Skip to content

Commit 65b3eda

Browse files
committed
wallet: Add input bytes to CInputCoin
With nInputBytes, coin selection can execute without a reference to the COutput
1 parent a443d7a commit 65b3eda

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/wallet/coinselection.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@ class CInputCoin {
2828
effective_value = txout.nValue;
2929
}
3030

31+
CInputCoin(const CTransactionRef& tx, unsigned int i, int input_bytes) : CInputCoin(tx, i)
32+
{
33+
m_input_bytes = input_bytes;
34+
}
35+
3136
COutPoint outpoint;
3237
CTxOut txout;
3338
CAmount effective_value;
3439
CAmount fee = 0;
3540
CAmount long_term_fee = 0;
3641

42+
/** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
43+
int m_input_bytes{-1};
44+
3745
bool operator<(const CInputCoin& rhs) const {
3846
return outpoint < rhs.outpoint;
3947
}

src/wallet/wallet.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ class COutput
525525
}
526526

527527
std::string ToString() const;
528+
529+
inline CInputCoin GetInputCoin() const
530+
{
531+
return CInputCoin(tx->tx, i, nInputBytes);
532+
}
528533
};
529534

530535

0 commit comments

Comments
 (0)