lnwallet/chanfunding: add new ThawHeight() method to ShimIntent+CannedAssembler

As frozen channels can only be created via the non-default channel
assembler, we extend both the ShimIntent and CannedAssembler to also
accept and expose this new channel status along with the thaw height.
This commit is contained in:
Olaoluwa Osuntokun 2020-03-13 16:51:32 -07:00
parent dbc485f724
commit 8bce48d3cc
No known key found for this signature in database
GPG Key ID: BC13F65E2DC84465
2 changed files with 24 additions and 6 deletions

@ -30,6 +30,11 @@ type ShimIntent struct {
// chanPoint is the final channel point for the to be created channel.
chanPoint *wire.OutPoint
// thawHeight, if non-zero is the height where this channel will become
// a normal channel. Until this height, it's considered frozen, so it
// can only be cooperatively closed by the responding party.
thawHeight uint32
}
// FundingOutput returns the witness script, and the output that creates the
@ -87,6 +92,12 @@ func (s *ShimIntent) ChanPoint() (*wire.OutPoint, error) {
return s.chanPoint, nil
}
// ThawHeight returns the height where this channel goes back to being a normal
// channel.
func (s *ShimIntent) ThawHeight() uint32 {
return s.thawHeight
}
// FundingKeys couples our multi-sig key along with the remote party's key.
type FundingKeys struct {
// LocalKey is our multi-sig key.
@ -131,12 +142,17 @@ type CannedAssembler struct {
// initiator indicates if we're the initiator or the channel or not.
initiator bool
// thawHeight, if non-zero is the height where this channel will become
// a normal channel. Until this height, it's considered frozen, so it
// can only be cooperatively closed by the responding party.
thawHeight uint32
}
// NewCannedAssembler creates a new CannedAssembler from the material required
// to construct a funding output and channel point.
func NewCannedAssembler(chanPoint wire.OutPoint, fundingAmt btcutil.Amount,
localKey *keychain.KeyDescriptor,
func NewCannedAssembler(thawHeight uint32, chanPoint wire.OutPoint,
fundingAmt btcutil.Amount, localKey *keychain.KeyDescriptor,
remoteKey *btcec.PublicKey, initiator bool) *CannedAssembler {
return &CannedAssembler{
@ -145,6 +161,7 @@ func NewCannedAssembler(chanPoint wire.OutPoint, fundingAmt btcutil.Amount,
remoteKey: remoteKey,
fundingAmt: fundingAmt,
chanPoint: chanPoint,
thawHeight: thawHeight,
}
}
@ -162,9 +179,10 @@ func (c *CannedAssembler) ProvisionChannel(req *Request) (Intent, error) {
}
intent := &ShimIntent{
localKey: c.localKey,
remoteKey: c.remoteKey,
chanPoint: &c.chanPoint,
localKey: c.localKey,
remoteKey: c.remoteKey,
chanPoint: &c.chanPoint,
thawHeight: c.thawHeight,
}
if c.initiator {

@ -1545,7 +1545,7 @@ func newFundingShimAssembler(chanPointShim *lnrpc.ChanPointShim,
// With all the parts assembled, we can now make the canned assembler
// to pass into the wallet.
return chanfunding.NewCannedAssembler(
*chanPoint, btcutil.Amount(chanPointShim.Amt),
0, *chanPoint, btcutil.Amount(chanPointShim.Amt),
&localKeyDesc, remoteKey, initiator,
), nil
}