Bitcoin Forum
March 01, 2021, 07:45:56 AM *
News: Latest Bitcoin Core release: 0.21.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: btc rpc how to get the output address  (Read 158 times)
linuxqq
Newbie
*
Offline Offline

Activity: 23
Merit: 6


View Profile
November 17, 2020, 11:48:38 AM
Last edit: November 17, 2020, 12:07:42 PM by linuxqq
 #1

I am learning the transfer structure of Bitcoin's blockchain. I have encountered a problem and I hope to get help. First of all, thank you. I want to analyze the UTXO transfer in and out of a block, but the following json does not tell Which address did I transfer to, and how do I know which address the expense was transferred to? Why didn't I see vout['scriptPubKey']['addresses'],In the following message'value': Decimal('49.98000000'), how can I know where the 49 BTC went?


{'txid': 'a64be218809b61ac67ddc7f6c7f9fbebfe420cf75fe0318ebc727f060df48b37',
 'hash': 'a64be218809b61ac67ddc7f6c7f9fbebfe420cf75fe0318ebc727f060df48b37', 'version': 1, 'size': 276, 'vsize': 276,
 'weight': 1104, 'locktime': 0, 'vin': [
    {'txid': '131f68261e28a80c3300b048c4c51f3ca4745653ba7ad6b20cc9188322818f25', 'vout': 1, 'scriptSig': {
        'asm': '3045022100ef78daeb60d6332fa6f91ee93d95486d8601b5f2c1d1dc77633801dc6c0eb41902201 5b19e34de00ae729e20b97de8ac58ea8bb9227ba91a33bfaa26b7480e8a0005[ALL]',
        'hex': '483045022100ef78daeb60d6332fa6f91ee93d95486d8601b5f2c1d1dc77633801dc6c0eb419022 015b19e34de00ae729e20b97de8ac58ea8bb9227ba91a33bfaa26b7480e8a000501'},
     'sequence': 4294967295}], 'vout': [{'value': Decimal('0.01000000'), 'n': 0, 'scriptPubKey': {
    'asm': '041d1ffff1175ce4628ed11b4074956a3f0facc95ab388e47b95daa02891f6e0b9642d4ae2b68c0 787d2c95288ec42045a087c262d803b6fa14ecedb2a632f3df1 OP_CHECKSIG',
    'hex': '41041d1ffff1175ce4628ed11b4074956a3f0facc95ab388e47b95daa02891f6e0b9642d4ae2b68 c0787d2c95288ec42045a087c262d803b6fa14ecedb2a632f3df1ac',
    'type': 'pubkey'}}, {'value': Decimal('49.98000000'), 'n': 1, 'scriptPubKey': {
    'asm': '04f9804cfb86fb17441a6562b07c4ee8f012bdb2da5be022032e4b87100350ccc7c0f4d47078b06 c9d22b0ec10bdce4c590e0d01aed618987a6caa8c94d74ee6dc OP_CHECKSIG',
    'hex': '4104f9804cfb86fb17441a6562b07c4ee8f012bdb2da5be022032e4b87100350ccc7c0f4d47078b 06c9d22b0ec10bdce4c590e0d01aed618987a6caa8c94d74ee6dcac',
    'type': 'pubkey'}}],
 'hex': '0100000001258f81228318c90cb2d67aba535674a43c1fc5c448b000330ca8281e26681f1301000 00049483045022100ef78daeb60d6332fa6f91ee93d95486d8601b5f2c1d1dc77633801dc6c0eb4 19022015b19e34de00ae729e20b97de8ac58ea8bb9227ba91a33bfaa26b7480e8a000501fffffff f0240420f00000000004341041d1ffff1175ce4628ed11b4074956a3f0facc95ab388e47b95daa0 2891f6e0b9642d4ae2b68c0787d2c95288ec42045a087c262d803b6fa14ecedb2a632f3df1ac806 de72901000000434104f9804cfb86fb17441a6562b07c4ee8f012bdb2da5be022032e4b87100350 ccc7c0f4d47078b06c9d22b0ec10bdce4c590e0d01aed618987a6caa8c94d74ee6dcac00000000',
 'blockhash': '0000000049a63b4dda3a43450c19d085d6c28bfb4cbb2e0576815d7f31919c5d', 'confirmations': 654530,
 'time': 1233636459, 'blocktime': 1233636459}
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1614584756
Hero Member
*
Offline Offline

Posts: 1614584756

View Profile Personal Message (Offline)

Ignore
1614584756
Reply with quote  #2

1614584756
Report to moderator
mocacinno
Legendary
*
Online Online

Activity: 2240
Merit: 2927


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
November 17, 2020, 12:27:32 PM
Merited by HCP (2)
 #2

This might be an interesting read for you:
https://learnmeabitcoin.com/technical/p2pk

linuxqq
Newbie
*
Offline Offline

Activity: 23
Merit: 6


View Profile
November 17, 2020, 12:43:22 PM
 #3

