Skip to content

Commit 319a0ee

Browse files
authored
Merge pull request #9493 from ziggie1984/lncli-no-replacement
For some lncli cmds we should not replace the content with other data
2 parents 2ec9720 + 3562767 commit 319a0ee

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

cmd/commands/cmd_payments.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ func queryRoutes(ctx *cli.Context) error {
12541254
}
12551255

12561256
printRespJSON(route)
1257+
12571258
return nil
12581259
}
12591260

cmd/commands/commands.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,29 @@ func printJSON(resp interface{}) {
212212
_, _ = out.WriteTo(os.Stdout)
213213
}
214214

215+
// printRespJSON prints the response in a json format.
215216
func printRespJSON(resp proto.Message) {
216217
jsonBytes, err := lnrpc.ProtoJSONMarshalOpts.Marshal(resp)
217218
if err != nil {
218219
fmt.Println("unable to decode response: ", err)
219220
return
220221
}
221222

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+
222238
// Replace custom_channel_data in the JSON.
223239
jsonBytesReplaced := replaceCustomData(jsonBytes)
224240

@@ -1853,7 +1869,7 @@ func ListChannels(ctx *cli.Context) error {
18531869
return err
18541870
}
18551871

1856-
printRespJSON(resp)
1872+
printModifiedProtoJSON(resp)
18571873

18581874
return nil
18591875
}
@@ -1915,7 +1931,7 @@ func closedChannels(ctx *cli.Context) error {
19151931
return err
19161932
}
19171933

1918-
printRespJSON(resp)
1934+
printModifiedProtoJSON(resp)
19191935

19201936
return nil
19211937
}

0 commit comments

Comments
 (0)