1 // Copyright (c) 2017-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_WALLET_FEEBUMPER_H
6 #define BITCOIN_WALLET_FEEBUMPER_H
7 
8 #include <primitives/transaction.h>
9 
10 class CWallet;
11 class CWalletTx;
12 class uint256;
13 class CCoinControl;
14 enum class FeeEstimateMode;
15 struct bilingual_str;
16 
17 namespace feebumper {
18 
19 enum class Result
20 {
21     OK,
22     INVALID_ADDRESS_OR_KEY,
23     INVALID_REQUEST,
24     INVALID_PARAMETER,
25     WALLET_ERROR,
26     MISC_ERROR,
27 };
28 
29 //! Return whether transaction can be bumped.
30 bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid);
31 
32 //! Create bumpfee transaction based on feerate estimates.
33 Result CreateRateBumpTransaction(CWallet& wallet,
34     const uint256& txid,
35     const CCoinControl& coin_control,
36     std::vector<bilingual_str>& errors,
37     CAmount& old_fee,
38     CAmount& new_fee,
39     CMutableTransaction& mtx);
40 
41 //! Sign the new transaction,
42 //! @return false if the tx couldn't be found or if it was
43 //! impossible to create the signature(s)
44 bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx);
45 
46 //! Commit the bumpfee transaction.
47 //! @return success in case of CWallet::CommitTransaction was successful,
48 //! but sets errors if the tx could not be added to the mempool (will try later)
49 //! or if the old transaction could not be marked as replaced.
50 Result CommitTransaction(CWallet& wallet,
51     const uint256& txid,
52     CMutableTransaction&& mtx,
53     std::vector<bilingual_str>& errors,
54     uint256& bumped_txid);
55 
56 } // namespace feebumper
57 
58 #endif // BITCOIN_WALLET_FEEBUMPER_H
59