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 @@ -1971,6 +1971,8 @@ RPCHelpMan listdescriptors()
1971
1971
throw JSONRPCError (RPC_WALLET_ERROR, " listdescriptors is not available for non-descriptor wallets" );
1972
1972
}
1973
1973
1974
+ EnsureWalletIsUnlocked (wallet.get ());
1975
+
1974
1976
LOCK (wallet->cs_wallet );
1975
1977
1976
1978
UniValue response (UniValue::VARR);
@@ -1983,7 +1985,11 @@ RPCHelpMan listdescriptors()
1983
1985
UniValue spk (UniValue::VOBJ);
1984
1986
LOCK (desc_spk_man->cs_desc_man );
1985
1987
const auto & wallet_descriptor = desc_spk_man->GetWalletDescriptor ();
1986
- spk.pushKV (" desc" , wallet_descriptor.descriptor ->ToString ());
1988
+ std::string descriptor;
1989
+ if (!desc_spk_man->GetDescriptorString (descriptor, false )) {
1990
+ throw JSONRPCError (RPC_WALLET_ERROR, " Can't get normalized descriptor string." );
1991
+ }
1992
+ spk.pushKV (" desc" , descriptor);
1987
1993
spk.pushKV (" timestamp" , wallet_descriptor.creation_time );
1988
1994
const bool active = active_spk_mans.count (desc_spk_man) != 0 ;
1989
1995
spk.pushKV (" active" , active);
Original file line number Diff line number Diff line change @@ -51,6 +51,22 @@ def run_test(self):
51
51
assert item ['range' ] == [0 , 0 ]
52
52
assert item ['timestamp' ] is not None
53
53
54
+ self .log .info ('Test descriptors with hardened derivations are listed in importable form.' )
55
+ xprv = 'tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg'
56
+ xpub_acc = 'tpubDCMVLhErorrAGfApiJSJzEKwqeaf2z3NrkVMxgYQjZLzMjXMBeRw2muGNYbvaekAE8rUFLftyEar4LdrG2wXyyTJQZ26zptmeTEjPTaATts'
57
+ hardened_path = '/84\' /1\' /0\' '
58
+ wallet = node .get_wallet_rpc ('w2' )
59
+ wallet .importdescriptors ([{
60
+ 'desc' : descsum_create ('pkh(' + xprv + hardened_path + '/0/*)' ),
61
+ 'timestamp' : 1296688602 ,
62
+ }])
63
+ expected = {'desc' : descsum_create ('pkh([80002067' + hardened_path + ']' + xpub_acc + '/0/*)' ),
64
+ 'timestamp' : 1296688602 ,
65
+ 'active' : False ,
66
+ 'range' : [0 , 0 ],
67
+ 'next' : 0 }
68
+ assert_equal ([expected ], wallet .listdescriptors ())
69
+
54
70
self .log .info ('Test non-active non-range combo descriptor' )
55
71
node .createwallet (wallet_name = 'w4' , blank = True , descriptors = True )
56
72
wallet = node .get_wallet_rpc ('w4' )
You can’t perform that action at this time.
0 commit comments