multi: remove function BalancesAtHeight

This commit deletes the function `BalancesAtHeight` since its only
usague is to find the push amount, which can be achieved by saving the
initial balances.
Another reason to remove it is to pave the way to incooperate our new
revocation log. If we ever need this function again, we can add it back
by visiting all the revocation logs to calculate the balances at a given
height.
This commit is contained in:
yyforyongyu
2022-04-08 04:27:26 +08:00
parent 7eaf0d0089
commit f42d1f2d62
4 changed files with 24 additions and 249 deletions

View File

@@ -4080,21 +4080,13 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
channel.UnsettledBalance += channel.PendingHtlcs[i].Amount
}
// Lookup our balances at height 0, because they will reflect any
// push amounts that may have been present when this channel was
// created.
localBalance, remoteBalance, err := dbChannel.BalancesAtHeight(0)
if err != nil {
return nil, err
}
// If we initiated opening the channel, the zero height remote balance
// is the push amount. Otherwise, our starting balance is the push
// amount. If there is no push amount, these values will simply be zero.
if dbChannel.IsInitiator {
channel.PushAmountSat = uint64(remoteBalance.ToSatoshis())
channel.PushAmountSat = uint64(dbChannel.InitialRemoteBalance)
} else {
channel.PushAmountSat = uint64(localBalance.ToSatoshis())
channel.PushAmountSat = uint64(dbChannel.InitialLocalBalance)
}
if len(dbChannel.LocalShutdownScript) > 0 {