Sunday, December 29, 2024

signature – How do I get hash to confirm transaction?

Right here is how issues might be carried out backwards. Sadly, the bitcoin-explorer (bx) confirm mechanism works a bit of in another way however considerably much like what you have been anticipating. Step 4 under would possibly present particulars that is likely to be helpful for what you’re doing. Step 5 under completes the validation offline.

1. Right here is the straightforward solution to compute transaction IDs from the uncooked hexadecimal transactions.

% echo 01000000018a8a9f938c251be60da2711c6bf168c66213fae8e26251fcec47f9a41d0e71e3020000006b483045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d012103c0f217eb4428c61d47d8aa084a28c3d3d26f43b6569283f08fec5451a5fc8c98ffffffff0200803801000000001976a914d2c6b9c7f146ea4039e6ae67904eb94d479b7ed688ac06d79e460e0000001976a914b85f8cde95fe9b30872e49d5b961a4af5d07518688ac00000000 | bx bitcoin256

9b4912711de5e258a74a529227f43647bc3b2304212fb508c5f8e910d5986270

2. Listed below are two means (1st is offline, 2nd is on-line) to extract the Endorsement/Signature and related Public Key used for the TX_ID 9b4912711de5e258a74a529227f43647bc3b2304212fb508c5f8e910d5986270 enter:

% echo 01000000018a8a9f938c251be60da2711c6bf168c66213fae8e26251fcec47f9a41d0e71e3020000006b483045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d012103c0f217eb4428c61d47d8aa084a28c3d3d26f43b6569283f08fec5451a5fc8c98ffffffff0200803801000000001976a914d2c6b9c7f146ea4039e6ae67904eb94d479b7ed688ac06d79e460e0000001976a914b85f8cde95fe9b30872e49d5b961a4af5d07518688ac00000000 | bx tx-decode

or

% bx fetch-tx -c ~/bitcoin-explorer/bx-mainnet-remote.cfg 9b4912711de5e258a74a529227f43647bc3b2304212fb508c5f8e910d5986270

that each yield:

transaction
{
    hash 9b4912711de5e258a74a529227f43647bc3b2304212fb508c5f8e910d5986270
    inputs
    {
        enter
        {
            address_hash a0d48c129cfde8f124a16f4d69bc47fd7fb5780d
            previous_output
            {
                hash e3710e1da4f947ecfc5162e2e8fa1362c668f16b1c71a20de61b258c939f8a8a
                index 2
            }
            script "[3045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d01] [03c0f217eb4428c61d47d8aa084a28c3d3d26f43b6569283f08fec5451a5fc8c98]"
            sequence 4294967295
        }
    }
    lock_time 0
    outputs
    {
        output
        {
            address_hash d2c6b9c7f146ea4039e6ae67904eb94d479b7ed6
            script "dup hash160 [d2c6b9c7f146ea4039e6ae67904eb94d479b7ed6] equalverify checksig"
            worth 20480000
        }
        output
        {
            address_hash b85f8cde95fe9b30872e49d5b961a4af5d075186
            script "dup hash160 [b85f8cde95fe9b30872e49d5b961a4af5d075186] equalverify checksig"
            worth 61314356998
        }
    }
    model 1
}

Distinguished Encoding Guidelines (DER) formatted Signature = 3045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d01

R =

% echo 3045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d01 | lower -c 9-74
00ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed429

S =

% echo 3045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d01 | lower -c 79-142
4efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d

Pubkey = 03c0f217eb4428c61d47d8aa084a28c3d3d26f43b6569283f08fec5451a5fc8c98

3. The third output of TXID e3710e1da4f947ecfc5162e2e8fa1362c668f16b1c71a20de61b258c939f8a8a incorporates the unique enter script that was signed, requires an extra on-line question:

% bx fetch-tx -c ~/bitcoin-explorer/bx-mainnet-remote.cfg e3710e1da4f947ecfc5162e2e8fa1362c668f16b1c71a20de61b258c939f8a8a

transaction
{
    hash e3710e1da4f947ecfc5162e2e8fa1362c668f16b1c71a20de61b258c939f8a8a
    inputs
    {
        enter
        {
            address_hash 3480cd7a92d09974aacc473512ca80a686249498
            previous_output
            {
                hash 4b7b945088ad38de258490d02bdca724548818e1ad184d0e00a2d4d1e82229c8
                index 0
            }
            script "[3046022100da2122351174582ca4f8b9cfc2567bd2c95c3f30be13ce0f20422ba6c2d55806022100af211740671144cc8cbce04e8028e60eb1028af661a8eba77430e4a8615925da01] [02416953ece00bbc3a1ebca108c8961abae0bcc613ecf838bb0e5799202fbe7ae4]"
            sequence 4294967295
        }
    }
    lock_time 0
    outputs
    {
        output
        {
            address_hash ead65b0c5d7abc0af467ae2f34ed1b84a6662fda
            script "dup hash160 [ead65b0c5d7abc0af467ae2f34ed1b84a6662fda] equalverify checksig"
            worth 12557630
        }
        output
        {
            address_hash 59cca2f8c91a9784c6c38da5a10f00644238b527
            script "dup hash160 [59cca2f8c91a9784c6c38da5a10f00644238b527] equalverify checksig"
            worth 10100000
        }
        output
        {
            address_hash a0d48c129cfde8f124a16f4d69bc47fd7fb5780d
            script "dup hash160 [a0d48c129cfde8f124a16f4d69bc47fd7fb5780d] equalverify checksig"
            worth 61334886998
        }
    }
    model 1
}

ASCII encoded script = "dup hash160 [a0d48c129cfde8f124a16f4d69bc47fd7fb5780d] equalverify checksig"

and computing the corresponding P2PKH handle:

% echo a0d48c129cfde8f124a16f4d69bc47fd7fb5780d | bx address-encode -v 0

1FfPjjFG1uoA62yiTsje8biYYvEhf8puQP

4. For self consciousness, compute Hex encoded script and related sha256 worth:

% echo “dup hash160 [a0d48c129cfde8f124a16f4d69bc47fd7fb5780d] equalverify checksig” | bx script-encode

76a914a0d48c129cfde8f124a16f4d69bc47fd7fb5780d88ac

% echo 76a914a0d48c129cfde8f124a16f4d69bc47fd7fb5780d88ac | bx sha256
0d9288118ccdc74e6ce85ced746aa48afbd30eb70f58e4ce009a78dd96faf33d

5. Affirm signature is legitimate utilizing an offline command:

% echo 01000000018a8a9f938c251be60da2711c6bf168c66213fae8e26251fcec47f9a41d0e71e3020000006b483045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d012103c0f217eb4428c61d47d8aa084a28c3d3d26f43b6569283f08fec5451a5fc8c98ffffffff0200803801000000001976a914d2c6b9c7f146ea4039e6ae67904eb94d479b7ed688ac06d79e460e0000001976a914b85f8cde95fe9b30872e49d5b961a4af5d07518688ac00000000 | bx input-validate -i 0 03c0f217eb4428c61d47d8aa084a28c3d3d26f43b6569283f08fec5451a5fc8c98 “dup hash160 [a0d48c129cfde8f124a16f4d69bc47fd7fb5780d] equalverify checksig” 3045022100ad775acd2d0b14904771c28754e0e510ecd8af842732c5c15a0899d1e28ed42902204efb34805a958174f6a6273444cde7f97cf38cec0d96d17c7921490f58e6379d01

The endorsement is legitimate.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles