mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Create wallet RPCs for PSBT
walletprocesspsbt takes a PSBT format transaction, updates the PSBT with any inputs related to this wallet, signs, and finalizes the transaction. There is also an option to not sign and just update. walletcreatefundedpsbt creates a PSBT from user provided data in the same form as createrawtransaction. It also funds the transaction and takes an options argument in the same form as fundrawtransaction. The resulting PSBT is blank with no input or output data filled in.
This commit is contained in:
@@ -197,3 +197,26 @@ std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strN
|
||||
throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
|
||||
return ParseHex(strHex);
|
||||
}
|
||||
|
||||
int ParseSighashString(const UniValue& sighash)
|
||||
{
|
||||
int hash_type = SIGHASH_ALL;
|
||||
if (!sighash.isNull()) {
|
||||
static std::map<std::string, int> map_sighash_values = {
|
||||
{std::string("ALL"), int(SIGHASH_ALL)},
|
||||
{std::string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)},
|
||||
{std::string("NONE"), int(SIGHASH_NONE)},
|
||||
{std::string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)},
|
||||
{std::string("SINGLE"), int(SIGHASH_SINGLE)},
|
||||
{std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)},
|
||||
};
|
||||
std::string strHashType = sighash.get_str();
|
||||
const auto& it = map_sighash_values.find(strHashType);
|
||||
if (it != map_sighash_values.end()) {
|
||||
hash_type = it->second;
|
||||
} else {
|
||||
throw std::runtime_error(strHashType + " is not a valid sighash parameter.");
|
||||
}
|
||||
}
|
||||
return hash_type;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user