Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated keys in JSON rpc interface. #3281

Closed
m-schmoock opened this issue Nov 21, 2019 · 1 comment
Closed

Duplicated keys in JSON rpc interface. #3281

m-schmoock opened this issue Nov 21, 2019 · 1 comment

Comments

@m-schmoock
Copy link
Collaborator

m-schmoock commented Nov 21, 2019

Issue and Steps to Reproduce

I saw that the command outputs duplicated config entries (i.e. the "plugin" switch) as duplicated keys in the JSON output. This is only more or less valid, while the formal specification allows this, all the implementations complain about it and most will filter out duplicated entries by picking the first or last one. We can see this by pushing the output of listconfigs through the neat command-line tool jq:

lightning-cli listconfigs
 lightning-cli listconfigs
{
   "# version": "v0.7.3",
   "lightning-dir": "/home/btc/.lightning",
   "wallet": "sqlite3:///home/btc/.lightning/lightningd.sqlite3",
   "plugin": "/home/btc/lightning.git/lightningd/../plugins/pay",
   "plugin": "/home/btc/lightning.git/lightningd/../plugins/autoclean",
   "plugin": "/home/btc/lightning.git/lightningd/../plugins/fundchannel",
   "..." : "..."
}

lightning-cli listconfigs | jq
{
  "# version": "v0.7.3",
  "lightning-dir": "/home/btc/.lightning",
  "wallet": "sqlite3:///home/btc/.lightning/lightningd.sqlite3",
  "plugin": "/home/btc/.lightning/plugins/summary/summary.py",
  "network": "bitcoin",
  "..." : "..."
}

Impact

External applications that are using the RPC interface (such as web interfaces, remote wallets, ...) will have a hard time to access the duplicated entries when their JSON library do not support this.

Suggestion

We could replace duplicated keys by just one key having an array of the the values that were duplicated, example:

{
   "# version": "v0.7.3",
   "lightning-dir": "/home/btc/.lightning",
   "wallet": "sqlite3:///home/btc/.lightning/lightningd.sqlite3",
   "plugin": [
      "/home/btc/lightning.git/lightningd/../plugins/pay",
      "/home/btc/lightning.git/lightningd/../plugins/autoclean",
      "/home/btc/lightning.git/lightningd/../plugins/fundchannel",
      "..."
   ],
   "network": "bitcoin",
   "..." : "..."
}

Considerations

  • Backwards compatibility may be affected, though a lot of applications were missing out the duplicates anyway already.
  • We could add an RPC switch, for example something like --json-normalize, that will post-process the JSON output and collects duplicates by putting them into an array. This way we don't break backwards compatibility while offering a solution to users that otherwise can't see the duplicated values...
@m-schmoock
Copy link
Collaborator Author

This is likely related to #3206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant