newaddr: support getting both bech32 and p2sh addresses.

Higher layers consume less addresses this way.

Fixes: #2390
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-03-04 13:43:20 +10:30
committed by Christian Decker
parent 5518c7cba8
commit 3e67c09d5e
5 changed files with 56 additions and 31 deletions

View File

@@ -1232,3 +1232,16 @@ def test_bad_onion(node_factory, bitcoind):
assert err.value.error['data']['failcode'] == WIRE_INVALID_ONION_HMAC
assert err.value.error['data']['erring_node'] == mangled_nodeid
assert err.value.error['data']['erring_channel'] == route[1]['channel']
def test_newaddr(node_factory):
l1 = node_factory.get_node()
p2sh = l1.rpc.newaddr('p2sh-segwit')
assert 'bech32' not in p2sh
assert p2sh['p2sh-segwit'].startswith('2')
bech32 = l1.rpc.newaddr('bech32')
assert 'p2sh-segwit' not in bech32
assert bech32['bech32'].startswith('bcrt1')
both = l1.rpc.newaddr('all')
assert both['p2sh-segwit'].startswith('2')
assert both['bech32'].startswith('bcrt1')