sweep: create new Input interface

This commit introduces a common interface for sweep
inputs. It eliminates the type checking from UtxoSweeper.

Also the formerly present Amount() getter is removed. It was redundant
because this value is present in SignDesc().Output.Value as well.
This commit is contained in:
Joost Jager committed 2018-10-17 12:44:33 +02:00
1 parent 4dab405623
commit 7d69df77ed
4 files changed
+109 -90

No files matched your search

+7 -7
View File
@@ -871,14 +871,14 @@ func (u *utxoNursery) graduateClass(classHeight uint32) error {
// generated a sweep txn for this height. Generate one if there
// are kindergarten outputs or cltv crib outputs to be spent.
if len(kgtnOutputs) > 0 {
csvSpendableOutputs := make([]sweep.CsvSpendableOutput,
sweepInputs := make([]sweep.Input,
len(kgtnOutputs))
for i := range kgtnOutputs {
csvSpendableOutputs[i] = &kgtnOutputs[i]
sweepInputs[i] = &kgtnOutputs[i]
}
finalTx, err = u.cfg.Sweeper.CreateSweepTx(
csvSpendableOutputs, classHeight)
sweepInputs, classHeight)
if err != nil {
utxnLog.Errorf("Failed to create sweep txn at "+
@@ -1749,7 +1749,7 @@ func readTxOut(r io.Reader, txo *wire.TxOut) error {
return nil
}
// Compile-time constraint to ensure kidOutput and babyOutput implement the
// CsvSpendableOutput interface.
var _ sweep.CsvSpendableOutput = (*kidOutput)(nil)
var _ sweep.CsvSpendableOutput = (*babyOutput)(nil)
// Compile-time constraint to ensure kidOutput implements the
// Input interface.
var _ sweep.Input = (*kidOutput)(nil)