Handy to have quickly available, and a good pedagogical tool.
Add scriptPubKey field to validateaddress RPC call #4964
pull petertodd wants to merge 1 commits into bitcoin:master from petertodd:validateaddress-return-scriptpubkey changing 1 files +5 −0-
petertodd commented at 9:26 AM on September 23, 2014: contributor
-
Add scriptPubKey field to validateaddress RPC call 426a74ed3c
-
BitcoinPullTester commented at 9:41 AM on September 23, 2014: none
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4964_426a74ed3c3c98b791a8445dd276e89fc5d6175e/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
- laanwj added the label RPC on Sep 23, 2014
-
laanwj commented at 9:28 AM on September 24, 2014: member
Agree that this could be handy, but I don't think we should be adding more 'library-like' functionality to RPC (ie, stuff that doesn't actually require a running node), we're trying to move in the opposite direction.
-
gmaxwell commented at 12:26 AM on October 9, 2014: contributor
Really this isn't that much of a library call, I think. It consults the wallet. Current addresses are simple enough that a stateless library could do it, but something fancier might need the wallet. Having people unaware of scriptPubKey as a pubkey has certantly made it harder for people to understand the system.
-
TheBlueMatt commented at 12:41 AM on October 9, 2014: member
I'm not sure this isnt more something for bitcoin-tx.
-
laanwj commented at 10:41 AM on October 9, 2014: member
@gmaxwell
validateaddressconsults the wallet when it is built in; without wallet it's a pure library call. But I didn't mean to say thatvalidateaddressis a library call, functionality to compute a scriptPubKey certainly is. @TheBlueMatt Agreed. Would be more something for an utility. -
laanwj commented at 8:45 AM on October 10, 2014: member
I've verified that this matches against python-bitcoinllib for both P2SH and legacy addresses, for example:
>>> from bitcoin.wallet import CBitcoinAddress >>> binascii.b2a_hex(CBitcoinAddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy').to_scriptPubKey()) 'a914b472a266d0bd89c13706a4132ccfb16f7c3b9fcb87'$ src/bitcoin-cli -datadir=/store/tmp/testbtc validateaddress 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy { "isvalid" : true, "address" : "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy", "scriptPubKey" : "a914b472a266d0bd89c13706a4132ccfb16f7c3b9fcb87", "ismine" : false }One nit: validateaddress can return a "pubkey" entry as well when the address is a receiving address in the wallet which is also a hex string. Could
scriptPubKeyversuspubkeycause (dangerous) confusion? -
laanwj commented at 10:38 AM on October 10, 2014: member
Making a pedagogical point is good, but not if it would cost someone a lot of money. I don't think that's a risk as the underlying data is a different type/structure, but I wanted to mention it. Trying to use a scriptPubKey as pubkey would get an OpenSSL error about invalid encoding (and thus an invalid transaction), and the other way around would get an invalid script (which at least fails the isCanonical check but probably more...).
- jgarzik merged this on Dec 31, 2014
- jgarzik closed this on Dec 31, 2014
- jgarzik referenced this in commit 95ecc0a857 on Dec 31, 2014
-
jgarzik commented at 12:24 PM on December 31, 2014: contributor
ACK
- MarcoFalke locked this on Sep 8, 2021