MCPcopy Create free account
hub / github.com/ElementsProject/elements / DummySignTx

Method DummySignTx

src/wallet/spend.cpp:56–84  ·  view source on GitHub ↗

Helper for producing a bunch of max-sized low-S low-R signatures (eg 71 bytes)

Source from the content-addressed store, hash-verified

54
55// Helper for producing a bunch of max-sized low-S low-R signatures (eg 71 bytes)
56bool CWallet::DummySignTx(CMutableTransaction &txNew, const std::vector<CTxOut> &txouts, const CCoinControl* coin_control) const
57{
58 // Fill in dummy signatures for fee calculation.
59 int nIn = 0;
60 for (const auto& txout : txouts)
61 {
62 CTxIn& txin = txNew.vin[nIn];
63 // If weight was provided, fill the input to that weight
64 if (coin_control && coin_control->HasInputWeight(txin.prevout)) {
65 if (!FillInputToWeight(txNew, nIn, coin_control->GetInputWeight(txin.prevout))) {
66 return false;
67 }
68 nIn++;
69 continue;
70 }
71 // Use max sig if watch only inputs were used or if this particular input is an external input
72 // to ensure a sufficient fee is attained for the requested feerate.
73 const bool use_max_sig = coin_control && (coin_control->fAllowWatchOnly || coin_control->IsExternalSelected(txin.prevout));
74 const std::unique_ptr<SigningProvider> provider = GetSolvingProvider(txout.scriptPubKey);
75 if (!provider || !DummySignInput(*provider, txNew, nIn, txout, use_max_sig)) {
76 if (!coin_control || !DummySignInput(coin_control->m_external_provider, txNew, nIn, txout, use_max_sig)) {
77 return false;
78 }
79 }
80
81 nIn++;
82 }
83 return true;
84}
85
86bool FillInputToWeight(CMutableTransaction& mtx, size_t nIn, int64_t target_weight)
87{

Callers 1

Calls 5

FillInputToWeightFunction · 0.85
DummySignInputFunction · 0.85
HasInputWeightMethod · 0.80
GetInputWeightMethod · 0.80
IsExternalSelectedMethod · 0.80

Tested by

no test coverage detected