Skip to content

Commit

Permalink
[RPC] use fundrawtransactions feerate option for the bumpfee command
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Jun 8, 2016
1 parent 72812f7 commit 4bbf2cf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/wallet/rpcwallet.cpp
Expand Up @@ -2511,7 +2511,8 @@ UniValue bumpfee(const UniValue& params, bool fHelp)
// get the old fee to allow oldfee+newfee
CAmount nDebit = wtx.GetDebit(ISMINE_SPENDABLE);
CAmount nOldFee = -(wtx.IsFromMe(ISMINE_SPENDABLE) ? wtx.GetValueOut() - nDebit : 0);
CAmount nFee = nOldFee; //set the old fee as the base fee
CFeeRate oldFeeRate(nOldFee, (int)::GetSerializeSize(wtx, SER_NETWORK, PROTOCOL_VERSION));
CAmount nFee = 0;

CMutableTransaction tx(wtx);
// remove scriptSigs, the signatures are invalid after mutating the transaction
Expand All @@ -2532,9 +2533,12 @@ UniValue bumpfee(const UniValue& params, bool fHelp)
string strFailReason;
int nChangePos = -1;

// increase fee rate
CFeeRate newFeeRate = CFeeRate(oldFeeRate.GetFeePerK()*1.5);

// re-fund the transaction, a new change output will be added
CReserveKey reservekey(pwalletMain);
if(!pwalletMain->FundTransaction(tx, reservekey, nFee, false, CFeeRate(0), nChangePos, strFailReason, false, false))
if(!pwalletMain->FundTransaction(tx, reservekey, nFee, true, newFeeRate, nChangePos, strFailReason, false, false))
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason);

// sign the new transaction
Expand Down

0 comments on commit 4bbf2cf

Please sign in to comment.