lnwallet+sweep: introduce TxPublisher to handle fee bump

This commit adds `TxPublisher` which implements `Bumper` interface. This
is part one of the implementation that focuses on implementing the
`Broadcast` method which guarantees a tx can be published with
RBF-compliant. It does so by leveraging the `testmempoolaccept` API,
keep increasing the fee rate until an RBF-compliant tx is made and
broadcasts it.

This tx will then be monitored by the `TxPublisher` and in the following
commit, the monitoring process will be added.
This commit is contained in:
yyforyongyu
2024-02-29 13:18:59 +08:00
parent ecd471ac75
commit 11f7e455d1
6 changed files with 1548 additions and 5 deletions

View File

@@ -493,3 +493,32 @@ func (m *MockBumper) Broadcast(req *BumpRequest) (<-chan *BumpResult, error) {
return args.Get(0).(chan *BumpResult), args.Error(1)
}
// MockFeeFunction is a mock implementation of the FeeFunction interface.
type MockFeeFunction struct {
mock.Mock
}
// Compile-time constraint to ensure MockFeeFunction implements FeeFunction.
var _ FeeFunction = (*MockFeeFunction)(nil)
// FeeRate returns the current fee rate calculated by the fee function.
func (m *MockFeeFunction) FeeRate() chainfee.SatPerKWeight {
args := m.Called()
return args.Get(0).(chainfee.SatPerKWeight)
}
// Increment adds one delta to the current fee rate.
func (m *MockFeeFunction) Increment() (bool, error) {
args := m.Called()
return args.Bool(0), args.Error(1)
}
// IncreaseFeeRate increases the fee rate by one step.
func (m *MockFeeFunction) IncreaseFeeRate(confTarget uint32) (bool, error) {
args := m.Called(confTarget)
return args.Bool(0), args.Error(1)
}