build+lncli: default to hex encoding for byte slices
This commit swaps out golang/protobuf/jsonpb for a custom variant that by default prints byte slices as hex, which is more useful for our setting. Some existing wrapper structs are removed as they can now be printed directly with the new jsonpb. !!! NOTE !!! This commit introduces a breaking change to lncli listinvoices since payment hashes and preimages will now be printed in hex instead of base64.
This commit is contained in:
9 files changed
+22
-149
No files matched your search
@@ -4,7 +4,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
|
||||
@@ -31,34 +30,7 @@ func queryMissionControl(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
type displayPairHistory struct {
|
||||
NodeFrom, NodeTo string
|
||||
SuccessTime, FailTime int64
|
||||
FailAmtSat, FailAmtMsat int64
|
||||
SuccessAmtSat, SuccessAmtMsat int64
|
||||
}
|
||||
|
||||
displayResp := struct {
|
||||
Pairs []displayPairHistory
|
||||
}{}
|
||||
|
||||
for _, n := range snapshot.Pairs {
|
||||
displayResp.Pairs = append(
|
||||
displayResp.Pairs,
|
||||
displayPairHistory{
|
||||
NodeFrom: hex.EncodeToString(n.NodeFrom),
|
||||
NodeTo: hex.EncodeToString(n.NodeTo),
|
||||
FailTime: n.History.FailTime,
|
||||
SuccessTime: n.History.SuccessTime,
|
||||
FailAmtSat: n.History.FailAmtSat,
|
||||
FailAmtMsat: n.History.FailAmtMsat,
|
||||
SuccessAmtSat: n.History.SuccessAmtSat,
|
||||
SuccessAmtMsat: n.History.SuccessAmtMsat,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
printJSON(displayResp)
|
||||
printRespJSON(snapshot)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user