mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
multi: obtain+verify aux sigs for all second level HTLCs
In this commit, we start to use the new AuxSigner to obtain+verify aux sigs for all second level HTLCs. This is similar to the existing SigPool, but we'll only attempt to do this if the AuxSigner is present (won't be for most channels).
This commit is contained in:
committed by
Oliver Gugger
parent
bd84fd256e
commit
83fdbda2fa
@ -21,6 +21,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -441,3 +442,54 @@ func (*MockAuxLeafStore) ApplyHtlcView(
|
||||
|
||||
return fn.Ok(fn.None[tlv.Blob]())
|
||||
}
|
||||
|
||||
// MockAuxSigner is a mock implementation of the AuxSigner interface.
|
||||
type MockAuxSigner struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// SubmitSecondLevelSigBatch takes a batch of aux sign jobs and
|
||||
// processes them asynchronously.
|
||||
func (a *MockAuxSigner) SubmitSecondLevelSigBatch(chanState AuxChanState,
|
||||
tx *wire.MsgTx, jobs []AuxSigJob) error {
|
||||
|
||||
args := a.Called(chanState, tx, jobs)
|
||||
|
||||
// While we return, we'll also send back an instant response for the
|
||||
// set of jobs.
|
||||
for _, sigJob := range jobs {
|
||||
sigJob.Resp <- AuxSigJobResp{}
|
||||
}
|
||||
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// PackSigs takes a series of aux signatures and packs them into a
|
||||
// single blob that can be sent alongside the CommitSig messages.
|
||||
func (a *MockAuxSigner) PackSigs(
|
||||
sigs []fn.Option[tlv.Blob]) fn.Result[fn.Option[tlv.Blob]] {
|
||||
|
||||
args := a.Called(sigs)
|
||||
|
||||
return args.Get(0).(fn.Result[fn.Option[tlv.Blob]])
|
||||
}
|
||||
|
||||
// UnpackSigs takes a packed blob of signatures and returns the
|
||||
// original signatures for each HTLC, keyed by HTLC index.
|
||||
func (a *MockAuxSigner) UnpackSigs(
|
||||
sigs fn.Option[tlv.Blob]) fn.Result[[]fn.Option[tlv.Blob]] {
|
||||
|
||||
args := a.Called(sigs)
|
||||
|
||||
return args.Get(0).(fn.Result[[]fn.Option[tlv.Blob]])
|
||||
}
|
||||
|
||||
// VerifySecondLevelSigs attempts to synchronously verify a batch of aux
|
||||
// sig jobs.
|
||||
func (a *MockAuxSigner) VerifySecondLevelSigs(chanState AuxChanState,
|
||||
tx *wire.MsgTx, jobs []AuxVerifyJob) error {
|
||||
|
||||
args := a.Called(chanState, tx, jobs)
|
||||
|
||||
return args.Error(0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user