Skip to content

Commit ee8b847

Browse files
committed
address_to_scriptpubkey: correctly handle WALLY_NETWORK_BITCOIN_REGTEST
Account for regtest using the same (non-segwit) address prefix as testnet.
1 parent 45a7bed commit ee8b847

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/address.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ int wally_address_to_scriptpubkey(const char *addr, uint32_t network, unsigned c
139139
version = decoded[0];
140140
if (network_from_addr_version(version, &addr_network) != WALLY_OK)
141141
return WALLY_EINVAL;
142+
if (network == WALLY_NETWORK_BITCOIN_REGTEST)
143+
network = WALLY_NETWORK_BITCOIN_TESTNET; /* regtest uses testnet prefix */
142144
if (network != addr_network)
143145
return WALLY_EINVAL;
144146

src/test/test_address.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
NETWORK_BITCOIN_MAINNET = 0x01
1919
NETWORK_BITCOIN_TESTNET = 0x02
20+
NETWORK_BITCOIN_REGTEST = 0xff
2021
NETWORK_LIQUID_MAINNET = 0x03
2122
NETWORK_LIQUID_REGTEST = 0x04
2223
NETWORK_LIQUID_TESTNET = 0x05
@@ -96,6 +97,7 @@ def get_test_key(self, vec, path):
9697
def test_address_vectors(self):
9798
self.do_test_vector(vec, 'm/0H/1', NETWORK_BITCOIN_MAINNET)
9899
self.do_test_vector(vec, 'm/1H/1', NETWORK_BITCOIN_TESTNET) # Testnet
100+
self.do_test_vector(vec, 'm/1H/1', NETWORK_BITCOIN_REGTEST) # Testnet
99101

100102
def do_test_vector(self, vec, path, network):
101103
key = self.get_test_key(vec, path)

0 commit comments

Comments
 (0)