mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
Accumulate result UniValue in SignTransaction
SignTransaction will be called multiple times in the future. Pass it a result UniValue so that it can accumulate the results of multiple SignTransaction passes.
This commit is contained in:
parent
bc38bb9a60
commit
4b0c718f8f
@ -763,7 +763,9 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
|
||||
// Parse the prevtxs array
|
||||
ParsePrevouts(request.params[2], &keystore, coins);
|
||||
|
||||
return SignTransaction(mtx, &keystore, coins, request.params[3]);
|
||||
UniValue result(UniValue::VOBJ);
|
||||
SignTransaction(mtx, &keystore, coins, request.params[3], result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
|
@ -268,7 +268,7 @@ void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keyst
|
||||
}
|
||||
}
|
||||
|
||||
UniValue SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType)
|
||||
void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType, UniValue& result)
|
||||
{
|
||||
int nHashType = ParseSighashString(hashType);
|
||||
|
||||
@ -319,12 +319,12 @@ UniValue SignTransaction(CMutableTransaction& mtx, const SigningProvider* keysto
|
||||
}
|
||||
bool fComplete = vErrors.empty();
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.pushKV("hex", EncodeHexTx(CTransaction(mtx)));
|
||||
result.pushKV("complete", fComplete);
|
||||
if (!vErrors.empty()) {
|
||||
if (result.exists("errors")) {
|
||||
vErrors.push_backV(result["errors"].getValues());
|
||||
}
|
||||
result.pushKV("errors", vErrors);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ class SigningProvider;
|
||||
* @param keystore Temporary keystore containing signing keys
|
||||
* @param coins Map of unspent outputs
|
||||
* @param hashType The signature hash type
|
||||
* @returns JSON object with details of signed transaction
|
||||
* @param result JSON object where signed transaction results accumulate
|
||||
*/
|
||||
UniValue SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType);
|
||||
void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType, UniValue& result);
|
||||
|
||||
/**
|
||||
* Parse a prevtxs UniValue array and get the map of coins from it
|
||||
|
@ -3281,7 +3281,9 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
|
||||
// Parse the prevtxs array
|
||||
ParsePrevouts(request.params[1], nullptr, coins);
|
||||
|
||||
return SignTransaction(mtx, &*pwallet->GetLegacyScriptPubKeyMan(), coins, request.params[2]);
|
||||
UniValue result(UniValue::VOBJ);
|
||||
SignTransaction(mtx, &*pwallet->GetLegacyScriptPubKeyMan(), coins, request.params[2], result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static UniValue bumpfee(const JSONRPCRequest& request)
|
||||
|
Loading…
Reference in New Issue
Block a user