mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
rpc: bugfix, incorrect segwit redeem script size used in signrawtransactionwithkey
The process currently fails to sign redeem scripts that are longer than 520 bytes. Even when it shouldn't. The 520 bytes redeem scripts limit is a legacy p2sh rule, and not a segwit limitation. Segwit redeem scripts are not restricted by the script item size limit. The reason why this occurs, is the usage of the same keystore used by the legacy spkm. Which contains blockage for any redeem scripts longer than the script item size limit.
This commit is contained in:
@@ -785,7 +785,7 @@ static RPCHelpMan signrawtransactionwithkey()
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
|
||||
}
|
||||
|
||||
FillableSigningProvider keystore;
|
||||
FlatSigningProvider keystore;
|
||||
const UniValue& keys = request.params[1].get_array();
|
||||
for (unsigned int idx = 0; idx < keys.size(); ++idx) {
|
||||
UniValue k = keys[idx];
|
||||
@@ -793,7 +793,11 @@ static RPCHelpMan signrawtransactionwithkey()
|
||||
if (!key.IsValid()) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
|
||||
}
|
||||
keystore.AddKey(key);
|
||||
|
||||
CPubKey pubkey = key.GetPubKey();
|
||||
CKeyID key_id = pubkey.GetID();
|
||||
keystore.pubkeys.emplace(key_id, pubkey);
|
||||
keystore.keys.emplace(key_id, key);
|
||||
}
|
||||
|
||||
// Fetch previous transactions (inputs):
|
||||
|
||||
Reference in New Issue
Block a user