sweep: add new AuxSweeper interface

In this commit, we add a new AuxSweeper interface. This'll take a set of
inputs, and a change addr for the sweep transaction, then optionally
return a new sweep output to be added to the sweep transaction.

We also add a new NotifyBroadcast method.  This'll be used to notify
that we're _about_ to broadcast a sweeping transaction. The set of
inputs is passed in, which allows the caller to prepare for the ultimate
broadcast of the sweeping transaction.

We also add ExtraTxOut to BumpRequest pass fees to NotifyBroadcast. This
allows the callee to know the total fee of the sweeping transaction.
This commit is contained in:
Olaoluwa Osuntokun
2024-06-03 23:06:17 -07:00
parent d52d30d46e
commit cb93f8c01a
7 changed files with 166 additions and 62 deletions

View File

@@ -314,3 +314,22 @@ func (m *MockFeeFunction) IncreaseFeeRate(confTarget uint32) (bool, error) {
return args.Bool(0), args.Error(1)
}
type MockAuxSweeper struct{}
// DeriveSweepAddr takes a set of inputs, and the change address we'd
// use to sweep them, and maybe results an extra sweep output that we
// should add to the sweeping transaction.
func (*MockAuxSweeper) DeriveSweepAddr(_ []input.Input,
_ lnwallet.AddrWithKey) fn.Result[SweepOutput] {
return fn.Ok(SweepOutput{})
}
// NotifyBroadcast is used to notify external callers of the broadcast
// of a sweep transaction, generated by the passed BumpRequest.
func (*MockAuxSweeper) NotifyBroadcast(_ *BumpRequest, _ *wire.MsgTx,
_ btcutil.Amount) error {
return nil
}