This might be an interesting read for you:
https://learnmeabitcoin.com/technical/p2pk

Thank you for your reply. The example in the document you sent has "addresses": [
                     "1Q2TWHE3GMdB6BZKafqwxXtWAWgFt5Jvm3"
                 ], I want to know why the structure I see does not have a wallet address, so I don’t know which wallet to transfer to
mocacinno
Legendary
*
Online Online

Activity: 2240
Merit: 2927


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
November 17, 2020, 12:56:39 PM
Merited by ETFbitcoin (1), HCP (1), nc50lc (1)
 #4

It doesn't have a wallet address because it's a "Pay to Pubkey" script.

You're used to see "pay to pubkey hash" scripts... The hash of the pubkey IS the address Wink

In this case, it's just the pubkey... There is no "address"... If you were the owner of this wallet, you could spend the funds by providing a valid signature which can be verified against the pubkey that was funded. That's about it Smiley

You're just looking at very old blocks, p2pk scripts are very rare nowadays.

odolvlobo
Legendary
*
Offline Offline

Activity: 3150
Merit: 1808



View Profile
November 19, 2020, 07:08:25 AM
Merited by naufragus (1)
 #5

It doesn't have a wallet address because it's a "Pay to Pubkey" script.

You're used to see "pay to pubkey hash" scripts... The hash of the pubkey IS the address Wink

In this case, it's just the pubkey... There is no "address"... If you were the owner of this wallet, you could spend the funds by providing a valid signature which can be verified against the pubkey that was funded. That's about it Smiley

You're just looking at very old blocks, p2pk scripts are very rare nowadays.

If you want an address, I suppose you could construct an address from the public key.

Buy stuff on Amazon with BTC or convert Amazon points to BTC here: Purse.io
Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
naufragus
Newbie
*
Offline Offline

Activity: 22
Merit: 34


View Profile
November 21, 2020, 04:35:37 PM
Last edit: November 21, 2020, 08:24:09 PM by naufragus
 #6

If you are using Linux shell and run my script (bitcoin.tx.sh), which is a bitcoin-cli wrapper:

Code:
user@archhost ~ % bitcoin.tx.sh a64be218809b61ac67ddc7f6c7f9fbebfe420cf75fe0318ebc727f060df48b37
txs: 1/1

--------
Transaction information
TxId____: a64be218809b61ac67ddc7f6c7f9fbebfe420cf75fe0318ebc727f060df48b37
Hash____: a64be218809b61ac67ddc7f6c7f9fbebfe420cf75fe0318ebc727f060df48b37
BlkHash_: 0000000049a63b4dda3a43450c19d085d6c28bfb4cbb2e0576815d7f31919c5d
Time____: 1233636459    2009-02-03T04:47:39Z
BlkTime_: 1233636459    2009-02-03T04:47:39Z
LockTime: 0
Version_: 1
Vsize___: 276
Size____: 276
Weight__: 1104
Confirma: 650779

Vins
  TxIndex: 131f68261e28a80c3300b048c4c51f3ca4745653ba7ad6b20cc9188322818f25
  Sequenc: 4294967295
  VoutNum: 1
  Addresses
  Number_: 1    Value__: 49.99
    type: pubkey
    1AbHNFdKJeVL8FRZyRZoiTzG9VCmzLrtvm


Vouts
  Number_: 0    Value__: 0.01
  Addresses
    type: pubkey
    1CbAopr7sNMKjsJa8dAS6P5sM788kmMooo

  Number_: 1    Value__: 49.98
  Addresses
    type: pubkey
    1AbHNFdKJeVL8FRZyRZoiTzG9VCmzLrtvm


VinSum__: 49.99000000
VoutSum_: 49.99000000
TxFee___: 0

>>>final transaction parsing at: /home/user/00.transactions.parsed.txt
>>>took 1 seconds  (0 minutes)

The script uses grondilu's bitcoin-bash-tools to make the address from the pub key..
Script from my githubh repo: https://github.com/mountaineerbr/scripts/blob/master/bitcoin.tx.sh


The next script wraps grondilu's bitcoin bash functions. Here I
get the ASM (assembly) code, pack, double-sha256 and then
convert it to address with byte number 00.

Code:
user@archhost /tmp % bitcoin.hx.sh 041d1ffff1175ce4628ed11b4074956a3f0facc95ab388e47b95daa02891f6e0b9642d4ae2b68c0787d2c95288ec42045a087c262d803b6fa14ecedb2a632f3df1
1CbAopr7sNMKjsJa8dAS6P5sM788kmMooo

user@archhost /tmp % bitcoin.hx.sh 04f9804cfb86fb17441a6562b07c4ee8f012bdb2da5be022032e4b87100350ccc7c0f4d47078b06c9d22b0ec10bdce4c590e0d01aed618987a6caa8c94d74ee6dc
1AbHNFdKJeVL8FRZyRZoiTzG9VCmzLrtvm
https://github.com/mountaineerbr/scripts/blob/master/bitcoin.hx.sh
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!