Merge pull request #1390 from Roasbeef/sorted-closed-channels
rpc: sort closed channels in order of ascending height
This commit is contained in:
commit
aeca4d6def
13
rpcserver.go
13
rpcserver.go
@ -9,6 +9,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -1137,8 +1138,9 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
// the htlc switch which will handle the negotiation and
|
// the htlc switch which will handle the negotiation and
|
||||||
// broadcast details.
|
// broadcast details.
|
||||||
feePerKw := feeRate.FeePerKWeight()
|
feePerKw := feeRate.FeePerKWeight()
|
||||||
updateChan, errChan = r.server.htlcSwitch.CloseLink(chanPoint,
|
updateChan, errChan = r.server.htlcSwitch.CloseLink(
|
||||||
htlcswitch.CloseRegular, feePerKw)
|
chanPoint, htlcswitch.CloseRegular, feePerKw,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
for {
|
for {
|
||||||
@ -1600,6 +1602,13 @@ func (r *rpcServer) ClosedChannels(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In order to make the response easier to parse for clients, we'll
|
||||||
|
// sort the set of closed channels by their closing height before
|
||||||
|
// serializing the proto response.
|
||||||
|
sort.Slice(dbChannels, func(i, j int) bool {
|
||||||
|
return dbChannels[i].CloseHeight < dbChannels[j].CloseHeight
|
||||||
|
})
|
||||||
|
|
||||||
for _, dbChannel := range dbChannels {
|
for _, dbChannel := range dbChannels {
|
||||||
if dbChannel.IsPending {
|
if dbChannel.IsPending {
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user