Skip to content

Commit facede1

Browse files
author
MarcoFalke
committed
test: Check that invalid witness destinations can not be imported
1 parent a9a6d94 commit facede1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/functional/wallet_labels.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,33 @@ def run_test(self):
134134
# in the label. This is a no-op.
135135
change_label(node, labels[2].addresses[0], labels[2], labels[2])
136136

137+
self.log.info('Check watchonly labels')
138+
node.createwallet(wallet_name='watch_only', disable_private_keys=True, descriptors=False)
139+
wallet_watch_only = node.get_wallet_rpc('watch_only')
140+
BECH32_VALID = {
141+
'✔️_VER15_PROG40': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqn2cjv3',
142+
'✔️_VER16_PROG03': 'bcrt1sqqqqqjq8pdp',
143+
'✔️_VER16_PROB02': 'bcrt1sqqqqqjq8pv',
144+
}
145+
BECH32_INVALID = {
146+
'❌_VER15_PROG41': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzc7xyq',
147+
'❌_VER16_PROB01': 'bcrt1sqqpl9r5c',
148+
}
149+
for l in BECH32_VALID:
150+
ad = BECH32_VALID[l]
151+
wallet_watch_only.importaddress(label=l, rescan=False, address=ad)
152+
node.generatetoaddress(1, ad)
153+
assert_equal(wallet_watch_only.getaddressesbylabel(label=l), {ad: {'purpose': 'receive'}})
154+
assert_equal(wallet_watch_only.getreceivedbylabel(label=l), 0)
155+
for l in BECH32_INVALID:
156+
ad = BECH32_INVALID[l]
157+
assert_raises_rpc_error(
158+
-5,
159+
"Invalid Bitcoin address or script",
160+
lambda: wallet_watch_only.importaddress(label=l, rescan=False, address=ad),
161+
)
162+
163+
137164
class Label:
138165
def __init__(self, name):
139166
# Label name

0 commit comments

Comments
 (0)