aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/feebumper.h
blob: 7e36a9766be7ef50a7009c83d2016119306079be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_WALLET_FEEBUMPER_H
#define BITCOIN_WALLET_FEEBUMPER_H

#include <primitives/transaction.h>

class CWallet;
class CWalletTx;
class uint256;
class CCoinControl;
enum class FeeEstimateMode;

namespace feebumper {

enum class Result
{
    OK,
    INVALID_ADDRESS_OR_KEY,
    INVALID_REQUEST,
    INVALID_PARAMETER,
    WALLET_ERROR,
    MISC_ERROR,
};

//! Return whether transaction can be bumped.
bool TransactionCanBeBumped(const CWallet* wallet, const uint256& txid);

//! Create bumpfee transaction.
Result CreateTransaction(const CWallet* wallet,
                         const uint256& txid,
                         const CCoinControl& coin_control,
                         CAmount total_fee,
                         std::vector<std::string>& errors,
                         CAmount& old_fee,
                         CAmount& new_fee,
                         CMutableTransaction& mtx);

//! Sign the new transaction,
//! @return false if the tx couldn't be found or if it was
//! impossible to create the signature(s)
bool SignTransaction(CWallet* wallet, CMutableTransaction& mtx);

//! Commit the bumpfee transaction.
//! @return success in case of CWallet::CommitTransaction was successful,
//! but sets errors if the tx could not be added to the mempool (will try later)
//! or if the old transaction could not be marked as replaced.
Result CommitTransaction(CWallet* wallet,
                         const uint256& txid,
                         CMutableTransaction&& mtx,
                         std::vector<std::string>& errors,
                         uint256& bumped_txid);

} // namespace feebumper

#endif // BITCOIN_WALLET_FEEBUMPER_H