2017-03-03 16:15:47 +01:00
|
|
|
// 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;
|
2017-05-11 09:34:39 +02:00
|
|
|
class CWalletTx;
|
2017-03-03 16:15:47 +01:00
|
|
|
class uint256;
|
2017-06-28 23:23:46 +02:00
|
|
|
class CCoinControl;
|
2017-06-14 21:15:40 +02:00
|
|
|
enum class FeeEstimateMode;
|
2017-03-03 16:15:47 +01:00
|
|
|
|
|
|
|
enum class BumpFeeResult
|
|
|
|
{
|
|
|
|
OK,
|
|
|
|
INVALID_ADDRESS_OR_KEY,
|
|
|
|
INVALID_REQUEST,
|
|
|
|
INVALID_PARAMETER,
|
|
|
|
WALLET_ERROR,
|
|
|
|
MISC_ERROR,
|
|
|
|
};
|
|
|
|
|
2017-09-20 22:04:05 +02:00
|
|
|
class FeeBumper
|
2017-03-03 16:15:47 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-09-20 22:04:05 +02:00
|
|
|
FeeBumper(const CWallet *wallet, const uint256 txid_in, const CCoinControl& coin_control, CAmount total_fee);
|
|
|
|
BumpFeeResult getResult() const { return current_result; }
|
|
|
|
const std::vector<std::string>& getErrors() const { return errors; }
|
|
|
|
CAmount getOldFee() const { return old_fee; }
|
|
|
|
CAmount getNewFee() const { return new_fee; }
|
|
|
|
uint256 getBumpedTxId() const { return bumped_txid; }
|
2017-03-03 16:15:47 +01:00
|
|
|
|
2017-03-30 09:26:21 +02:00
|
|
|
/* signs the new transaction,
|
|
|
|
* returns false if the tx couldn't be found or if it was
|
2017-04-07 18:29:54 +02:00
|
|
|
* impossible to create the signature(s)
|
2017-03-30 09:26:21 +02:00
|
|
|
*/
|
2017-09-20 22:04:05 +02:00
|
|
|
bool signTransaction(CWallet *wallet);
|
2017-03-30 09:26:21 +02:00
|
|
|
|
|
|
|
/* commits the fee bump,
|
|
|
|
* returns true, in case of CWallet::CommitTransaction was successful
|
2017-09-20 22:04:05 +02:00
|
|
|
* but, eventually sets errors if the tx could not be added to the mempool (will try later)
|
2017-03-30 09:26:21 +02:00
|
|
|
* or if the old transaction could not be marked as replaced
|
|
|
|
*/
|
2017-09-20 22:04:05 +02:00
|
|
|
bool commit(CWallet *wallet);
|
2017-03-03 16:15:47 +01:00
|
|
|
|
|
|
|
private:
|
2017-09-20 22:04:05 +02:00
|
|
|
bool preconditionChecks(const CWallet *wallet, const CWalletTx& wtx);
|
2017-05-11 09:34:39 +02:00
|
|
|
|
2017-03-03 16:15:47 +01:00
|
|
|
const uint256 txid;
|
2017-09-20 22:04:05 +02:00
|
|
|
uint256 bumped_txid;
|
2017-03-03 16:15:47 +01:00
|
|
|
CMutableTransaction mtx;
|
2017-09-20 22:04:05 +02:00
|
|
|
std::vector<std::string> errors;
|
|
|
|
BumpFeeResult current_result;
|
|
|
|
CAmount old_fee;
|
|
|
|
CAmount new_fee;
|
2017-03-03 16:15:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BITCOIN_WALLET_FEEBUMPER_H
|