Bitcoin Forum
April 27, 2024, 05:56:49 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getrawtransaction not decoding address?  (Read 76 times)
mine49 (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 8


View Profile
September 09, 2023, 08:50:35 AM
Merited by o_e_l_e_o (4), vapourminer (2), ABCbits (2)
 #1

Hi all! I'm running a slightly modified Bitcoin Core node (for our own educational blockchain, Bitcoin Edu, https://github.com/bitcoinedu-io).

We recently upgraded the code base to 24.0. The RPC return format for getrawtransaction seems to have changed slightly, a single "address" is decoded instead of the "addresses" field. That's fine. But, we found one peculiar transaction (in our chain):

Old v21 bitcoind, one of the outputs:

Code:
     "scriptPubKey": {
        "asm": "02d316d8a24940934460a6c97de69718afb1ea6e5f054ae60b1c62e6cd2758e9ed OP_CHECKSIG",
        "hex": "2102d316d8a24940934460a6c97de69718afb1ea6e5f054ae60b1c62e6cd2758e9edac",
        "reqSigs": 1,
        "type": "pubkey",
        "addresses": [
          "1DZxEMQqMHdgcazmMk4XtedUmXhsntzuMN"
        ]
      }

But, the new v24 bitcoind, responds with:

Code:
      "scriptPubKey": {                                                             
        "asm": "02d316d8a24940934460a6c97de69718afb1ea6e5f054ae60b1c62e6cd2758e9ed OP_CHECKSIG",
        "desc": "pk(02d316d8a24940934460a6c97de69718afb1ea6e5f054ae60b1c62e6cd2758e9ed)#jdtmre63",
        "hex": "2102d316d8a24940934460a6c97de69718afb1ea6e5f054ae60b1c62e6cd2758e9edac",
        "type": "pubkey"                                                           
      }

Here we got no "address" at all. This is a bit rare, normally we get an "address" field and everything looks alright. But, in this case, why didn't the script get decoded? Anyone have a clue? A bug?
1714240609
Hero Member
*
Offline Offline

Posts: 1714240609

View Profile Personal Message (Offline)

Ignore
1714240609
Reply with quote  #2

1714240609
Report to moderator
1714240609
Hero Member
*
Offline Offline

Posts: 1714240609

View Profile Personal Message (Offline)

Ignore
1714240609
Reply with quote  #2

1714240609
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714240609
Hero Member
*
Offline Offline

Posts: 1714240609

View Profile Personal Message (Offline)

Ignore
1714240609
Reply with quote  #2

1714240609
Report to moderator
1714240609
Hero Member
*
Offline Offline

Posts: 1714240609

View Profile Personal Message (Offline)

Ignore
1714240609
Reply with quote  #2

1714240609
Report to moderator
1714240609
Hero Member
*
Offline Offline

Posts: 1714240609

View Profile Personal Message (Offline)

Ignore
1714240609
Reply with quote  #2

1714240609
Report to moderator
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18507


View Profile
September 09, 2023, 09:08:45 AM
Last edit: September 09, 2023, 12:26:59 PM by o_e_l_e_o
Merited by ABCbits (3), vapourminer (1), Findingnemo (1)
 #2

The old "addresses" field was initial depreciated in v22.0.0 and replaced with a new "sane addresses" field: https://github.com/bitcoin/bitcoin/pull/20286
The old field was then fully removed in v23.0.0: https://github.com/bitcoin/bitcoin/pull/22650

If you look at the RPC docs for anything from v23 onward (https://bitcoincore.org/en/doc/25.0.0/rpc/rawtransactions/getrawtransaction/), you'll see the address field now returns an address "only if a well-defined address exists". Given that the script you have shared is pay to pubkey, and not pay to pubkey hash, then you are not paying an address and so getrawtransaction will not return an address.
mine49 (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 8


View Profile
September 09, 2023, 09:14:58 AM
 #3

Great! Thank's for the explanation. That makes sense! I wonder how we managed to get some "pubkey" outputs at all. We probably experimented too much some years back  Smiley
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6693


bitcoincleanup.com / bitmixlist.org


View Profile WWW
September 09, 2023, 11:24:08 AM
 #4

Great! Thank's for the explanation. That makes sense! I wonder how we managed to get some "pubkey" outputs at all. We probably experimented too much some years back  Smiley

Yeah, as oeleo said, if it's not a common address type then Bitcoin Core will bail out during the RPC call and won't return an address. Basically if it's P2PKH, P2SH, P2[w]PKH and so on, that's what they call a common address type. If you however have a complex multisig script then determining the address type will probably fail since there are many ways you can make a multisig script look valid.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
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!