File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1775,6 +1775,8 @@ RPCHelpMan listdescriptors()
1775
1775
throw JSONRPCError (RPC_WALLET_ERROR, " listdescriptors is not available for non-descriptor wallets" );
1776
1776
}
1777
1777
1778
+ EnsureWalletIsUnlocked (wallet.get ());
1779
+
1778
1780
LOCK (wallet->cs_wallet );
1779
1781
1780
1782
UniValue response (UniValue::VARR);
@@ -1787,7 +1789,11 @@ RPCHelpMan listdescriptors()
1787
1789
UniValue spk (UniValue::VOBJ);
1788
1790
LOCK (desc_spk_man->cs_desc_man );
1789
1791
const auto & wallet_descriptor = desc_spk_man->GetWalletDescriptor ();
1790
- spk.pushKV (" desc" , wallet_descriptor.descriptor ->ToString ());
1792
+ std::string descriptor;
1793
+ if (!desc_spk_man->GetDescriptorString (descriptor, false )) {
1794
+ throw JSONRPCError (RPC_WALLET_ERROR, " Can't get normalized descriptor string." );
1795
+ }
1796
+ spk.pushKV (" desc" , descriptor);
1791
1797
spk.pushKV (" timestamp" , wallet_descriptor.creation_time );
1792
1798
const bool active = active_spk_mans.count (desc_spk_man) != 0 ;
1793
1799
spk.pushKV (" active" , active);
Original file line number Diff line number Diff line change @@ -50,6 +50,22 @@ def run_test(self):
50
50
assert item ['range' ] == [0 , 0 ]
51
51
assert item ['timestamp' ] is not None
52
52
53
+ self .log .info ('Test descriptors with hardened derivations are listed in importable form.' )
54
+ xprv = 'tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg'
55
+ xpub_acc = 'tpubDCMVLhErorrAGfApiJSJzEKwqeaf2z3NrkVMxgYQjZLzMjXMBeRw2muGNYbvaekAE8rUFLftyEar4LdrG2wXyyTJQZ26zptmeTEjPTaATts'
56
+ hardened_path = '/84\' /1\' /0\' '
57
+ wallet = node .get_wallet_rpc ('w2' )
58
+ wallet .importdescriptors ([{
59
+ 'desc' : descsum_create ('wpkh(' + xprv + hardened_path + '/0/*)' ),
60
+ 'timestamp' : 1296688602 ,
61
+ }])
62
+ expected = {'desc' : descsum_create ('wpkh([80002067' + hardened_path + ']' + xpub_acc + '/0/*)' ),
63
+ 'timestamp' : 1296688602 ,
64
+ 'active' : False ,
65
+ 'range' : [0 , 0 ],
66
+ 'next' : 0 }
67
+ assert_equal ([expected ], wallet .listdescriptors ())
68
+
53
69
self .log .info ('Test non-active non-range combo descriptor' )
54
70
node .createwallet (wallet_name = 'w4' , blank = True , descriptors = True )
55
71
wallet = node .get_wallet_rpc ('w4' )
You can’t perform that action at this time.
0 commit comments