Pages:
Author

Topic: [solved]How decode raw transaction? - page 2. (Read 3932 times)

member
Activity: 138
Merit: 25
May 03, 2016, 05:39:31 PM
#4
Thanks, this explain a lot.
1.
OP_DUP duplicate top of stack? At start output, must something be on the stack. But may be many inputs and many outputs. Inputs pushes to stack and outputs duplicates?
For extract addresses for all cases I  must interprete opcodes?
2.
Daemon bitcoind often give error -5 for getrawtransaction method, why?
full member
Activity: 217
Merit: 259
May 03, 2016, 12:20:18 PM
#3
But topic is not solved:
I don't know how read addresses from script.

block raw: 0100000001a7c3e111fcf6acf6d14a5ec90faedf03ba5fe589069a48113cddd3a43a866c4901000 0006a473044022050c91af9918b85525ebf8802d69a904e85abe6dee306201689107c63a41e7ae2 02206faa2bb6a4073f78672364db85bce6022686c5b604f789d9b9b6383d1086bc830121031d4a1 0c5ae03e291aaf1fced54b1848535fbd926b671726297dd3455c399d380ffffffff02f0874b0000 0000001976a914f5d7afc3df015ecfd309dd591acf1b8f1e0c4ec088acc095a905000000001976a 91475ce9ff7867baffecbb0e61f879bab9e976e9c1488ac00000000

For the output addresses, find the script_pub_key.  If you follow the instructions in the links you posted you should get

Code:
76a914f5d7afc3df015ecfd309dd591acf1b8f1e0c4ec088ac

for the first output.  Now this is a standard pay to pubkey hash script that decodes as:

Code:
OP_DUP OP_HASH160 f5d7afc3df015ecfd309dd591acf1b8f1e0c4ec0 OP_EQUALVERIFY OP_CHECKSIG

So the hex number is the 160 bit hash of the public key.  Follow the instructions on https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses (starting at step 4) to get the address in base58 encoding.

For the input, you can either take the script_pub_key from the previous transactioon, or extract the pubkey from the input script (the second pushed number), which in this case is
Code:
031d4a10c5ae03e291aaf1fced54b1848535fbd926b671726297dd3455c399d380
Then use the above page, starting at step 2.
member
Activity: 138
Merit: 25
May 03, 2016, 11:38:59 AM
#2
But topic is not solved:
I don't know how read addresses from script.

block hash: 000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf
tx hash : 2871576bb636f71274736a65eeb897d94df7bab6ef9d9dc8eccde49a7658a7cc

block raw: 0100000001a7c3e111fcf6acf6d14a5ec90faedf03ba5fe589069a48113cddd3a43a866c4901000 0006a473044022050c91af9918b85525ebf8802d69a904e85abe6dee306201689107c63a41e7ae2 02206faa2bb6a4073f78672364db85bce6022686c5b604f789d9b9b6383d1086bc830121031d4a1 0c5ae03e291aaf1fced54b1848535fbd926b671726297dd3455c399d380ffffffff02f0874b0000 0000001976a914f5d7afc3df015ecfd309dd591acf1b8f1e0c4ec088acc095a905000000001976a 91475ce9ff7867baffecbb0e61f879bab9e976e9c1488ac00000000

https://blockexplorer.com/tx/2871576bb636f71274736a65eeb897d94df7bab6ef9d9dc8eccde49a7658a7cc

Input:
1 BTC 14cYFWwLHksk3226tUNs44rNpBJzNiPj8i
(scriptSig )

Output
0.0495 BTC (U) 1PQtwAZpv52PS9kgdsdd6hLHN9SCrv15UV Output is unspent
0.95 BTC (S) 1BjuazXd6pBtZpvDXwm76dueoiNJfXLj1p

No addresses in raw data. Is doc https://en.bitcoin.it/wiki/Script but i don't want proceed full interpretation, but find addresses.

I search full real example of interpretation data. What at start is at top of stack. At start each script is empty or is stuff of previous script?
member
Activity: 138
Merit: 25
May 03, 2016, 01:08:16 AM
#1
One solution is RPC method decoderawtransaction. But is is possible decode by myself? It would be faster and even easier decode from binary format than from JSON.
I found: http://bitcoin.stackexchange.com/questions/42510/how-to-decode-raw-tx-hex-programmatically
https://en.bitcoin.it/wiki/Transaction
Pages:
Jump to: