in

address – How to extract addresses from input in raw transaction

Have I understood the concept of address, account and wallet correctly and how the wallet balance is calculated?

[ad_1]

The bitcoin-exlporer (bx) tool applied below does not yet support the segwit-encoded portion of analyzing a raw hexadecimal transaction (TX). However, the bx commands below can analyze the results offline given the supplied raw TX provided above, and two pertinent TXs associated with the two input UTXOs.

% echo 01000000000102b4370d52c1e1dc67b0250ef7bd5265146d4def0beacfefd99660a86baf97faf000000000232200202dc520822e73d4262000d3b456b16df1d07b0ba9d238f3063379d65840fd38e7feffffff92e7b08c7a67a7a783b52d83e7b051a4812e496fac181aaadcaa69a3b526ca500100000023220020357bc74e1f825c4628519a3322f2aa9b2c5bd55b523149d4e1f7fe2f273ce7d6feffffff02a08601000000000017a914113e1767186f0280174123ad0c22e8929f994c1c87f4fd01000000000017a9148160a47aeafb68288f0df8551d5d9dddd22a643387040047304402202575f8326e510b8213d70a8213ab1a36cd2984b16673ef3579960d0089ad13de022020ec4e78129c084103909acec0319f7d326fff699de142ab354be9570d68dc170147304402202bc22860e84e0311bbc175940c2b3b5435255dc7ca3fb0d12e5f03df80237b880220536eceee1aace094825f0fd884d057e395102f4e4627188fe6dd5648cdc7a457014752210274ecb4e28e6b7be314d844bb7561b605d537106f7f5c3eaba31a8cd3dd0097c8210343ed9c58350b4013b3c9a02da2148d59e8109a90f0fa0ea77d31b8570990d46352ae0400473044022042d6861f81b617cfbe51e7efefb59dd990d4c0057b43645d2f006db93b38c59e02204595b7f822546082b0ee1efb6966c97b2d8174c96b670a10bc9d78d3cf7ba99101483045022100bb3a612fe17f261a0c5e9db20a087362c10556571ef54866ab29cfdb94975236022037bebec4c0459bba21656cb36b331313c2dd6008ed7a2479efca659c7fc97c9d0147522103838edaeadeed0e9f660e725970787b69ad4926afe1f19626d5476d356cb3b4722103c37f3b264f674c6c2e273e06da7fb7fe720be6828f251c71d0cb10e349d0222d52ae2f3f0800 | bx tx-decode

{
    hash b0dd3d915a568c9d48e37b3fbfca58ae3276a5dba176fdf30f18af794310cc02
    inputs
    {
        input
        {
            address_hash 49e282ad0605c1cb63ff45fc34b14357859e8d08
            previous_output
            {
                hash f0fa97af6ba86096d9efcfea0bef4d6d146552bdf70e25b067dce1c1520d37b4
                index 0
            }
            script [00202dc520822e73d4262000d3b456b16df1d07b0ba9d238f3063379d65840fd38e7]
            sequence 4294967294
            witness "[] [304402202575f8326e510b8213d70a8213ab1a36cd2984b16673ef3579960d0089ad13de022020ec4e78129c084103909acec0319f7d326fff699de142ab354be9570d68dc1701] [304402202bc22860e84e0311bbc175940c2b3b5435255dc7ca3fb0d12e5f03df80237b880220536eceee1aace094825f0fd884d057e395102f4e4627188fe6dd5648cdc7a45701] [52210274ecb4e28e6b7be314d844bb7561b605d537106f7f5c3eaba31a8cd3dd0097c8210343ed9c58350b4013b3c9a02da2148d59e8109a90f0fa0ea77d31b8570990d46352ae]"
        }
        input
        {
            address_hash 70871ecb261f3df9a9d325b33ef6d8acb5074258
            previous_output
            {
                hash 50ca26b5a369aadcaa1a18ac6f492e81a451b0e7832db583a7a7677a8cb0e792
                index 1
            }
            script [0020357bc74e1f825c4628519a3322f2aa9b2c5bd55b523149d4e1f7fe2f273ce7d6]
            sequence 4294967294
            witness "[] [3044022042d6861f81b617cfbe51e7efefb59dd990d4c0057b43645d2f006db93b38c59e02204595b7f822546082b0ee1efb6966c97b2d8174c96b670a10bc9d78d3cf7ba99101] [3045022100bb3a612fe17f261a0c5e9db20a087362c10556571ef54866ab29cfdb94975236022037bebec4c0459bba21656cb36b331313c2dd6008ed7a2479efca659c7fc97c9d01] [522103838edaeadeed0e9f660e725970787b69ad4926afe1f19626d5476d356cb3b4722103c37f3b264f674c6c2e273e06da7fb7fe720be6828f251c71d0cb10e349d0222d52ae]"
        }
    }
    lock_time 540463
    outputs
    {
        output
        {
            address_hash 113e1767186f0280174123ad0c22e8929f994c1c
            script "hash160 [113e1767186f0280174123ad0c22e8929f994c1c] equal"
            value 100000
        }
        output
        {
            address_hash 8160a47aeafb68288f0df8551d5d9dddd22a6433
            script "hash160 [8160a47aeafb68288f0df8551d5d9dddd22a6433] equal"
            value 130548
        }
    }
    version 1
}

