From 21e1a4a881d8c6236b66411b47a1c1bfe5a9ecda Mon Sep 17 00:00:00 2001 From: mrbandrews Date: Fri, 9 Dec 2016 13:45:27 -0500 Subject: [PATCH] partial Merge #8456: [RPC] Simplified bumpfee command. It includes only this commit for sake of backporting HasWalletSpent [RPC] bumpfee This command allows a user to increase the fee on a wallet transaction T, creating a "bumper" transaction B. T must signal that it is BIP-125 replaceable. T's change output is decremented to pay the additional fee. (B will not add inputs to T.) T cannot have any descendant transactions. Once B bumps T, neither T nor B's outputs can be spent until either T or (more likely) B is mined. Includes code by @jonasschnelli and @ryanofsky --- src/wallet/wallet.cpp | 7 +++++++ src/wallet/wallet.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c42ffc6dd3..9d52273549 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -495,6 +495,13 @@ std::set CWallet::GetConflicts(const uint256& txid) const return result; } +bool CWallet::HasWalletSpend(const uint256& txid) const +{ + AssertLockHeld(cs_wallet); + auto iter = mapTxSpends.lower_bound(COutPoint(txid, 0)); + return (iter != mapTxSpends.end() && iter->first.hash == txid); +} + void CWallet::Flush() { GetDatabase().Flush(); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 55024c86c4..3db4953c20 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1190,6 +1190,9 @@ public: //! Get wallet transactions that conflict with given transaction (spend same outputs) std::set GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + //! Check if a given transaction has any of its outputs spent by another transaction in the wallet + bool HasWalletSpend(const uint256& txid) const; + //! Flush wallet (bitdb flush) void Flush();