From fffe15f0fd60a76dfcf2916b1330c5c6b66cfee1 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 13 Nov 2017 17:15:27 -0800 Subject: [PATCH] lnwallet: add FundingFlag parameter to InitChannelReservation --- lnwallet/reservation.go | 14 ++++++++------ lnwallet/wallet.go | 10 ++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lnwallet/reservation.go b/lnwallet/reservation.go index e10acd09..51f91298 100644 --- a/lnwallet/reservation.go +++ b/lnwallet/reservation.go @@ -137,7 +137,8 @@ type ChannelReservation struct { // lnwallet.InitChannelReservation interface. func NewChannelReservation(capacity, fundingAmt, commitFeePerKw btcutil.Amount, wallet *LightningWallet, id uint64, pushMSat lnwire.MilliSatoshi, - chainHash *chainhash.Hash) (*ChannelReservation, error) { + chainHash *chainhash.Hash, + flags lnwire.FundingFlag) (*ChannelReservation, error) { var ( ourBalance lnwire.MilliSatoshi @@ -219,11 +220,12 @@ func NewChannelReservation(capacity, fundingAmt, commitFeePerKw btcutil.Amount, ChannelConfig: &channeldb.ChannelConfig{}, }, partialState: &channeldb.OpenChannel{ - ChanType: chanType, - ChainHash: *chainHash, - IsPending: true, - IsInitiator: initiator, - Capacity: capacity, + ChanType: chanType, + ChainHash: *chainHash, + IsPending: true, + IsInitiator: initiator, + ChannelFlags: flags, + Capacity: capacity, LocalCommitment: channeldb.ChannelCommitment{ LocalBalance: ourBalance, RemoteBalance: theirBalance, diff --git a/lnwallet/wallet.go b/lnwallet/wallet.go index dbc851ed..446ee6de 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -108,6 +108,10 @@ type initFundingReserveMsg struct { // the responder as part of the initial channel creation. pushMSat lnwire.MilliSatoshi + // flags are the channel flags specified by the initiator in the + // open_channel message. + flags lnwire.FundingFlag + // err is a channel in which all errors will be sent across. Will be // nil if this initial set is successful. // @@ -449,7 +453,7 @@ func (l *LightningWallet) InitChannelReservation( capacity, ourFundAmt btcutil.Amount, pushMSat lnwire.MilliSatoshi, commitFeePerKw, fundingFeePerWeight btcutil.Amount, theirID *btcec.PublicKey, theirAddr *net.TCPAddr, - chainHash *chainhash.Hash) (*ChannelReservation, error) { + chainHash *chainhash.Hash, flags lnwire.FundingFlag) (*ChannelReservation, error) { errChan := make(chan error, 1) respChan := make(chan *ChannelReservation, 1) @@ -463,6 +467,7 @@ func (l *LightningWallet) InitChannelReservation( commitFeePerKw: commitFeePerKw, fundingFeePerWeight: fundingFeePerWeight, pushMSat: pushMSat, + flags: flags, err: errChan, resp: respChan, } @@ -493,7 +498,8 @@ func (l *LightningWallet) handleFundingReserveRequest(req *initFundingReserveMsg id := atomic.AddUint64(&l.nextFundingID, 1) reservation, err := NewChannelReservation(req.capacity, req.fundingAmount, - req.commitFeePerKw, l, id, req.pushMSat, l.Cfg.NetParams.GenesisHash) + req.commitFeePerKw, l, id, req.pushMSat, + l.Cfg.NetParams.GenesisHash, req.flags) if err != nil { req.err <- err req.resp <- nil