Then one needs to examine the encumbrance scripts associated with the following to affirm determine if they P2PKH or P2SH address types:

1) transaction ID f0fa97af6ba86096d9efcfea0bef4d6d146552bdf70e25b067dce1c1520d37b4 and index 0

2) transaction ID 50ca26b5a369aadcaa1a18ac6f492e81a451b0e7832db583a7a7677a8cb0e792 and index 1

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

transaction
{
    hash f0fa97af6ba86096d9efcfea0bef4d6d146552bdf70e25b067dce1c1520d37b4
    inputs
    {
        input
        {
            address_hash 40ef0e3af404842b44912f6a65ca4adfb8f93a1a
            previous_output
            {
                hash f0eda490f5e8c3096b74b66524ff9c7b6fa1b9d4280e8372476af1d202a8b360
                index 1
            }
            script [0020de730ce4f827ac7c63ea8c9a47419875eacaf167f9391eb5d30817a181aca8d3]
            sequence 4294967294
        }
    }
    lock_time 539071
    outputs
    {
        output
        {
            address_hash 49e282ad0605c1cb63ff45fc34b14357859e8d08
            script "hash160 [49e282ad0605c1cb63ff45fc34b14357859e8d08] equal"
            value 18640
        }
        output
        {
            address_hash 113e1767186f0280174123ad0c22e8929f994c1c
            script "hash160 [113e1767186f0280174123ad0c22e8929f994c1c] equal"
            value 30000
        }
    }
    version 1
}

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

transaction
{
    hash 50ca26b5a369aadcaa1a18ac6f492e81a451b0e7832db583a7a7677a8cb0e792
    inputs
    {
        input
        {
            address_hash 62979379f3e415ef86d5dcecf9c93a9930333ce6
            previous_output
            {
                hash dbc6bff3ef644974667316072c6e28e5c58c18e62f8282ff624fde7d179639b2
                index 3
            }
            script [0020a9250a9c4e56b3d822717c37c713d30618f2af8f5932ded48fd6c8b3f0b5ff05]
            sequence 4294967295
        }
    }
    lock_time 0
    outputs
    {
        output
        {
            address_hash 877f4856923528187ab9708660fa201e4282ef8f
            script "dup hash160 [877f4856923528187ab9708660fa201e4282ef8f] equalverify checksig"
            value 10000
        }
        output
        {
            address_hash 70871ecb261f3df9a9d325b33ef6d8acb5074258
            script "hash160 [70871ecb261f3df9a9d325b33ef6d8acb5074258] equal"
            value 212250
        }
    }
    version 1
}

Upon examination of the two different encumbrance scripts are of P2SH form:

1) script “hash160 [49e282ad0605c1cb63ff45fc34b14357859e8d08] equal”

2) script “hash160 [70871ecb261f3df9a9d325b33ef6d8acb5074258] equal”

the two address_hash data values are operated on as follows:

% echo 49e282ad0605c1cb63ff45fc34b14357859e8d08 | bx base58check-encode -v 5
38Rgbmaxitveg1S8UNbWjwV5UMoBt3PtnG

% echo 70871ecb261f3df9a9d325b33ef6d8acb5074258 | bx base58check-encode -v 5
3Bx1UMJieKFngvBA8m2VqE6s4wXYKWzhkP

If a particular addresses were of P2PKH form, replace the -v 5 with -v 0 in the operations above.

BTW – It looks like the two redeemed P2SH inputs are really both 2 of 2 multisig addresses based upon the examination of the two DER-encoded signatures and knowing the last data elements are script-encoded.

% echo 52210274ecb4e28e6b7be314d844bb7561b605d537106f7f5c3eaba31a8cd3dd0097c8210343ed9c58350b4013b3c9a02da2148d59e8109a90f0fa0ea77d31b8570990d46352ae | bx script-decode

2 [0274ecb4e28e6b7be314d844bb7561b605d537106f7f5c3eaba31a8cd3dd0097c8] [0343ed9c58350b4013b3c9a02da2148d59e8109a90f0fa0ea77d31b8570990d463] 2 checkmultisig

% echo 522103838edaeadeed0e9f660e725970787b69ad4926afe1f19626d5476d356cb3b4722103c37f3b264f674c6c2e273e06da7fb7fe720be6828f251c71d0cb10e349d0222d52ae | bx script-decode

2 [03838edaeadeed0e9f660e725970787b69ad4926afe1f19626d5476d356cb3b472] [03c37f3b264f674c6c2e273e06da7fb7fe720be6828f251c71d0cb10e349d0222d] 2 checkmultisig

Bitcoin Explorer kicks butt!!

[ad_2]

Source link

Written by BTC Artist

Leave a Reply

Your email address will not be published. Required fields are marked *

Credit Suisse: Short term CDS at >830 bps

Credit Suisse: Short term CDS at >830 bps

Brazil Breaks World Record for Bitcoin Payments Via Lightning Network