keep-network / local-setup

Allow to easily set up tBTC and Keep locally for development and test purposes.
MIT License
8 stars 16 forks source link

bitcoind-wallet: Let to select address type for getNewAddress #95

Closed nkuba closed 3 years ago

nkuba commented 3 years ago

bitcoind-rpc API allows selection of the address type to generate. Options are: legacy, p2sh-segwit, and bech32. Default is bech32. Here we enhance CLI command to let the user select the address type.

Ref: https://developer.bitcoin.org/reference/rpc/getnewaddress.html

beaurancourt commented 3 years ago

I ran the command twice for each argument variant (to make sure they returned different addresses each time). Looks like it works!

❯ btcw getNewAddress bech32
bcrt1qhwdrqqlnljt6pe07scrq5us3dpnnpyppqz6xkc

❯ btcw getNewAddress legacy
n13QMNEgpsmzXujwroP4BHRW8LLk5N4vvv

❯ btcw getNewAddress legacy
msakDVkFzPpiVRM5eCoEJqhc872BXoZ5p9

❯ btcw getNewAddress p2sh-segwit
2MvkZBW6LvZ98iwCRfMMeau3Ep9vtvKgd2J

❯ btcw getNewAddress p2sh-segwit
2N7tkmZ23PWrjTEsnkAvmiHJYEqqT6GrskS

❯ btcw getNewAddress            
bcrt1qf8td8z20x5dwnvpfnxdmk7s2nlazn2tcvcfglk

❯ btcw getNewAddress
bcrt1qz6xc25hls2mzy33cjdjp7xas3sd8c2aq8fatut

(where btcw is aliased to bitcoind-wallet/bin/cli.js)