lnwallet: mark channel as frozen based on ShimIntent

In this commit, we make the internal channel funding flow aware of
frozen channels. We also update the testSingleFunderReservationWorkflow
method to ensure that the created channels have the proper type bit set.
This commit is contained in:
Olaoluwa Osuntokun committed 2020-03-23 16:57:00 -07:00
1 parent 8bce48d3cc
commit c85f6bb364
3 files changed
+59 -25

No files matched your search

+21 -13
View File
@@ -560,6 +560,26 @@ func (l *LightningWallet) handleFundingReserveRequest(req *InitFundingReserveMsg
remoteFundingAmt = fundingIntent.RemoteFundingAmt()
}
// If this is a shim intent, then it may be attempting to use an
// existing set of keys for the funding workflow. In this case, we'll
// make a simple wrapper keychain.KeyRing that will proxy certain
// derivation calls to future callers.
var (
keyRing keychain.KeyRing = l.SecretKeyRing
thawHeight uint32
)
if shimIntent, ok := fundingIntent.(*chanfunding.ShimIntent); ok {
keyRing = &shimKeyRing{
KeyRing: keyRing,
ShimIntent: shimIntent,
}
// As this was a registered shim intent, we'll obtain the thaw
// height of the intent, if present at all. If this is
// non-zero, then we'll mark this as the proper channel type.
thawHeight = shimIntent.ThawHeight()
}
// The total channel capacity will be the size of the funding output we
// created plus the remote contribution.
capacity := localFundingAmt + remoteFundingAmt
@@ -569,6 +589,7 @@ func (l *LightningWallet) handleFundingReserveRequest(req *InitFundingReserveMsg
capacity, localFundingAmt, req.CommitFeePerKw, l, id,
req.PushMSat, l.Cfg.NetParams.GenesisHash, req.Flags,
req.CommitType, req.ChanFunder, req.PendingChanID,
thawHeight,
)
if err != nil {
if fundingIntent != nil {
@@ -580,19 +601,6 @@ func (l *LightningWallet) handleFundingReserveRequest(req *InitFundingReserveMsg
return
}
var keyRing keychain.KeyRing = l.SecretKeyRing
// If this is a shim intent, then it may be attempting to use an
// existing set of keys for the funding workflow. In this case, we'll
// make a simple wrapper keychain.KeyRing that will proxy certain
// derivation calls to future callers.
if shimIntent, ok := fundingIntent.(*chanfunding.ShimIntent); ok {
keyRing = &shimKeyRing{
KeyRing: keyRing,
ShimIntent: shimIntent,
}
}
err = l.initOurContribution(
reservation, fundingIntent, req.NodeAddr, req.NodeID, keyRing,
)