Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
constexpr Amount HIGH_TX_FEE_PER_KB{COIN / 100}; | constexpr Amount HIGH_TX_FEE_PER_KB{COIN / 100}; | ||||
//! -maxtxfee will warn if called with a higher fee than this amount (in | //! -maxtxfee will warn if called with a higher fee than this amount (in | ||||
//! satoshis) | //! satoshis) | ||||
constexpr Amount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB}; | constexpr Amount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB}; | ||||
class CChainParams; | class CChainParams; | ||||
class CCoinControl; | class CCoinControl; | ||||
class COutput; | class COutput; | ||||
class CReserveKey; | |||||
class CScript; | class CScript; | ||||
class CTxMemPool; | class CTxMemPool; | ||||
class CWalletTx; | class CWalletTx; | ||||
class ReserveDestination; | |||||
/** (client) version numbers for particular wallet features */ | /** (client) version numbers for particular wallet features */ | ||||
enum WalletFeature { | enum WalletFeature { | ||||
// the earliest version new wallets supports (only useful for | // the earliest version new wallets supports (only useful for | ||||
// getwalletinfo's clientversion output) | // getwalletinfo's clientversion output) | ||||
FEATURE_BASE = 10500, | FEATURE_BASE = 10500, | ||||
// wallet encryption | // wallet encryption | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
} else { | } else { | ||||
READWRITE(fInternal); | READWRITE(fInternal); | ||||
READWRITE(m_pre_split); | READWRITE(m_pre_split); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* A wrapper to reserve a key from a wallet keypool | * A wrapper to reserve an address from a wallet | ||||
* | * | ||||
* CReserveKey is used to reserve a key from the keypool. It is passed around | * ReserveDestination is used to reserve an address. It is passed around | ||||
* during the CreateTransaction/CommitTransaction procedure. | * during the CreateTransaction/CommitTransaction procedure. | ||||
* | * | ||||
* Instantiating a CReserveKey does not reserve a keypool key. To do so, | * Instantiating a ReserveDestination does not reserve an address. To do so, | ||||
* GetReservedKey() needs to be called on the object. Once a key has been | * GetReservedDestination() needs to be called on the object. Once an address | ||||
* reserved, call KeepKey() on the CReserveKey object to make sure it is not | * has been reserved, call KeepDestination() on the ReserveDestination object to | ||||
* returned to the keypool. Call ReturnKey() to return the key to the keypool | * make sure it is not returned. Call ReturnDestination() to return the address | ||||
* so it can be re-used (for example, if the key was used in a new transaction | * so it can be re-used (for example, if the address was used in a new | ||||
* and that transaction was not completed and needed to be aborted). | * transaction and that transaction was not completed and needed to be aborted). | ||||
* | * | ||||
* If a key is reserved and KeepKey() is not called, then the key will be | * If an address is reserved and KeepDestination() is not called, then the | ||||
* returned to the keypool when the CReserveObject goes out of scope. | * address will be returned when the ReserveDestination goes out of scope. | ||||
*/ | */ | ||||
class CReserveKey { | class ReserveDestination { | ||||
protected: | protected: | ||||
//! The wallet to reserve the keypool key from | //! The wallet to reserve from | ||||
CWallet *pwallet; | CWallet *pwallet; | ||||
//! The index of the key in the keypool | //! The index of the address's key in the keypool | ||||
int64_t nIndex{-1}; | int64_t nIndex{-1}; | ||||
//! The public key | //! The public key for the address | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
//! The destination | |||||
CTxDestination address; | |||||
//! Whether this is from the internal (change output) keypool | //! Whether this is from the internal (change output) keypool | ||||
bool fInternal{false}; | bool fInternal{false}; | ||||
public: | public: | ||||
//! Construct a CReserveKey object. This does NOT reserve a key from the | //! Construct a ReserveDestination object. This does NOT reserve an address | ||||
//! keypool yet | //! yet | ||||
explicit CReserveKey(CWallet *pwalletIn) { pwallet = pwalletIn; } | explicit ReserveDestination(CWallet *pwalletIn) { pwallet = pwalletIn; } | ||||
CReserveKey(const CReserveKey &) = delete; | ReserveDestination(const ReserveDestination &) = delete; | ||||
CReserveKey &operator=(const CReserveKey &) = delete; | ReserveDestination &operator=(const ReserveDestination &) = delete; | ||||
//! Destructor. If a key has been reserved and not KeepKey'ed, it will be | //! Destructor. If a key has been reserved and not KeepKey'ed, it will be | ||||
//! returned to the keypool | //! returned to the keypool | ||||
~CReserveKey() { ReturnKey(); } | ~ReserveDestination() { ReturnDestination(); } | ||||
//! Reserve a key from the keypool | //! Reserve an address | ||||
bool GetReservedKey(CPubKey &pubkey, bool internal = false); | bool GetReservedDestination(const OutputType type, CTxDestination &pubkey, | ||||
//! Return a key to the keypool | bool internal); | ||||
void ReturnKey(); | //! Return reserved address | ||||
//! Keep the key. Do not return it to the keypool when this object goes out | void ReturnDestination(); | ||||
//! of scope | //! Keep the address. Do not return it's key to the keypool when this object | ||||
void KeepKey(); | //! goes out of scope | ||||
void KeepDestination(); | |||||
}; | }; | ||||
/** Address book data */ | /** Address book data */ | ||||
class CAddressBookData { | class CAddressBookData { | ||||
public: | public: | ||||
std::string name; | std::string name; | ||||
std::string purpose; | std::string purpose; | ||||
▲ Show 20 Lines • Show All 959 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Create a new transaction paying the recipients with a set of coins | * Create a new transaction paying the recipients with a set of coins | ||||
* selected by SelectCoins(); Also create the change output, when needed | * selected by SelectCoins(); Also create the change output, when needed | ||||
* @note passing nChangePosInOut as -1 will result in setting a random | * @note passing nChangePosInOut as -1 will result in setting a random | ||||
* position | * position | ||||
*/ | */ | ||||
bool CreateTransaction(interfaces::Chain::Lock &locked_chain, | bool CreateTransaction(interfaces::Chain::Lock &locked_chain, | ||||
const std::vector<CRecipient> &vecSend, | const std::vector<CRecipient> &vecSend, | ||||
CTransactionRef &tx, CReserveKey &reservekey, | CTransactionRef &tx, ReserveDestination &reservedest, | ||||
Amount &nFeeRet, int &nChangePosInOut, | Amount &nFeeRet, int &nChangePosInOut, | ||||
std::string &strFailReason, | std::string &strFailReason, | ||||
const CCoinControl &coin_control, bool sign = true); | const CCoinControl &coin_control, bool sign = true); | ||||
bool CommitTransaction( | bool CommitTransaction( | ||||
CTransactionRef tx, mapValue_t mapValue, | CTransactionRef tx, mapValue_t mapValue, | ||||
std::vector<std::pair<std::string, std::string>> orderForm, | std::vector<std::pair<std::string, std::string>> orderForm, | ||||
CReserveKey &reservekey, CValidationState &state); | ReserveDestination &reservedest, CValidationState &state); | ||||
bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, | bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, | ||||
bool use_max_sig = false) const { | bool use_max_sig = false) const { | ||||
std::vector<CTxOut> v_txouts(txouts.size()); | std::vector<CTxOut> v_txouts(txouts.size()); | ||||
std::copy(txouts.begin(), txouts.end(), v_txouts.begin()); | std::copy(txouts.begin(), txouts.end(), v_txouts.begin()); | ||||
return DummySignTx(txNew, v_txouts, use_max_sig); | return DummySignTx(txNew, v_txouts, use_max_sig); | ||||
} | } | ||||
bool DummySignTx(CMutableTransaction &txNew, | bool DummySignTx(CMutableTransaction &txNew, | ||||
▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines |