Witnesses Now for our signature and public key. But how does it work? On the face of it, it seems like youre burning money by not signing any outputs. Or you can calculate it manually using openssl printf xxd -r -p openssl sha256 (stdin) printf xxd -r -p openssl ripemd160 (stdin) Notes: ef and 0 indicate testnet and a compressed key, so they are removed. If youre still wondering, lets break it down (from left to right Version : 02000000, flag: 0001 (if present, indicates segwit). First though lets remind ourselves of the process. Pu (Xk, Yk) (Xm Public Key(Xpub, Ypub) (Xm Private KeyPr G(Xg, Yg). Lets use Output 1 from the transaction above: bitcoin-cli -regtest listunspent "txid "vout 0, "address "account "test "redeemScript "scriptPubKey "amount.00000000, "confirmations 1, "spendable true, "solvable true, "safe true. This essentially says I only agree to move my BTC with this exact combination of inputs and outputs. I dont think I could come up with a better example than this one by Alex Mzrahi. M # Use promo code, medium2 to get the Udemy course for.99 #.
This then makes a complete tx, which can be broadcast to execute the sale trustlessly. Such a transaction allows anyone to define an input, and include the input in any other transaction, with arbitrary outputs. You can easily pull this information out using the decoderawtransaction method in bitcoind, under the vin scriptSig key.
Sighash_none - This one is a bit more confusing. Our script sig becomes: Outputs Lets send 1 BTC to address: 1 BTC 100,000,000 satoshi so Output 1 Value : 00e1f (remember, little endian). At that point, such a signature essentially means I agree to spend my money, provided all these other people spend theirs too. If the input has a vin that exceeds the number of outputs, it produces a signature that is valid, but not tied to any inputs. The values for this flag are found in interpreter. Rp (Xr, Yr) (Mh)Xr*Pr ( G(Xg, Yg Sf, rp (Xr, Yr (Mh)Xr*Pr Mh)Xr*Pr) Rn* G(Xg, Yg)Rn* G(Xg, Yg). The equation above can be substituted in the following way to prove this. The Output 2 public key script. Sighash_single - This can be used to send BTC in scenarios where you only want to make the transfer provided some other parties are making a transfer too.