Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | public: | ||||
void setAbandoned() { hashBlock = ABANDON_HASH; } | void setAbandoned() { hashBlock = ABANDON_HASH; } | ||||
TxId GetId() const { return tx->GetId(); } | TxId GetId() const { return tx->GetId(); } | ||||
bool IsCoinBase() const { return tx->IsCoinBase(); } | bool IsCoinBase() const { return tx->IsCoinBase(); } | ||||
bool IsImmatureCoinBase() const EXCLUSIVE_LOCKS_REQUIRED(cs_main); | bool IsImmatureCoinBase() const EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
}; | }; | ||||
// Get the marginal bytes of spending the specified output | // Get the marginal bytes of spending the specified output | ||||
int CalculateMaximumSignedInputSize(const CTxOut &txout, | int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, | ||||
const CWallet *pwallet); | bool use_max_sig = false); | ||||
/** | /** | ||||
* A transaction with a bunch of additional info that only the owner cares | * A transaction with a bunch of additional info that only the owner cares | ||||
* about. It includes any unrecorded transactions needed to link it back to the | * about. It includes any unrecorded transactions needed to link it back to the | ||||
* block chain. | * block chain. | ||||
*/ | */ | ||||
class CWalletTx : public CMerkleTx { | class CWalletTx : public CMerkleTx { | ||||
private: | private: | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | public: | ||||
Amount GetImmatureWatchOnlyCredit(const bool fUseCache = true) const | Amount GetImmatureWatchOnlyCredit(const bool fUseCache = true) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
Amount GetAvailableWatchOnlyCredit(const bool fUseCache = true) const | Amount GetAvailableWatchOnlyCredit(const bool fUseCache = true) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
Amount GetChange() const; | Amount GetChange() const; | ||||
// Get the marginal bytes if spending the specified output from this | // Get the marginal bytes if spending the specified output from this | ||||
// transaction | // transaction | ||||
int GetSpendSize(unsigned int out) const { | int GetSpendSize(unsigned int out, bool use_max_sig = false) const { | ||||
return CalculateMaximumSignedInputSize(tx->vout[out], pwallet); | return CalculateMaximumSignedInputSize(tx->vout[out], pwallet, | ||||
use_max_sig); | |||||
} | } | ||||
void GetAmounts(std::list<COutputEntry> &listReceived, | void GetAmounts(std::list<COutputEntry> &listReceived, | ||||
std::list<COutputEntry> &listSent, Amount &nFee, | std::list<COutputEntry> &listSent, Amount &nFee, | ||||
std::string &strSentAccount, | std::string &strSentAccount, | ||||
const isminefilter &filter) const; | const isminefilter &filter) const; | ||||
bool IsFromMe(const isminefilter &filter) const { | bool IsFromMe(const isminefilter &filter) const { | ||||
Show All 36 Lines | public: | ||||
/** Whether we have the private keys to spend this output */ | /** Whether we have the private keys to spend this output */ | ||||
bool fSpendable; | bool fSpendable; | ||||
/** Whether we know how to spend this output, ignoring the lack of keys */ | /** Whether we know how to spend this output, ignoring the lack of keys */ | ||||
bool fSolvable; | bool fSolvable; | ||||
/** | /** | ||||
* Whether to use the maximum sized, 72 byte signature when calculating the | |||||
* size of the input spend. This should only be set when watch-only outputs | |||||
* are allowed. | |||||
*/ | |||||
bool use_max_sig; | |||||
/** | |||||
* Whether this output is considered safe to spend. Unconfirmed transactions | * Whether this output is considered safe to spend. Unconfirmed transactions | ||||
* from outside keys are considered unsafe and will not be used to fund new | * from outside keys are considered unsafe and will not be used to fund new | ||||
* spending transactions. | * spending transactions. | ||||
*/ | */ | ||||
bool fSafe; | bool fSafe; | ||||
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, | COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, | ||||
bool fSolvableIn, bool fSafeIn) { | bool fSolvableIn, bool fSafeIn, bool use_max_sig_in = false) { | ||||
tx = txIn; | tx = txIn; | ||||
i = iIn; | i = iIn; | ||||
nDepth = nDepthIn; | nDepth = nDepthIn; | ||||
fSpendable = fSpendableIn; | fSpendable = fSpendableIn; | ||||
fSolvable = fSolvableIn; | fSolvable = fSolvableIn; | ||||
fSafe = fSafeIn; | fSafe = fSafeIn; | ||||
nInputBytes = -1; | nInputBytes = -1; | ||||
use_max_sig = use_max_sig_in; | |||||
// If known and signable by the given wallet, compute nInputBytes | // If known and signable by the given wallet, compute nInputBytes | ||||
// Failure will keep this value -1 | // Failure will keep this value -1 | ||||
if (fSpendable && tx) { | if (fSpendable && tx) { | ||||
nInputBytes = tx->GetSpendSize(i); | nInputBytes = tx->GetSpendSize(i, use_max_sig); | ||||
} | } | ||||
} | } | ||||
std::string ToString() const; | std::string ToString() const; | ||||
inline CInputCoin GetInputCoin() const { | inline CInputCoin GetInputCoin() const { | ||||
return CInputCoin(tx->tx, i, nInputBytes); | return CInputCoin(tx->tx, i, nInputBytes); | ||||
} | } | ||||
Show All 11 Lines | public: | ||||
explicit CWalletKey(int64_t nExpires = 0); | explicit CWalletKey(int64_t nExpires = 0); | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
int nVersion = s.GetVersion(); | int nVersion = s.GetVersion(); | ||||
if (!(s.GetType() & SER_GETHASH)) READWRITE(nVersion); | if (!(s.GetType() & SER_GETHASH)) { | ||||
READWRITE(nVersion); | |||||
} | |||||
READWRITE(vchPrivKey); | READWRITE(vchPrivKey); | ||||
READWRITE(nTimeCreated); | READWRITE(nTimeCreated); | ||||
READWRITE(nTimeExpires); | READWRITE(nTimeExpires); | ||||
READWRITE(LIMITED_STRING(strComment, 65536)); | READWRITE(LIMITED_STRING(strComment, 65536)); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 506 Lines • ▼ Show 20 Lines | bool CommitTransaction( | ||||
std::vector<std::pair<std::string, std::string>> orderForm, | std::vector<std::pair<std::string, std::string>> orderForm, | ||||
std::string fromAccount, CReserveKey &reservekey, CConnman *connman, | std::string fromAccount, CReserveKey &reservekey, CConnman *connman, | ||||
CValidationState &state); | CValidationState &state); | ||||
void ListAccountCreditDebit(const std::string &strAccount, | void ListAccountCreditDebit(const std::string &strAccount, | ||||
std::list<CAccountingEntry> &entries); | std::list<CAccountingEntry> &entries); | ||||
bool AddAccountingEntry(const CAccountingEntry &); | bool AddAccountingEntry(const CAccountingEntry &); | ||||
bool AddAccountingEntry(const CAccountingEntry &, WalletBatch *batch); | bool AddAccountingEntry(const CAccountingEntry &, WalletBatch *batch); | ||||
bool DummySignTx(CMutableTransaction &txNew, | bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, | ||||
const std::set<CTxOut> &txouts) 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); | return DummySignTx(txNew, v_txouts, use_max_sig); | ||||
} | } | ||||
bool DummySignTx(CMutableTransaction &txNew, | bool DummySignTx(CMutableTransaction &txNew, | ||||
const std::vector<CTxOut> &txouts) const; | const std::vector<CTxOut> &txouts, | ||||
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout) const; | bool use_max_sig = false) const; | ||||
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, | |||||
bool use_max_sig = false) const; | |||||
CFeeRate m_pay_tx_fee{DEFAULT_PAY_TX_FEE}; | CFeeRate m_pay_tx_fee{DEFAULT_PAY_TX_FEE}; | ||||
bool m_spend_zero_conf_change{DEFAULT_SPEND_ZEROCONF_CHANGE}; | bool m_spend_zero_conf_change{DEFAULT_SPEND_ZEROCONF_CHANGE}; | ||||
// will be defined via chainparams | // will be defined via chainparams | ||||
bool m_allow_fallback_fee{true}; | bool m_allow_fallback_fee{true}; | ||||
// Override with -mintxfee | // Override with -mintxfee | ||||
CFeeRate m_min_fee{DEFAULT_TRANSACTION_MINFEE_PER_KB}; | CFeeRate m_min_fee{DEFAULT_TRANSACTION_MINFEE_PER_KB}; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
}; | }; | ||||
// Calculate the size of the transaction assuming all signatures are max size | // Calculate the size of the transaction assuming all signatures are max size | ||||
// Use DummySignatureCreator, which inserts 71 byte signatures everywhere. | // Use DummySignatureCreator, which inserts 71 byte signatures everywhere. | ||||
// NOTE: this requires that all inputs must be in mapWallet (eg the tx should | // NOTE: this requires that all inputs must be in mapWallet (eg the tx should | ||||
// be IsAllFromMe). | // be IsAllFromMe). | ||||
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, | int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, | ||||
const CWallet *wallet); | const CWallet *wallet, | ||||
bool use_max_sig = false); | |||||
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, | int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, | ||||
const CWallet *wallet, | const CWallet *wallet, | ||||
const std::vector<CTxOut> &txouts); | const std::vector<CTxOut> &txouts, | ||||
bool use_max_sig = false); | |||||
#endif // BITCOIN_WALLET_WALLET_H | #endif // BITCOIN_WALLET_WALLET_H |