Skip to content

cli: Support extracting sub-fields with jq-like queries #433

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

Open
leighmcculloch opened this issue Apr 28, 2025 · 1 comment
Open

cli: Support extracting sub-fields with jq-like queries #433

leighmcculloch opened this issue Apr 28, 2025 · 1 comment

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Apr 28, 2025

It would be really helpful if the stellar-xdr cli supported when decoding extracting subfields.

For example, the other day I was trying to get the memo extracted of a transaction, and I wanted to view the raw bytes of just that one field in the XDR. I was sort of able to do it with the following, but it was a pretty imperfect experience. I had to decode the entire tx, then re-encode the field I wanted to see in binary. I couldn't actually encode the field I wanted, the .text subfield of memo, because it has no named type. The best I could do was re-encode the memo field which wraps the text field.

$ curl -sSL https://horizon.stellar.org/transactions/1a0d08578d973892ef99e46c6a33882e231eb17a8c4f503487b996bb17982b57 \
    | jq -r '.envelope_xdr' \
    | stellar xdr decode --type TransactionEnvelope \
    | jq -r '.tx.tx.memo' \
    | stellar xdr encode --type Memo --output single \
    | xxd
00000000: 0000 0001 0000 000c d349 1c68 30d6 13e6  .........I.h0...
00000010: 28db 168d                                (...

The experience should be something like:

$ curl -sSL https://horizon.stellar.org/transactions/1a0d08578d973892ef99e46c6a33882e231eb17a8c4f503487b996bb17982b57 \
    | jq -r '.envelope_xdr' \
    | stellar xdr decode --type TransactionEnvelope --query '.tx.tx.memo.text' --output single-binary \
    | xxd
00000000: 0000 000c d349 1c68 30d6 13e6 28db 168d  .....I.h0...(...

Ref to offline conversation:

cc @stellar/devx

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Apr 28, 2025
@leighmcculloch
Copy link
Member Author

leighmcculloch commented Apr 29, 2025

Cursory look at how we might do this suggests this might be a pretty big lift to the point that the effort might outsize the value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog (Not Ready)
Development

No branches or pull requests

1 participant