mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 06:21:40 +01:00
channeldb+lnwallet: save initial balances during channel opening
This commit is contained in:
parent
291a8e4eff
commit
22f8f6ed4a
3 changed files with 22 additions and 7 deletions
|
@ -129,9 +129,9 @@ var (
|
|||
// bucket for a given channel.
|
||||
frozenChanKey = []byte("frozen-chans")
|
||||
|
||||
// lastWasRevokeKey is a key that stores true when the last update we sent
|
||||
// was a revocation and false when it was a commitment signature. This is
|
||||
// nil in the case of new channels with no updates exchanged.
|
||||
// lastWasRevokeKey is a key that stores true when the last update we
|
||||
// sent was a revocation and false when it was a commitment signature.
|
||||
// This is nil in the case of new channels with no updates exchanged.
|
||||
lastWasRevokeKey = []byte("last-was-revoke")
|
||||
)
|
||||
|
||||
|
@ -657,6 +657,15 @@ type OpenChannel struct {
|
|||
// received within this channel.
|
||||
TotalMSatReceived lnwire.MilliSatoshi
|
||||
|
||||
// InitialLocalBalance is the balance we have during the channel
|
||||
// opening. When we are not the initiator, this value represents the
|
||||
// push amount.
|
||||
InitialLocalBalance lnwire.MilliSatoshi
|
||||
|
||||
// InitialRemoteBalance is the balance they have during the channel
|
||||
// opening.
|
||||
InitialRemoteBalance lnwire.MilliSatoshi
|
||||
|
||||
// LocalChanCfg is the channel configuration for the local node.
|
||||
LocalChanCfg ChannelConfig
|
||||
|
||||
|
@ -3322,7 +3331,8 @@ func putChanInfo(chanBucket kvdb.RwBucket, channel *OpenChannel) error {
|
|||
channel.chanStatus, channel.FundingBroadcastHeight,
|
||||
channel.NumConfsRequired, channel.ChannelFlags,
|
||||
channel.IdentityPub, channel.Capacity, channel.TotalMSatSent,
|
||||
channel.TotalMSatReceived,
|
||||
channel.TotalMSatReceived, channel.InitialLocalBalance,
|
||||
channel.InitialRemoteBalance,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -3509,7 +3519,8 @@ func fetchChanInfo(chanBucket kvdb.RBucket, channel *OpenChannel) error {
|
|||
&channel.chanStatus, &channel.FundingBroadcastHeight,
|
||||
&channel.NumConfsRequired, &channel.ChannelFlags,
|
||||
&channel.IdentityPub, &channel.Capacity, &channel.TotalMSatSent,
|
||||
&channel.TotalMSatReceived,
|
||||
&channel.TotalMSatReceived, &channel.InitialLocalBalance,
|
||||
&channel.InitialRemoteBalance,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -352,6 +352,8 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
|
|||
Packager: NewChannelPackager(chanID),
|
||||
FundingTxn: channels.TestFundingTx,
|
||||
ThawHeight: uint32(defaultPendingHeight),
|
||||
InitialLocalBalance: lnwire.MilliSatoshi(9000),
|
||||
InitialRemoteBalance: lnwire.MilliSatoshi(3000),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -403,8 +403,10 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
|||
FeePerKw: btcutil.Amount(commitFeePerKw),
|
||||
CommitFee: commitFee,
|
||||
},
|
||||
ThawHeight: thawHeight,
|
||||
Db: wallet.Cfg.Database,
|
||||
ThawHeight: thawHeight,
|
||||
Db: wallet.Cfg.Database,
|
||||
InitialLocalBalance: ourBalance,
|
||||
InitialRemoteBalance: theirBalance,
|
||||
},
|
||||
pushMSat: pushMSat,
|
||||
pendingChanID: pendingChanID,
|
||||
|
|
Loading…
Add table
Reference in a new issue