0

I have been trying to import a public key into my bitcoin[1] node, but it keeps saying that it isn't valid.

The address '18uLJohita1yWTAcDpoLPpd2vNAtnsLW4E' publishes front-pages of the New York times into the BSV ledger and I want to add its public key to my bitcoin server so I can see new UTXOs. The key must be in HEX, per the command.

bitcoin-cli validateaddress 18uLJohita1yWTAcDpoLPpd2vNAtnsLW4E

{ "isvalid": true, "address": "18uLJohita1yWTAcDpoLPpd2vNAtnsLW4E", "scriptPubKey": "76a91456aea08d8feaefb18222fcef953366da2a7f200588ac", "ismine": false, "iswatchonly": false, "isscript": false }

bitcoin-cli importpubkey 76a91456aea08d8feaefb18222fcef953366da2a7f200588ac error code: -5 error message: Pubkey is not a valid public key

It accepts that I have sent hex, but it doesn't like it. This is clearly more than just the public key, I can see that from a vout:

"asm": "OP_DUP OP_HASH160 56aea08d8feaefb18222fcef953366da2a7f2005 OP_EQUALVERIFY # OP_CHECKSIG",

So maybe it wants me to remove the OP_DUP, OP_HASH160 and OP_EQUALVERIFY:

bitcoin-cli importpubkey 56aea08d8feaefb18222fcef953366da2a7f2005 Pubkey is not a valid public key

Hmm? Maybe it wants the checksum at the end...

echo 18uLJohita1yWTAcDpoLPpd2vNAtnsLW4E | base58 -d | xxd -p 0056aea08d8feaefb18222fcef953366da2a7f200559461147 bitcoin-cli importpubkey 0056aea08d8feaefb18222fcef953366da2a7f200559461147 error code: -5 error message: Pubkey is not a valid public key

I them write a bigendian reversal script and tried it, didn't help either.

I am official stumped.

Thanks in advance.

[1] I currently run bitcoin.sv and digibyte and have the same problem on both.

1
  • I was considering to close this question as off-topic because the user was asking about problems using altcoin software. However, since the question appears to have been based on a usage error that also applies to Bitcoin Core, I voted to reopen it.
    – Murch
    Mar 27 at 12:44

1 Answer 1

3

importpubkey imports a public key, not a scriptPubKey.

A public key in this context is a 66 character hexadecimal string starting with 02 or 03, or a 130 character hexadecimal string starting with 04. It encodes a secp256k1 public key. A scriptPubKey is any hexadecimal string, and encodes a locking script. These are distinct things; you can't use one in place of the other.

In this case, it appears you want to import an address. You can do so directly using importaddress.

1
  • 1
    and a scriptpubkey for P2PKH as in this Q includes the address (in binary or hex rather than base58check) but from the address (in any form) you can't backtrack to the pubkey Mar 27 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.