sweep/tx_input_set: account for required outputs in input set
If inputs require outputs to be added at the same time, this will change the weight and amount calculations, so we must account for that. We wait to get the weight estimator for the sweep tx until needed, such that we can easily choose whether to include a change output or not in the estimate. This is needed for the case where the second level transactions can pay for their own fee, so no change output is needed.
This commit is contained in:
4 files changed
+238
-55
No files matched your search
@@ -110,17 +110,19 @@ func generateInputPartitionings(sweepableInputs []txInput,
|
||||
// the dust limit, stop sweeping. Because of the sorting,
|
||||
// continuing with the remaining inputs will only lead to sets
|
||||
// with an even lower output value.
|
||||
if !txInputs.dustLimitReached() {
|
||||
log.Debugf("Set value %v below dust limit of %v",
|
||||
txInputs.outputValue, txInputs.dustLimit)
|
||||
if !txInputs.enoughInput() {
|
||||
log.Debugf("Set value %v (r=%v, c=%v) below dust "+
|
||||
"limit of %v", txInputs.totalOutput(),
|
||||
txInputs.requiredOutput, txInputs.changeOutput,
|
||||
txInputs.dustLimit)
|
||||
return sets, nil
|
||||
}
|
||||
|
||||
log.Infof("Candidate sweep set of size=%v (+%v wallet inputs), "+
|
||||
"has yield=%v, weight=%v",
|
||||
inputCount, len(txInputs.inputs)-inputCount,
|
||||
txInputs.outputValue-txInputs.walletInputTotal,
|
||||
txInputs.weightEstimate.weight())
|
||||
txInputs.totalOutput()-txInputs.walletInputTotal,
|
||||
txInputs.weightEstimate(true).weight())
|
||||
|
||||
sets = append(sets, txInputs.inputs)
|
||||
sweepableInputs = sweepableInputs[inputCount:]
|
||||
|
||||
Reference in new issue
Block a user