mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Support descriptors with checksums in initpegoutwallet
This commit is contained in:
parent
280c33f865
commit
fdba8c45f9
3 changed files with 9 additions and 8 deletions
|
|
@ -464,13 +464,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
//TODO(stevenroose) remove if unused
|
||||
CScript P2PKHGetScript(const CPubKey& pubkey) { return GetScriptForDestination(PKHash(pubkey)); }
|
||||
CScript P2PKGetScript(const CPubKey& pubkey) { return GetScriptForRawPubKey(pubkey); }
|
||||
CScript P2WPKHGetScript(const CPubKey& pubkey) { return GetScriptForDestination(WitnessV0KeyHash(pubkey.GetID())); }
|
||||
CScript ConvertP2SH(const CScript& script) { return GetScriptForDestination(ScriptHash(script)); }
|
||||
CScript ConvertP2WSH(const CScript& script) { return GetScriptForDestination(WitnessV0ScriptHash(script)); }
|
||||
|
||||
/** Construct a vector with one element, which is moved into it. */
|
||||
template<typename T>
|
||||
std::vector<T> Singleton(T elem)
|
||||
|
|
|
|||
|
|
@ -4982,13 +4982,19 @@ UniValue initpegoutwallet(const JSONRPCRequest& request)
|
|||
}
|
||||
|
||||
FlatSigningProvider provider;
|
||||
auto desc = Parse(bitcoin_desc, provider);
|
||||
auto desc = Parse(bitcoin_desc, provider, false); // don't require checksum
|
||||
if (!desc) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "bitcoin_descriptor is not a valid descriptor string.");
|
||||
} else if (!desc->IsRange()) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "bitcoin_descriptor must be a ranged descriptor.");
|
||||
}
|
||||
|
||||
// For our manual pattern matching, we don't want the checksum part.
|
||||
auto checksum_char = bitcoin_desc.find('#');
|
||||
if (checksum_char != std::string::npos) {
|
||||
bitcoin_desc = bitcoin_desc.substr(0, checksum_char);
|
||||
}
|
||||
|
||||
// Three acceptable descriptors:
|
||||
if (bitcoin_desc.substr(0, 8) == "sh(wpkh("
|
||||
&& bitcoin_desc.substr(bitcoin_desc.size()-2, 2) == "))") {
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ class PAKTest (BitcoinTestFramework):
|
|||
|
||||
# Peg out with each new type, check that destination script matches
|
||||
wpkh_desc = "wpkh("+xpub+"/0/*)"
|
||||
# add a valid checksum
|
||||
wpkh_desc = self.nodes[1].getdescriptorinfo(wpkh_desc)["descriptor"]
|
||||
wpkh_info = self.nodes[1].initpegoutwallet(wpkh_desc)
|
||||
wpkh_pak_info = self.nodes[1].getwalletpakinfo()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue