Merge bitcoin/bitcoin#22021: rpc: bumpfee/psbtbumpfee fixes and updates

4f504f826b rpc: fix code comment for bumpfee/psbtbumpfee output (Jon Atack)
5cb7ac23fb rpc: fix docs for bumpfee psbt update (Jon Atack)

Pull request description:

  Follow-up to #21544 and #20891 for the `bumpfee_helper` used for RPCs bumpfee and psbtbumpfee:
  - "psbt" field is only returned in psbtbumpfee and not bumpfee
  - bumpfee raises if private keys are disabled, so the txid help "Only returned when wallet private keys are enabled." no longer makes sense; remove it
  - add missing space in RPC examples ("Bump the fee, get the new transaction'stxid")
  - update txid/psbt code comments

ACKs for top commit:
  klementtan:
    ACK [`4f504f8`](4f504f826b)

Tree-SHA512: 194faf8af52383eb8ac5cd22825265931bcde135dac79d8ecc4f84f698070da9b9373c00eef8623961881bb293157c7c9a0d71d1bcccf481ae3605a2d1444ed8
This commit is contained in:
MarcoFalke 2021-05-25 09:00:25 +02:00
commit db1aca01d5
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -3430,12 +3430,10 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
"options"},
},
RPCResult{
RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>(
{
{RPCResult::Type::STR, "psbt", "The base64-encoded unsigned PSBT of the new transaction."},
},
want_psbt ? std::vector<RPCResult>{} : std::vector<RPCResult>{{RPCResult::Type::STR_HEX, "txid", "The id of the new transaction. Only returned when wallet private keys are enabled."}}
),
RPCResult::Type::OBJ, "", "", Cat(
want_psbt ?
std::vector<RPCResult>{{RPCResult::Type::STR, "psbt", "The base64-encoded unsigned PSBT of the new transaction."}} :
std::vector<RPCResult>{{RPCResult::Type::STR_HEX, "txid", "The id of the new transaction."}},
{
{RPCResult::Type::STR_AMOUNT, "origfee", "The fee of the replaced transaction."},
{RPCResult::Type::STR_AMOUNT, "fee", "The fee of the new transaction."},
@ -3446,7 +3444,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
})
},
RPCExamples{
"\nBump the fee, get the new transaction\'s" + std::string(want_psbt ? "psbt" : "txid") + "\n" +
"\nBump the fee, get the new transaction\'s " + std::string(want_psbt ? "psbt" : "txid") + "\n" +
HelpExampleCli(method_name, "<txid>")
},
[want_psbt](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
@ -3528,8 +3526,8 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
UniValue result(UniValue::VOBJ);
// If wallet private keys are enabled, return the new transaction id,
// otherwise return the base64-encoded unsigned PSBT of the new transaction.
// For bumpfee, return the new transaction id.
// For psbtbumpfee, return the base64-encoded unsigned PSBT of the new transaction.
if (!want_psbt) {
if (!feebumper::SignTransaction(*pwallet, mtx)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Can't sign transaction.");