Artificial Intelligence
Please fill the required field.

Private key 13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so

4QpJLxmVLu Extended public key: 13bYjry1ZgCKoGd2GmHZayqA4E7EASY3J Public Key: 13fcm73ukqeNEojPs2C1v2M1M4dZNmgLfAU6YCjDaQSJ Let's start redeeming some Inputs. With this set of values, we can redeem the coins. There seems to be confusion around the redeem script vs. scriptSig. The redeem script is the scriptPubKey (in the special form of a push to <hash-of-pubkey> and the info from the private key is put into the scriptSig. The goal is to create a scriptSig which moves funds, which requires the hash of the public key (and <OP_CHECKSIG>). This hash of the public key can be created using: >>> import hashlib >>> compress_hex_pubkey = "13fcm73ukqeNEojPs2C1v2M1M4dZNmgLfAU6YCjDaQSJ" >>> pk_bytes = bytes.fromhex(compress_hex_pubkey) >>> hex_pubKey = hashlib.sha256(pk_bytes).hexdigest() >>> hex_pubKeyRipeMd ="ripemd160", bytes.fromhex(hex_pubKey)).hexdigest() >>> hex_redeem_script = ("76" + # OP_DUP "a9" + # OP_HASH160 ("14" if len(hex_pubKeyRipeMd) == 40 else "15") + # length of pubKey in bytes hex_pubKeyRipeMd + # OP_EQUALVERIFY + OP_CHECKSIG "88" + # [左] OP_EQUALVERIFY [右] "ac") # OP_CHECKSIG, sighashes=None) >>> redeem_script = bytes.fromhex(hex_redeem_script) >>> redeem_script.hex() "76a914ba3b02d1c4b459e03455ae7b3ed5af3adedb56ea88ac" This will give us `ba3b02d1c4b459e03455ae7b3ed5af3adedb56ea`. Then this can be put into the scriptSig together with a signature: >>> signature = b'N0\x16gq\x16y\x82\x95\x8f\xd2b\xf6\x92\xef\x86\xf3d2\xe6omq\x9d\x0f{\xc5!l\x00\xe1\xf4F+' >>> sigLength = len(signature).to_bytes(1, 'little').hex() >>> "483045022100" + signature.hex() + "01" + sigLength + "ffffffff" + \ "ba3b02d1c4b459e03455ae7b3ed5af3adedb56ea" # push sig "4830450221004e30166771167982958fd262f692ef86f36432e66f6d719d0f7bc5216c00e1f446616fffffffba3b02d1c4b459e03455ae7b3ed5af3adedb56ea" and the public key ... >>> "2102a12840cbe82f3d69e3775838b040c1c7cb709fc60a3934160653334331374b6bcc" # push data (serialized) "2102a12840cbe82f3d69e3775838b040c1c7cb709fc60a3934160653334331374b6bcc" and nothing more. Create the txnbody using an old transaction, use swap, finalize and broadcast the transaction. Output: 0.0003 Bitcoin Sender address: 13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so4QpJLxmVLu Receiver address: 13bYjry1ZgCKoGd2GmHZayqA4E7EASY3J