@@ -3365,10 +3365,11 @@ static UniValue bumpfee(const JSONRPCRequest& request)
3365
3365
},
3366
3366
RPCResult{
3367
3367
" {\n "
3368
- " \" txid\" : \" value\" , (string) The id of the new transaction\n "
3369
- " \" origfee\" : n, (numeric) Fee of the replaced transaction\n "
3370
- " \" fee\" : n, (numeric) Fee of the new transaction\n "
3371
- " \" errors\" : [ str... ] (json array of strings) Errors encountered during processing (may be empty)\n "
3368
+ " \" psbt\" : \" psbt\" , (string) The base64-encoded unsigned PSBT of the new transaction. Only returned when wallet private keys are disabled.\n "
3369
+ " \" txid\" : \" value\" , (string) The id of the new transaction. Only returned when wallet private keys are enabled.\n "
3370
+ " \" origfee\" : n, (numeric) The fee of the replaced transaction.\n "
3371
+ " \" fee\" : n, (numeric) The fee of the new transaction.\n "
3372
+ " \" errors\" : [ str... ] (json array of strings) Errors encountered during processing (may be empty).\n "
3372
3373
" }\n "
3373
3374
},
3374
3375
RPCExamples{
@@ -3470,17 +3471,32 @@ static UniValue bumpfee(const JSONRPCRequest& request)
3470
3471
}
3471
3472
}
3472
3473
3473
- // sign bumped transaction
3474
- if (!feebumper::SignTransaction (*pwallet, mtx)) {
3475
- throw JSONRPCError (RPC_WALLET_ERROR, " Can't sign transaction." );
3476
- }
3477
- // commit the bumped transaction
3478
- uint256 txid;
3479
- if (feebumper::CommitTransaction (*pwallet, hash, std::move (mtx), errors, txid) != feebumper::Result::OK) {
3480
- throw JSONRPCError (RPC_WALLET_ERROR, errors[0 ]);
3481
- }
3482
3474
UniValue result (UniValue::VOBJ);
3483
- result.pushKV (" txid" , txid.GetHex ());
3475
+
3476
+ // If wallet private keys are enabled, return the new transaction id,
3477
+ // otherwise return the base64-encoded unsigned PSBT of the new transaction.
3478
+ if (!pwallet->IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
3479
+ if (!feebumper::SignTransaction (*pwallet, mtx)) {
3480
+ throw JSONRPCError (RPC_WALLET_ERROR, " Can't sign transaction." );
3481
+ }
3482
+
3483
+ uint256 txid;
3484
+ if (feebumper::CommitTransaction (*pwallet, hash, std::move (mtx), errors, txid) != feebumper::Result::OK) {
3485
+ throw JSONRPCError (RPC_WALLET_ERROR, errors[0 ]);
3486
+ }
3487
+
3488
+ result.pushKV (" txid" , txid.GetHex ());
3489
+ } else {
3490
+ PartiallySignedTransaction psbtx (mtx);
3491
+ bool complete = false ;
3492
+ const TransactionError err = FillPSBT (pwallet, psbtx, complete, SIGHASH_ALL, false /* sign */ , true /* bip32derivs */ );
3493
+ CHECK_NONFATAL (err == TransactionError::OK);
3494
+ CHECK_NONFATAL (!complete);
3495
+ CDataStream ssTx (SER_NETWORK, PROTOCOL_VERSION);
3496
+ ssTx << psbtx;
3497
+ result.pushKV (" psbt" , EncodeBase64 (ssTx.str ()));
3498
+ }
3499
+
3484
3500
result.pushKV (" origfee" , ValueFromAmount (old_fee));
3485
3501
result.pushKV (" fee" , ValueFromAmount (new_fee));
3486
3502
UniValue result_errors (UniValue::VARR);
0 commit comments