Skip to main content
10 events
when toggle format what by license comment
Sep 18, 2023 at 23:55 comment added dassd Yes, I absolutely agree that Pieter by that implicitly said that there must be exactly 2 elements, however, I don't think it's bad to state it explicitly since such an explicit check exists. I also agree that there are several different ways to properly implement the spec, but I think we should only look at the referent, which is bitcoin core. However, in the end, whether it's an implicit check (the script simply won't work if there's a different number of elements than 2) or an explicit one, or both (case in bitcoin core), it boils down to the same thing in this case.
Sep 18, 2023 at 23:29 comment added Vojtěch Strnad Pieter's answer already requires that the resulting stack has exactly one element, so a requirement that the initial stack has exactly two elements is redundant. Again, there are multiple algorithms that equivalently implement the specification.
Sep 18, 2023 at 22:42 comment added dassd I proposed an edit that includes this check.
Sep 18, 2023 at 22:37 comment added dassd So there is an explicit check. I guess that should be added to Pieter's answer.
Sep 18, 2023 at 21:59 comment added Vojtěch Strnad That depends on the implementation, as there are multiple equivalent ways of implementing the specification given in BIP141. Specifically, Bitcoin Core has an explicit check that the stack size is 2 and then feeds it into a P2PKH script.
Sep 18, 2023 at 21:53 comment added dassd Yes, I completely agree with you that there is an implicit check if 2 items are in witness data, because if it is not, the script will not pass. We did not understand. I meant whether there is an explicit check, like for example: witness_data.count == 2. Something similar to how P2WSH has a check to see if the witness data is empty.
Sep 18, 2023 at 21:00 comment added Vojtěch Strnad In his answer, Pieter interprets P2WPKH as a P2PKH script with the witness stack as the initial stack, with the requirement that the resulting stack must have exactly one element. That implicitly requires that the witness stack has exactly two elements, because any other length will either fail the script or result in more than one item on the resulting stack.
Sep 18, 2023 at 20:50 comment added Vojtěch Strnad Yes. From the specification: "The witness must consist of exactly 2 items (≤ 520 bytes each). The first one a signature, and the second one a public key."
Sep 18, 2023 at 20:25 comment added dassd Are you sure there is a check (requirement) for P2WPKH that exactly 2 elements are in the witness data? Pieter Wuille did not mention that requirement for P2WPKH in his answer.
Sep 18, 2023 at 19:00 history answered Vojtěch Strnad CC BY-SA 4.0