Skip to content

Commit 6668e21

Browse files
MarcoFalkeknst
authored andcommitted
Merge bitcoin#18974: test: Check that invalid witness destinations can not be imported
facede1 test: Check that invalid witness destinations can not be imported (MarcoFalke) Pull request description: ACKs for top commit: practicalswift: ACK facede1 -- thanks for adding! Tree-SHA512: 87000606fac2e6f2780ca75cdeeb2dc1f0528d9b8f13e4156e8304ce7a6b1eb014781b6f0c59d11544bf360ba3dc5f99549470b0876132e189b9107f2c6bb38d
1 parent b2258ab commit 6668e21

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
@@ -137,6 +137,33 @@ def run_test(self):
137137
# in the label. This is a no-op.
138138
change_label(node, labels[2].addresses[0], labels[2], labels[2])
139139

140+
self.log.info('Check watchonly labels')
141+
node.createwallet(wallet_name='watch_only', disable_private_keys=True, descriptors=False)
142+
wallet_watch_only = node.get_wallet_rpc('watch_only')
143+
VALID = {
144+
'✔️_a1': 'yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4',
145+
'✔️_a2': 'yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3',
146+
'✔️_a3': '93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB',
147+
}
148+
INVALID = {
149+
'❌_b1': 'y000000000000000000000000000000000',
150+
'❌_b2': 'y000000000000000000000000000000001',
151+
}
152+
for l in VALID:
153+
ad = VALID[l]
154+
wallet_watch_only.importaddress(label=l, rescan=False, address=ad)
155+
node.generatetoaddress(1, ad)
156+
assert_equal(wallet_watch_only.getaddressesbylabel(label=l), {ad: {'purpose': 'receive'}})
157+
assert_equal(wallet_watch_only.getreceivedbylabel(label=l), 0)
158+
for l in INVALID:
159+
ad = INVALID[l]
160+
assert_raises_rpc_error(
161+
-5,
162+
"Invalid Dash address or script",
163+
lambda: wallet_watch_only.importaddress(label=l, rescan=False, address=ad),
164+
)
165+
166+
140167
class Label:
141168
def __init__(self, name):
142169
# Label name

0 commit comments

Comments
 (0)