1

What RPC(s) can I use to transform an address to a paying script (0014<addr>)?

1
  • 1
    Hi warchantua, could you please describe a little more what you're trying to achieve? What are you starting out with, what should the final outcome look like? – Murch Dec 3 '20 at 15:15
2

Try validateaddress, note the scriptPubKey in the output of these examples:

$ bitcoin-cli validateaddress bc1q7ckr2hlws6ku4mlaggvmfqwgs42zjm4qf3s7hy
{
  "isvalid": true,
  "address": "bc1q7ckr2hlws6ku4mlaggvmfqwgs42zjm4qf3s7hy",
  "scriptPubKey": "0014f62c355fee86adcaeffd4219b481c88554296ea0",
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "f62c355fee86adcaeffd4219b481c88554296ea0"
}

$ bitcoin-cli validateaddress 1MWrgo4rm1aoPYFjCCMXgr1e564xVyHCqM
{
  "isvalid": true,
  "address": "1MWrgo4rm1aoPYFjCCMXgr1e564xVyHCqM",
  "scriptPubKey": "76a914e1080defe0aa086f1d5f698faf614e8f67af6e3b88ac",
  "isscript": false,
  "iswitness": false
}

Update: RPC getaddressinfo will also return the matching output script.

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