test: Check that invalid witness destinations can not be imported

pull/764/head
MarcoFalke 5 years ago
parent a9a6d946e4
commit facede18a4
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -134,6 +134,33 @@ class WalletLabelsTest(BitcoinTestFramework):
# in the label. This is a no-op.
change_label(node, labels[2].addresses[0], labels[2], labels[2])
self.log.info('Check watchonly labels')
node.createwallet(wallet_name='watch_only', disable_private_keys=True, descriptors=False)
wallet_watch_only = node.get_wallet_rpc('watch_only')
BECH32_VALID = {
'_VER15_PROG40': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqn2cjv3',
'_VER16_PROG03': 'bcrt1sqqqqqjq8pdp',
'_VER16_PROB02': 'bcrt1sqqqqqjq8pv',
}
BECH32_INVALID = {
'❌_VER15_PROG41': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzc7xyq',
'❌_VER16_PROB01': 'bcrt1sqqpl9r5c',
}
for l in BECH32_VALID:
ad = BECH32_VALID[l]
wallet_watch_only.importaddress(label=l, rescan=False, address=ad)
node.generatetoaddress(1, ad)
assert_equal(wallet_watch_only.getaddressesbylabel(label=l), {ad: {'purpose': 'receive'}})
assert_equal(wallet_watch_only.getreceivedbylabel(label=l), 0)
for l in BECH32_INVALID:
ad = BECH32_INVALID[l]
assert_raises_rpc_error(
-5,
"Invalid Bitcoin address or script",
lambda: wallet_watch_only.importaddress(label=l, rescan=False, address=ad),
)
class Label:
def __init__(self, name):
# Label name

Loading…
Cancel
Save