sweep: pass dustLimit to CreateSweepTx

This commit is contained in:
Johan T. Halseth
2020-11-06 19:44:12 +01:00
parent 3d209059c1
commit aa8fa9d0cf
6 changed files with 30 additions and 21 deletions

View File

@@ -132,7 +132,7 @@ func generateInputPartitionings(sweepableInputs []txInput,
// createSweepTx builds a signed tx spending the inputs to a the output script.
func createSweepTx(inputs []input.Input, outputPkScript []byte,
currentBlockHeight uint32, feePerKw chainfee.SatPerKWeight,
signer input.Signer) (*wire.MsgTx, error) {
dustLimit btcutil.Amount, signer input.Signer) (*wire.MsgTx, error) {
inputs, estimator := getWeightEstimate(inputs, feePerKw)
@@ -169,14 +169,16 @@ func createSweepTx(inputs []input.Input, outputPkScript []byte,
}
// Sweep as much possible, after subtracting txn fees.
sweepAmt := int64(totalSum - txFee)
sweepAmt := totalSum - txFee
// The txn will sweep the amount after fees to the pkscript generated
// above.
sweepTx.AddTxOut(&wire.TxOut{
PkScript: outputPkScript,
Value: sweepAmt,
})
if sweepAmt >= dustLimit {
sweepTx.AddTxOut(&wire.TxOut{
PkScript: outputPkScript,
Value: int64(sweepAmt),
})
}
// We'll default to using the current block height as locktime, if none
// of the inputs commits to a different locktime.