1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

bitcoin core rpc/ getnewaddressでp2pkhアドレスを得るには

1
Posted at

環境

bitcoind v0.16.99.0-87a9d03c0

困った

bitcoin core rpcでgetnewaddressすると

bash
$ bitcoin-cli -regtest getnewaddress
2N1Xx8taTNrm2RLxdeHMHT5fqgPJ219FWti

のように2で始まるアドレス、すなわち(テストネットの)p2SHのアドレスを教えてくれる1
でも、m,nではじまるP2PKHアドレスがほしい...。

どうして?

0.16からsegwitアドレスがデフォルトに2

Bitcoin Core 0.16.0 introduces full support for segwit in the wallet and user interfaces. A new -addresstype argument has been added, which supports legacy, p2sh-segwit (default), and bech32 addresses.

segwitアドレスを取得するaddwitnessaddressというコマンドがあったらしいが、それが廃止になり、getnewaddressの引数でアドレスタイプを指定できるようになった3

wallet RPC addwitnessaddress was deprecated and will be removed in version 0.17, set the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead.

どうする?

getnewaddressの引数はlabelとaddress_type。
address_typeに'legacy'を指定することで、P2PKHアドレスを得ることができる4

bash
$ bitcoin-cli getnewaddress "" "legacy"
moNuxPWGrK96NQwHugF6NcYpoXJrXMouz8

参考

  1. list of address prefix

  2. 0.16 release note/ segwit-wallet

  3. 0.16 release note/ RPC changes

  4. rpcwallet.cpp

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?