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:
parent
dbc485f724
commit
8bce48d3cc
@ -30,6 +30,11 @@ type ShimIntent struct {
|
|||||||
|
|
||||||
// chanPoint is the final channel point for the to be created channel.
|
// chanPoint is the final channel point for the to be created channel.
|
||||||
chanPoint *wire.OutPoint
|
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
|
// 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
|
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.
|
// FundingKeys couples our multi-sig key along with the remote party's key.
|
||||||
type FundingKeys struct {
|
type FundingKeys struct {
|
||||||
// LocalKey is our multi-sig key.
|
// 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 indicates if we're the initiator or the channel or not.
|
||||||
initiator bool
|
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
|
// NewCannedAssembler creates a new CannedAssembler from the material required
|
||||||
// to construct a funding output and channel point.
|
// to construct a funding output and channel point.
|
||||||
func NewCannedAssembler(chanPoint wire.OutPoint, fundingAmt btcutil.Amount,
|
func NewCannedAssembler(thawHeight uint32, chanPoint wire.OutPoint,
|
||||||
localKey *keychain.KeyDescriptor,
|
fundingAmt btcutil.Amount, localKey *keychain.KeyDescriptor,
|
||||||
remoteKey *btcec.PublicKey, initiator bool) *CannedAssembler {
|
remoteKey *btcec.PublicKey, initiator bool) *CannedAssembler {
|
||||||
|
|
||||||
return &CannedAssembler{
|
return &CannedAssembler{
|
||||||
@ -145,6 +161,7 @@ func NewCannedAssembler(chanPoint wire.OutPoint, fundingAmt btcutil.Amount,
|
|||||||
remoteKey: remoteKey,
|
remoteKey: remoteKey,
|
||||||
fundingAmt: fundingAmt,
|
fundingAmt: fundingAmt,
|
||||||
chanPoint: chanPoint,
|
chanPoint: chanPoint,
|
||||||
|
thawHeight: thawHeight,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,9 +179,10 @@ func (c *CannedAssembler) ProvisionChannel(req *Request) (Intent, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intent := &ShimIntent{
|
intent := &ShimIntent{
|
||||||
localKey: c.localKey,
|
localKey: c.localKey,
|
||||||
remoteKey: c.remoteKey,
|
remoteKey: c.remoteKey,
|
||||||
chanPoint: &c.chanPoint,
|
chanPoint: &c.chanPoint,
|
||||||
|
thawHeight: c.thawHeight,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.initiator {
|
if c.initiator {
|
||||||
|
@ -1545,7 +1545,7 @@ func newFundingShimAssembler(chanPointShim *lnrpc.ChanPointShim,
|
|||||||
// With all the parts assembled, we can now make the canned assembler
|
// With all the parts assembled, we can now make the canned assembler
|
||||||
// to pass into the wallet.
|
// to pass into the wallet.
|
||||||
return chanfunding.NewCannedAssembler(
|
return chanfunding.NewCannedAssembler(
|
||||||
*chanPoint, btcutil.Amount(chanPointShim.Amt),
|
0, *chanPoint, btcutil.Amount(chanPointShim.Amt),
|
||||||
&localKeyDesc, remoteKey, initiator,
|
&localKeyDesc, remoteKey, initiator,
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user