Browse Source

Improve CFeeBumper interface, add comments, make use of std::move

0.15
Jonas Schnelli 8 years ago
parent
commit
5f59d3ecb7
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
  1. 7
      src/wallet/feebumper.cpp
  2. 12
      src/wallet/feebumper.h
  3. 2
      src/wallet/rpcwallet.cpp

7
src/wallet/feebumper.cpp

@ -42,7 +42,7 @@ int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *pWal
CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConfirmTarget, bool specifiedConfirmTarget, CAmount totalFee, bool newTxReplaceable) CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConfirmTarget, bool specifiedConfirmTarget, CAmount totalFee, bool newTxReplaceable)
: :
txid(txidIn), txid(std::move(txidIn)),
nOldFee(0), nOldFee(0),
nNewFee(0) nNewFee(0)
{ {
@ -229,6 +229,11 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
currentResult = BumpFeeResult::OK; currentResult = BumpFeeResult::OK;
} }
bool CFeeBumper::signTransaction(CWallet *pWallet)
{
return pWallet->SignTransaction(mtx);
}
bool CFeeBumper::commit(CWallet *pWallet) bool CFeeBumper::commit(CWallet *pWallet)
{ {
AssertLockHeld(pWallet->cs_wallet); AssertLockHeld(pWallet->cs_wallet);

12
src/wallet/feebumper.h

@ -28,9 +28,19 @@ public:
const std::vector<std::string>& getErrors() const { return vErrors; } const std::vector<std::string>& getErrors() const { return vErrors; }
CAmount getOldFee() const { return nOldFee; } CAmount getOldFee() const { return nOldFee; }
CAmount getNewFee() const { return nNewFee; } CAmount getNewFee() const { return nNewFee; }
CMutableTransaction* getBumpedTxRef() { return &mtx; }
uint256 getBumpedTxId() const { return bumpedTxid; } uint256 getBumpedTxId() const { return bumpedTxid; }
/* signs the new transaction,
* returns false if the tx couldn't be found or if it was
* improssible to create the signature(s)
*/
bool signTransaction(CWallet *pWallet);
/* commits the fee bump,
* returns true, in case of CWallet::CommitTransaction was successful
* but, eventually sets vErrors if the tx could not be added to the mempool (will try later)
* or if the old transaction could not be marked as replaced
*/
bool commit(CWallet *pWalletNonConst); bool commit(CWallet *pWalletNonConst);
private: private:

2
src/wallet/rpcwallet.cpp

@ -2895,7 +2895,7 @@ UniValue bumpfee(const JSONRPCRequest& request)
} }
// sign bumped transaction // sign bumped transaction
if (!pwallet->SignTransaction(*feeBump.getBumpedTxRef())) { if (!feeBump.signTransaction(pwallet)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Can't sign transaction."); throw JSONRPCError(RPC_WALLET_ERROR, "Can't sign transaction.");
} }
// commit the bumped transaction // commit the bumped transaction

Loading…
Cancel
Save