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

types: Replace expression-based SpendPolicy JSON marshalling #182

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

lukechampine
Copy link
Member

The expression-based SpendPolicy encoding is more compact and easier to read, but using it as the standard JSON encoding means that all clients have to write a custom rule, which is annoying. Since most users won't be looking at raw JSON anyway, we might as well make life a bit easier for our devs by switch to a more conventional structural encoding.
(Note, however, that we still intend to use the expression-based encoding when displaying policies in UIs.)

Thanks to @Alrighttt for surfacing this.

Old:

thresh(2, [
  above(100),
  pk(0x111d2995afa8bf162180a647b9f1eb6a275fe8818e836b69b351871d5caf9c590ed25aec0616),
  thresh(2, [
    above(200),
    pk(0x111d2995afa8bf162180a647b9f1eb6a275fe8818e836b69b351871d5caf9c590ed25aec0616),
  ]),
]),

New:

{
  "type": "thresh",
  "policy": {
    "n": 2,
    "of": [
      {
        "type": "above",
        "policy": 100
      },
      {
        "type": "pk",
        "policy": "ed25519:111d2995afa8bf162180a647b9f1eb6a275fe8818e836b69b351871d5caf9c590ed25aec0616"
      },
      {
        "type": "thresh",
        "policy": {
          "n": 2,
          "of": [
            {
              "type": "above",
              "policy": 200
            },
            {
              "type": "pk",
              "policy": "ed25519:111d2995afa8bf162180a647b9f1eb6a275fe8818e836b69b351871d5caf9c590ed25aec0616"
            }
          ]
        }
      }
    ]
  }
}

@n8maninger n8maninger self-requested a review July 16, 2024 15:28
@n8maninger n8maninger merged commit 749090b into master Jul 16, 2024
9 checks passed
@n8maninger n8maninger deleted the json-policy branch July 16, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants