lnwallet: use stored initiator bool to properly construct close tx
This commit modifies the channel closing logic to remove the hard coded bools indicating which side is attempting the closure. With the recent changes, the initiator must always pay the channel closure fees. This information is recently stored on disk, therefore we can use the boolean to ensure that the closure transaction is created properly no matter who initiates the close. This fixes a bug.
This commit is contained in:
parent
60f66fe2d7
commit
e0c09a016b
@ -900,8 +900,8 @@ func testMaxPendingChannels(net *networkHarness, t *harnessTest) {
|
||||
|
||||
chanPoints := make([]*lnrpc.ChannelPoint, maxPendingChannels)
|
||||
for i, stream := range openStreams {
|
||||
ctx, _ = context.WithTimeout(context.Background(), timeout)
|
||||
fundingChanPoint, err := net.WaitForChannelOpen(ctx, stream)
|
||||
ctxt, _ := context.WithTimeout(context.Background(), timeout)
|
||||
fundingChanPoint, err := net.WaitForChannelOpen(ctxt, stream)
|
||||
if err != nil {
|
||||
t.Fatalf("error while waiting for channel open: %v", err)
|
||||
}
|
||||
|
@ -1949,11 +1949,10 @@ func (lc *LightningChannel) InitCooperativeClose() ([]byte, *wire.ShaHash, error
|
||||
// been initiated.
|
||||
lc.status = channelClosing
|
||||
|
||||
// TODO(roasbeef): assumes initiator pays fees
|
||||
closeTx := CreateCooperativeCloseTx(lc.fundingTxIn,
|
||||
lc.channelState.OurBalance, lc.channelState.TheirBalance,
|
||||
lc.channelState.OurDeliveryScript, lc.channelState.TheirDeliveryScript,
|
||||
true)
|
||||
lc.channelState.IsInitiator)
|
||||
closeTxSha := closeTx.TxSha()
|
||||
|
||||
// Finally, sign the completed cooperative closure transaction. As the
|
||||
@ -1995,7 +1994,7 @@ func (lc *LightningChannel) CompleteCooperativeClose(remoteSig []byte) (*wire.Ms
|
||||
closeTx := CreateCooperativeCloseTx(lc.fundingTxIn,
|
||||
lc.channelState.OurBalance, lc.channelState.TheirBalance,
|
||||
lc.channelState.OurDeliveryScript, lc.channelState.TheirDeliveryScript,
|
||||
false)
|
||||
lc.channelState.IsInitiator)
|
||||
|
||||
// With the transaction created, we can finally generate our half of
|
||||
// the 2-of-2 multi-sig needed to redeem the funding output.
|
||||
|
@ -496,7 +496,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness, wallet *lnwallet
|
||||
bobCloseTx := lnwallet.CreateCooperativeCloseTx(fundingTxIn,
|
||||
chanInfo.RemoteBalance, chanInfo.LocalBalance,
|
||||
lnc.RemoteDeliveryScript, lnc.LocalDeliveryScript,
|
||||
false)
|
||||
true)
|
||||
bobSig, err := bobNode.signCommitTx(bobCloseTx, witnessScript, int64(lnc.Capacity))
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate bob's signature for closing tx: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user