mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-12 13:54:31 +01:00
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:
103
input/mocks.go
103
input/mocks.go
@@ -1,8 +1,14 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
@@ -168,3 +174,100 @@ func (m *MockWitnessType) AddWeightEstimation(e *TxWeightEstimator) error {
|
||||
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// MockInputSigner is a mock implementation of the Signer interface.
|
||||
type MockInputSigner struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Compile-time constraint to ensure MockInputSigner implements Signer.
|
||||
var _ Signer = (*MockInputSigner)(nil)
|
||||
|
||||
// SignOutputRaw generates a signature for the passed transaction according to
|
||||
// the data within the passed SignDescriptor.
|
||||
func (m *MockInputSigner) SignOutputRaw(tx *wire.MsgTx,
|
||||
signDesc *SignDescriptor) (Signature, error) {
|
||||
|
||||
args := m.Called(tx, signDesc)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
return args.Get(0).(Signature), args.Error(1)
|
||||
}
|
||||
|
||||
// ComputeInputScript generates a complete InputIndex for the passed
|
||||
// transaction with the signature as defined within the passed SignDescriptor.
|
||||
func (m *MockInputSigner) ComputeInputScript(tx *wire.MsgTx,
|
||||
signDesc *SignDescriptor) (*Script, error) {
|
||||
|
||||
args := m.Called(tx, signDesc)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
return args.Get(0).(*Script), args.Error(1)
|
||||
}
|
||||
|
||||
// MuSig2CreateSession creates a new MuSig2 signing session using the local key
|
||||
// identified by the key locator.
|
||||
func (m *MockInputSigner) MuSig2CreateSession(version MuSig2Version,
|
||||
locator keychain.KeyLocator, pubkey []*btcec.PublicKey,
|
||||
tweak *MuSig2Tweaks, pubNonces [][musig2.PubNonceSize]byte,
|
||||
nonces *musig2.Nonces) (*MuSig2SessionInfo, error) {
|
||||
|
||||
args := m.Called(version, locator, pubkey, tweak, pubNonces, nonces)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
return args.Get(0).(*MuSig2SessionInfo), args.Error(1)
|
||||
}
|
||||
|
||||
// MuSig2RegisterNonces registers one or more public nonces of other signing
|
||||
// participants for a session identified by its ID.
|
||||
func (m *MockInputSigner) MuSig2RegisterNonces(versio MuSig2SessionID,
|
||||
pubNonces [][musig2.PubNonceSize]byte) (bool, error) {
|
||||
|
||||
args := m.Called(versio, pubNonces)
|
||||
if args.Get(0) == nil {
|
||||
return false, args.Error(1)
|
||||
}
|
||||
|
||||
return args.Bool(0), args.Error(1)
|
||||
}
|
||||
|
||||
// MuSig2Sign creates a partial signature using the local signing key that was
|
||||
// specified when the session was created.
|
||||
func (m *MockInputSigner) MuSig2Sign(sessionID MuSig2SessionID,
|
||||
msg [sha256.Size]byte, withSortedKeys bool) (
|
||||
*musig2.PartialSignature, error) {
|
||||
|
||||
args := m.Called(sessionID, msg, withSortedKeys)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
return args.Get(0).(*musig2.PartialSignature), args.Error(1)
|
||||
}
|
||||
|
||||
// MuSig2CombineSig combines the given partial signature(s) with the local one,
|
||||
// if it already exists.
|
||||
func (m *MockInputSigner) MuSig2CombineSig(sessionID MuSig2SessionID,
|
||||
partialSig []*musig2.PartialSignature) (
|
||||
*schnorr.Signature, bool, error) {
|
||||
|
||||
args := m.Called(sessionID, partialSig)
|
||||
if args.Get(0) == nil {
|
||||
return nil, false, args.Error(2)
|
||||
}
|
||||
|
||||
return args.Get(0).(*schnorr.Signature), args.Bool(1), args.Error(2)
|
||||
}
|
||||
|
||||
// MuSig2Cleanup removes a session from memory to free up resources.
|
||||
func (m *MockInputSigner) MuSig2Cleanup(sessionID MuSig2SessionID) error {
|
||||
args := m.Called(sessionID)
|
||||
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user