File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1254,6 +1254,7 @@ func queryRoutes(ctx *cli.Context) error {
1254
1254
}
1255
1255
1256
1256
printRespJSON (route )
1257
+
1257
1258
return nil
1258
1259
}
1259
1260
Original file line number Diff line number Diff line change @@ -212,13 +212,29 @@ func printJSON(resp interface{}) {
212
212
_ , _ = out .WriteTo (os .Stdout )
213
213
}
214
214
215
+ // printRespJSON prints the response in a json format.
215
216
func printRespJSON (resp proto.Message ) {
216
217
jsonBytes , err := lnrpc .ProtoJSONMarshalOpts .Marshal (resp )
217
218
if err != nil {
218
219
fmt .Println ("unable to decode response: " , err )
219
220
return
220
221
}
221
222
223
+ // Make the custom data human readable.
224
+ jsonBytesReplaced := replaceCustomData (jsonBytes )
225
+
226
+ fmt .Printf ("%s\n " , jsonBytesReplaced )
227
+ }
228
+
229
+ // printModifiedProtoJSON prints the response with some additional formatting
230
+ // and replacements.
231
+ func printModifiedProtoJSON (resp proto.Message ) {
232
+ jsonBytes , err := lnrpc .ProtoJSONMarshalOpts .Marshal (resp )
233
+ if err != nil {
234
+ fmt .Println ("unable to decode response: " , err )
235
+ return
236
+ }
237
+
222
238
// Replace custom_channel_data in the JSON.
223
239
jsonBytesReplaced := replaceCustomData (jsonBytes )
224
240
@@ -1853,7 +1869,7 @@ func ListChannels(ctx *cli.Context) error {
1853
1869
return err
1854
1870
}
1855
1871
1856
- printRespJSON (resp )
1872
+ printModifiedProtoJSON (resp )
1857
1873
1858
1874
return nil
1859
1875
}
@@ -1915,7 +1931,7 @@ func closedChannels(ctx *cli.Context) error {
1915
1931
return err
1916
1932
}
1917
1933
1918
- printRespJSON (resp )
1934
+ printModifiedProtoJSON (resp )
1919
1935
1920
1936
return nil
1921
1937
}
You can’t perform that action at this time.
0 commit comments