rpcserver: update calls to adhere to new channeldb API's
This commit is contained in:
parent
a39825db3f
commit
8a69397714
34
rpcserver.go
34
rpcserver.go
@ -1038,8 +1038,8 @@ func (r *rpcServer) ListPeers(ctx context.Context,
|
|||||||
// peer.
|
// peer.
|
||||||
chans := serverPeer.ChannelSnapshots()
|
chans := serverPeer.ChannelSnapshots()
|
||||||
for _, c := range chans {
|
for _, c := range chans {
|
||||||
satSent += int64(c.TotalMilliSatoshisSent.ToSatoshis())
|
satSent += int64(c.TotalMSatSent.ToSatoshis())
|
||||||
satRecv += int64(c.TotalMilliSatoshisReceived.ToSatoshis())
|
satRecv += int64(c.TotalMSatReceived.ToSatoshis())
|
||||||
}
|
}
|
||||||
|
|
||||||
nodePub := serverPeer.addr.IdentityKey.SerializeCompressed()
|
nodePub := serverPeer.addr.IdentityKey.SerializeCompressed()
|
||||||
@ -1112,7 +1112,7 @@ func (r *rpcServer) ChannelBalance(ctx context.Context,
|
|||||||
var balance btcutil.Amount
|
var balance btcutil.Amount
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
if !channel.IsPending {
|
if !channel.IsPending {
|
||||||
balance += channel.LocalBalance.ToSatoshis()
|
balance += channel.LocalCommitment.LocalBalance.ToSatoshis()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1157,7 +1157,8 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
|||||||
// broadcast.
|
// broadcast.
|
||||||
// TODO(roasbeef): query for funding tx from wallet, display
|
// TODO(roasbeef): query for funding tx from wallet, display
|
||||||
// that also?
|
// that also?
|
||||||
utx := btcutil.NewTx(&pendingChan.CommitTx)
|
localCommitment := pendingChan.LocalCommitment
|
||||||
|
utx := btcutil.NewTx(localCommitment.CommitTx)
|
||||||
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
||||||
commitWeight := commitBaseWeight + lnwallet.WitnessCommitmentTxWeight
|
commitWeight := commitBaseWeight + lnwallet.WitnessCommitmentTxWeight
|
||||||
|
|
||||||
@ -1166,12 +1167,12 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
|||||||
RemoteNodePub: hex.EncodeToString(pub),
|
RemoteNodePub: hex.EncodeToString(pub),
|
||||||
ChannelPoint: pendingChan.FundingOutpoint.String(),
|
ChannelPoint: pendingChan.FundingOutpoint.String(),
|
||||||
Capacity: int64(pendingChan.Capacity),
|
Capacity: int64(pendingChan.Capacity),
|
||||||
LocalBalance: int64(pendingChan.LocalBalance.ToSatoshis()),
|
LocalBalance: int64(localCommitment.LocalBalance.ToSatoshis()),
|
||||||
RemoteBalance: int64(pendingChan.RemoteBalance.ToSatoshis()),
|
RemoteBalance: int64(localCommitment.RemoteBalance.ToSatoshis()),
|
||||||
},
|
},
|
||||||
CommitWeight: commitWeight,
|
CommitWeight: commitWeight,
|
||||||
CommitFee: int64(pendingChan.CommitFee),
|
CommitFee: int64(localCommitment.CommitFee),
|
||||||
FeePerKw: int64(pendingChan.FeePerKw),
|
FeePerKw: int64(localCommitment.FeePerKw),
|
||||||
// TODO(roasbeef): need to track confirmation height
|
// TODO(roasbeef): need to track confirmation height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1311,7 +1312,8 @@ func (r *rpcServer) ListChannels(ctx context.Context,
|
|||||||
// estimated weight of the witness to calculate the weight of
|
// estimated weight of the witness to calculate the weight of
|
||||||
// the transaction if it were to be immediately unilaterally
|
// the transaction if it were to be immediately unilaterally
|
||||||
// broadcast.
|
// broadcast.
|
||||||
utx := btcutil.NewTx(&dbChannel.CommitTx)
|
localCommit := dbChannel.LocalCommitment
|
||||||
|
utx := btcutil.NewTx(localCommit.CommitTx)
|
||||||
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
||||||
commitWeight := commitBaseWeight + lnwallet.WitnessCommitmentTxWeight
|
commitWeight := commitBaseWeight + lnwallet.WitnessCommitmentTxWeight
|
||||||
|
|
||||||
@ -1321,18 +1323,18 @@ func (r *rpcServer) ListChannels(ctx context.Context,
|
|||||||
ChannelPoint: chanPoint.String(),
|
ChannelPoint: chanPoint.String(),
|
||||||
ChanId: chanID,
|
ChanId: chanID,
|
||||||
Capacity: int64(dbChannel.Capacity),
|
Capacity: int64(dbChannel.Capacity),
|
||||||
LocalBalance: int64(dbChannel.LocalBalance.ToSatoshis()),
|
LocalBalance: int64(localCommit.LocalBalance.ToSatoshis()),
|
||||||
RemoteBalance: int64(dbChannel.RemoteBalance.ToSatoshis()),
|
RemoteBalance: int64(localCommit.RemoteBalance.ToSatoshis()),
|
||||||
CommitFee: int64(dbChannel.CommitFee),
|
CommitFee: int64(localCommit.CommitFee),
|
||||||
CommitWeight: commitWeight,
|
CommitWeight: commitWeight,
|
||||||
FeePerKw: int64(dbChannel.FeePerKw),
|
FeePerKw: int64(localCommit.FeePerKw),
|
||||||
TotalSatoshisSent: int64(dbChannel.TotalMSatSent.ToSatoshis()),
|
TotalSatoshisSent: int64(dbChannel.TotalMSatSent.ToSatoshis()),
|
||||||
TotalSatoshisReceived: int64(dbChannel.TotalMSatReceived.ToSatoshis()),
|
TotalSatoshisReceived: int64(dbChannel.TotalMSatReceived.ToSatoshis()),
|
||||||
NumUpdates: dbChannel.NumUpdates,
|
NumUpdates: localCommit.CommitHeight,
|
||||||
PendingHtlcs: make([]*lnrpc.HTLC, len(dbChannel.Htlcs)),
|
PendingHtlcs: make([]*lnrpc.HTLC, len(localCommit.Htlcs)),
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, htlc := range dbChannel.Htlcs {
|
for i, htlc := range localCommit.Htlcs {
|
||||||
channel.PendingHtlcs[i] = &lnrpc.HTLC{
|
channel.PendingHtlcs[i] = &lnrpc.HTLC{
|
||||||
Incoming: htlc.Incoming,
|
Incoming: htlc.Incoming,
|
||||||
Amount: int64(htlc.Amt),
|
Amount: int64(htlc.Amt),
|
||||||
|
Loading…
Reference in New Issue
Block a user