mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
lnwallet: add new NewUnilateralCloseSummary function
In this commit, we add a new function that allows a caller to create a UnilateralCloseSummary with the proper materials. This will be used within a new sub-system to be added in a later commit to properly dispatch notifications when on-chain events happen for a channel.
This commit is contained in:
@ -4184,26 +4184,18 @@ func TestChannelUnilateralCloseHtlcResolution(t *testing.T) {
|
||||
|
||||
// We'll then use Bob's transaction to trigger a spend notification for
|
||||
// Alice.
|
||||
aliceNotifier := aliceChannel.channelEvents.(*mockNotfier)
|
||||
closeTx := bobForceClose.CloseTx
|
||||
commitTxHash := closeTx.TxHash()
|
||||
select {
|
||||
case aliceNotifier.activeSpendNtfn <- &chainntnfs.SpendDetail{
|
||||
spendDetail := &chainntnfs.SpendDetail{
|
||||
SpendingTx: closeTx,
|
||||
SpenderTxHash: &commitTxHash,
|
||||
}:
|
||||
case <-time.After(time.Second * 15):
|
||||
t.Fatalf("alice didn't consume spend ntfn")
|
||||
}
|
||||
|
||||
// Alice should now send over a signal on the unilateral close signal
|
||||
// that we'll use to ensure she's able to sweep all the relevant
|
||||
// outputs.
|
||||
var aliceCloseSummary *UnilateralCloseSummary
|
||||
select {
|
||||
case aliceCloseSummary = <-aliceChannel.UnilateralClose:
|
||||
case <-time.After(time.Second * 15):
|
||||
t.Fatalf("alice didn't send her close summary")
|
||||
aliceCloseSummary, err := NewUnilateralCloseSummary(
|
||||
aliceChannel.channelState, aliceChannel.signer, aliceChannel.pCache,
|
||||
spendDetail, aliceChannel.channelState.RemoteCommitment,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create alice close summary: %v", err)
|
||||
}
|
||||
|
||||
// She should detect that she can sweep both the outgoing HTLC as well
|
||||
|
Reference in New Issue
Block a user