Changeset View
Changeset View
Standalone View
Standalone View
src/primitives/transaction.h
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | public: | ||||
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) { | ||||
READWRITE(nValue); | READWRITE(nValue); | ||||
READWRITE(*(CScriptBase *)(&scriptPubKey)); | READWRITE(*(CScriptBase *)(&scriptPubKey)); | ||||
} | } | ||||
void SetNull() { | void SetNull() { | ||||
nValue = -1; | nValue = Amount(-1); | ||||
scriptPubKey.clear(); | scriptPubKey.clear(); | ||||
} | } | ||||
bool IsNull() const { return (nValue == -1); } | bool IsNull() const { return (nValue == Amount(-1)); } | ||||
Amount GetDustThreshold(const CFeeRate &minRelayTxFee) const { | Amount GetDustThreshold(const CFeeRate &minRelayTxFee) const { | ||||
// "Dust" is defined in terms of CTransaction::minRelayTxFee, which has | // "Dust" is defined in terms of CTransaction::minRelayTxFee, which has | ||||
// units satoshis-per-kilobyte. If you'd pay more than 1/3 in fees to | // units satoshis-per-kilobyte. If you'd pay more than 1/3 in fees to | ||||
// spend something, then we consider it dust. A typical spendable | // spend something, then we consider it dust. A typical spendable | ||||
// non-segwit txout is 34 bytes big, and will need a CTxIn of at least | // non-segwit txout is 34 bytes big, and will need a CTxIn of at least | ||||
// 148 bytes to spend: so dust is a spendable txout less than | // 148 bytes to spend: so dust is a spendable txout less than | ||||
// 546*minRelayTxFee/1000 (in satoshis). A typical spendable segwit | // 546*minRelayTxFee/1000 (in satoshis). A typical spendable segwit | ||||
// txout is 31 bytes big, and will need a CTxIn of at least 67 bytes to | // txout is 31 bytes big, and will need a CTxIn of at least 67 bytes to | ||||
// spend: so dust is a spendable txout less than 294*minRelayTxFee/1000 | // spend: so dust is a spendable txout less than 294*minRelayTxFee/1000 | ||||
// (in satoshis). | // (in satoshis). | ||||
if (scriptPubKey.IsUnspendable()) return 0; | if (scriptPubKey.IsUnspendable()) return Amount(0); | ||||
size_t nSize = GetSerializeSize(*this, SER_DISK, 0); | size_t nSize = GetSerializeSize(*this, SER_DISK, 0); | ||||
// the 148 mentioned above | // the 148 mentioned above | ||||
nSize += (32 + 4 + 1 + 107 + 4); | nSize += (32 + 4 + 1 + 107 + 4); | ||||
return 3 * minRelayTxFee.GetFee(nSize); | return 3 * minRelayTxFee.GetFee(nSize); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |