As laid out in BIP-141, the witness for a P2WPKH spend is as follows:
The witness should include precisely 2 gadgets (≤ 520 bytes every). The primary one a signature, and the second a public key.
The signature consists of the same old R and s values that you simply’re on the lookout for, as earlier than.
Let us take a look at this transaction you retain linking to. Let us take a look at the primary enter.
We will see the scriptPubKey is
OP_HASH160 fcebfb01198e90e99875a913dd592650fd2df667 OP_EQUAL
This implies it’s a P2SH spend, the place the P2SH redeem script has the hash fcebfb0....67
Let us take a look at that redeem script then:
0020d687015ac2304c3213491ff4fc71ea15e9c170fddedd8bed92be2d191f8adddd
That is OP_0 adopted by a push of 32-bytes. Which means it is a P2WSH spend. As a result of this was wrapped inside P2SH, it is known as P2SH-P2WSH. However there isn’t a public key or signature concerned to date, simply scripts.
The witness consists of three pushes onto the stack. This contains the witness script:
OP_PUSHNUM_2 OP_PUSHBYTES_33 035e1822f3a6eec3911545188bb0e6df3826eef8b630a77d1e344ba5954d9534a8 OP_PUSHBYTES_33 03694100a1f02854db3acac05c878053aba59fedfe3ebb1b7e094051aa61da6ba8 OP_PUSHBYTES_33 03e9509f6b6ad39542aa816c24d50d8ca7d83cfa6b430f0c366184957961a07fd6 OP_PUSHNUM_3 OP_CHECKMULTISIG
In different phrases, it is a 2-of-3 multisig. The opposite two gadgets on the witness stack are due to this fact signatures. However that is going to be completely different for each attainable kind of script, so there is not going to be a strategy to simply “extract” the signature from P2WSH spends. Greatest to focus simply on the key-based spends.

