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:
Olaoluwa Osuntokun
2018-01-18 13:49:35 -08:00
parent 341c1678fc
commit 5bbe126c34
2 changed files with 101 additions and 15 deletions

View File

@ -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