@@ -99,6 +99,8 @@ def test_address(self, node, address, multisig, typ):
99
99
"""Run sanity checks on an address."""
100
100
info = self .nodes [node ].getaddressinfo (address )
101
101
assert (self .nodes [node ].validateaddress (address )['isvalid' ])
102
+ assert_equal (info .get ('solvable' ), True )
103
+
102
104
if not multisig and typ == 'legacy' :
103
105
# P2PKH
104
106
assert (not info ['isscript' ])
@@ -146,6 +148,47 @@ def test_address(self, node, address, multisig, typ):
146
148
# Unknown type
147
149
assert (False )
148
150
151
+ def test_desc (self , node , address , multisig , typ , utxo ):
152
+ """Run sanity checks on a descriptor reported by getaddressinfo."""
153
+ info = self .nodes [node ].getaddressinfo (address )
154
+ assert ('desc' in info )
155
+ assert_equal (info ['desc' ], utxo ['desc' ])
156
+ assert (self .nodes [node ].validateaddress (address )['isvalid' ])
157
+
158
+ # Use a ridiculously roundabout way to find the key origin info through
159
+ # the PSBT logic. However, this does test consistency between the PSBT reported
160
+ # fingerprints/paths and the descriptor logic.
161
+ psbt = self .nodes [node ].createpsbt ([{'txid' :utxo ['txid' ], 'vout' :utxo ['vout' ]}],[{address :0.00010000 }])
162
+ psbt = self .nodes [node ].walletprocesspsbt (psbt , False , "ALL" , True )
163
+ decode = self .nodes [node ].decodepsbt (psbt ['psbt' ])
164
+ key_descs = {}
165
+ for deriv in decode ['inputs' ][0 ]['bip32_derivs' ]:
166
+ assert_equal (len (deriv ['master_fingerprint' ]), 8 )
167
+ assert_equal (deriv ['path' ][0 ], 'm' )
168
+ key_descs [deriv ['pubkey' ]] = '[' + deriv ['master_fingerprint' ] + deriv ['path' ][1 :] + ']' + deriv ['pubkey' ]
169
+
170
+ if not multisig and typ == 'legacy' :
171
+ # P2PKH
172
+ assert_equal (info ['desc' ], "pkh(%s)" % key_descs [info ['pubkey' ]])
173
+ elif not multisig and typ == 'p2sh-segwit' :
174
+ # P2SH-P2WPKH
175
+ assert_equal (info ['desc' ], "sh(wpkh(%s))" % key_descs [info ['pubkey' ]])
176
+ elif not multisig and typ == 'bech32' :
177
+ # P2WPKH
178
+ assert_equal (info ['desc' ], "wpkh(%s)" % key_descs [info ['pubkey' ]])
179
+ elif typ == 'legacy' :
180
+ # P2SH-multisig
181
+ assert_equal (info ['desc' ], "sh(multi(2,%s,%s))" % (key_descs [info ['pubkeys' ][0 ]], key_descs [info ['pubkeys' ][1 ]]))
182
+ elif typ == 'p2sh-segwit' :
183
+ # P2SH-P2WSH-multisig
184
+ assert_equal (info ['desc' ], "sh(wsh(multi(2,%s,%s)))" % (key_descs [info ['embedded' ]['pubkeys' ][0 ]], key_descs [info ['embedded' ]['pubkeys' ][1 ]]))
185
+ elif typ == 'bech32' :
186
+ # P2WSH-multisig
187
+ assert_equal (info ['desc' ], "wsh(multi(2,%s,%s))" % (key_descs [info ['pubkeys' ][0 ]], key_descs [info ['pubkeys' ][1 ]]))
188
+ else :
189
+ # Unknown type
190
+ assert (False )
191
+
149
192
def test_change_output_type (self , node_sender , destinations , expected_type ):
150
193
txid = self .nodes [node_sender ].sendmany (dummy = "" , amounts = dict .fromkeys (destinations , 0.001 ))
151
194
raw_tx = self .nodes [node_sender ].getrawtransaction (txid )
@@ -198,6 +241,7 @@ def run_test(self):
198
241
self .log .debug ("Old balances are {}" .format (old_balances ))
199
242
to_send = (old_balances [from_node ] / 101 ).quantize (Decimal ("0.00000001" ))
200
243
sends = {}
244
+ addresses = {}
201
245
202
246
self .log .debug ("Prepare sends" )
203
247
for n , to_node in enumerate (range (from_node , from_node + 4 )):
@@ -228,6 +272,7 @@ def run_test(self):
228
272
229
273
# Output entry
230
274
sends [address ] = to_send * 10 * (1 + n )
275
+ addresses [to_node ] = (address , typ )
231
276
232
277
self .log .debug ("Sending: {}" .format (sends ))
233
278
self .nodes [from_node ].sendmany ("" , sends )
@@ -244,6 +289,17 @@ def run_test(self):
244
289
self .nodes [5 ].generate (1 )
245
290
sync_blocks (self .nodes )
246
291
292
+ # Verify that the receiving wallet contains a UTXO with the expected address, and expected descriptor
293
+ for n , to_node in enumerate (range (from_node , from_node + 4 )):
294
+ to_node %= 4
295
+ found = False
296
+ for utxo in self .nodes [to_node ].listunspent ():
297
+ if utxo ['address' ] == addresses [to_node ][0 ]:
298
+ found = True
299
+ self .test_desc (to_node , addresses [to_node ][0 ], multisig , addresses [to_node ][1 ], utxo )
300
+ break
301
+ assert found
302
+
247
303
new_balances = self .get_balances ()
248
304
self .log .debug ("Check new balances: {}" .format (new_balances ))
249
305
# We don't know what fee was set, so we can only check bounds on the balance of the sending node
0 commit comments