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;
|
|
|
|
|
|
|
|
enum class BumpFeeResult
|
|
|
|
{
|
|
|
|
OK,
|
|
|
|
INVALID_ADDRESS_OR_KEY,
|
|
|
|
INVALID_REQUEST,
|
|
|
|
INVALID_PARAMETER,
|
|
|
|
WALLET_ERROR,
|
|
|
|
MISC_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
class CFeeBumper
|
|
|
|
{
|
|
|
|
public:
|
2017-05-25 16:13:28 +02:00
|
|
|
CFeeBumper(const CWallet *pWalletIn, const uint256 txidIn, int newConfirmTarget, bool ignoreGlobalPayTxFee, CAmount totalFee, bool newTxReplaceable);
|
2017-03-03 16:15:47 +01:00
|
|
|
BumpFeeResult getResult() const { return currentResult; }
|
|
|
|
const std::vector<std::string>& getErrors() const { return vErrors; }
|
|
|
|
CAmount getOldFee() const { return nOldFee; }
|
|
|
|
CAmount getNewFee() const { return nNewFee; }
|
|
|
|
uint256 getBumpedTxId() const { return bumpedTxid; }
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
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
|
|
|
|
*/
|
2017-03-03 16:15:47 +01:00
|
|
|
bool commit(CWallet *pWalletNonConst);
|
|
|
|
|
|
|
|
private:
|
2017-05-11 09:34:39 +02:00
|
|
|
bool preconditionChecks(const CWallet *pWallet, const CWalletTx& wtx);
|
|
|
|
|
2017-03-03 16:15:47 +01:00
|
|
|
const uint256 txid;
|
|
|
|
uint256 bumpedTxid;
|
|
|
|
CMutableTransaction mtx;
|
|
|
|
std::vector<std::string> vErrors;
|
|
|
|
BumpFeeResult currentResult;
|
|
|
|
CAmount nOldFee;
|
|
|
|
CAmount nNewFee;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BITCOIN_WALLET_FEEBUMPER_H
|