From 698340b62adbc24075e7c818844206a6582c6300 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Fri, 18 Oct 2019 14:44:58 -0400 Subject: [PATCH] Allow CInputCoin to also be constructed with COutPoint and CTxOut --- src/wallet/coinselection.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 0fee6ada96..ebee172223 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -6,7 +6,9 @@ #define BITCOIN_WALLET_COINSELECTION_H #include +#include #include +#include #include //! target minimum change amount @@ -26,6 +28,41 @@ class CInputCoin { m_input_bytes = input_bytes; } + CInputCoin(const COutPoint& outpoint_in, const CTxOut& txout_in) + { + outpoint = outpoint_in; + txout = txout_in; + if (txout.nValue.IsExplicit()) { + effective_value = txout_in.nValue.GetAmount(); + value = txout.nValue.GetAmount(); + asset = txout.nAsset.GetAsset(); + } else { + effective_value = 0; + } + } + + CInputCoin(const COutPoint& outpoint_in, const CTxOut& txout_in, int input_bytes) : CInputCoin(outpoint_in, txout_in) + { + m_input_bytes = input_bytes; + } + + CInputCoin(const COutPoint& outpoint_in, const Sidechain::Bitcoin::CTxOut& txout_in) + { + outpoint = outpoint_in; + effective_value = txout_in.nValue; + txout.SetNull(); + txout.scriptPubKey = txout_in.scriptPubKey; + txout.nValue.SetToAmount(txout_in.nValue); + txout.nAsset.SetToAsset(Params().GetConsensus().pegged_asset); + asset = Params().GetConsensus().pegged_asset; + value = txout_in.nValue; + } + + CInputCoin(const COutPoint& outpoint_in, const Sidechain::Bitcoin::CTxOut& txout_in, int input_bytes) : CInputCoin(outpoint_in, txout_in) + { + m_input_bytes = input_bytes; + } + COutPoint outpoint; CTxOut txout; CAmount effective_value;