mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Support descriptors with checksums in initpegoutwallet
This commit is contained in:
parent
f98b4ee657
commit
19c477edea
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. */
|
/** Construct a vector with one element, which is moved into it. */
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::vector<T> Singleton(T elem)
|
std::vector<T> Singleton(T elem)
|
||||||
|
|
|
||||||
|
|
@ -4977,13 +4977,19 @@ UniValue initpegoutwallet(const JSONRPCRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatSigningProvider provider;
|
FlatSigningProvider provider;
|
||||||
auto desc = Parse(bitcoin_desc, provider);
|
auto desc = Parse(bitcoin_desc, provider, false); // don't require checksum
|
||||||
if (!desc) {
|
if (!desc) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "bitcoin_descriptor is not a valid descriptor string.");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "bitcoin_descriptor is not a valid descriptor string.");
|
||||||
} else if (!desc->IsRange()) {
|
} else if (!desc->IsRange()) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "bitcoin_descriptor must be a ranged descriptor.");
|
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:
|
// Three acceptable descriptors:
|
||||||
if (bitcoin_desc.substr(0, 8) == "sh(wpkh("
|
if (bitcoin_desc.substr(0, 8) == "sh(wpkh("
|
||||||
&& bitcoin_desc.substr(bitcoin_desc.size()-2, 2) == "))") {
|
&& 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
|
# Peg out with each new type, check that destination script matches
|
||||||
wpkh_desc = "wpkh("+xpub+"/0/*)"
|
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_info = self.nodes[1].initpegoutwallet(wpkh_desc)
|
||||||
wpkh_pak_info = self.nodes[1].getwalletpakinfo()
|
wpkh_pak_info = self.nodes[1].getwalletpakinfo()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue