Skip to content

Conversation

jamillambert
Copy link
Collaborator

@jamillambert jamillambert commented Aug 13, 2025

listaddressgroupings was untested.

  • Add a test for it that returns a non empty list. But now with this test there is an error because "when Serde deserializes from a JSON array (a sequence), it uses positional fields and requires the sequence length to match the number of struct fields exactly" (AI quote). Which causes an error when the optional field label is not returned.

  • Change the struct to an enum with 2 fields, one for 2 returned items and one for 3.

No changes to the RPC return fields up to v29.

`listaddressgroupings` was untested.

Add a test for it that returns a non emply list.

When Serde deserializes from a JSON array (a sequence), it uses 
positional fields and requires the sequence length to match the number 
of struct fields exactly. 

This causes an error when the optional field `label` is not returned.

Change the struct to an enum with 2 fields, one for 2 returned items 
and one for 3.
@jamillambert jamillambert force-pushed the 0813-listaddressgroupings branch from 8436521 to e76ab0d Compare August 13, 2025 20:13
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e76ab0d

@tcharding
Copy link
Member

Nice, you worked out the JSON shape, that stumped me.

@tcharding tcharding merged commit f8b7ff2 into rust-bitcoin:master Aug 14, 2025
30 checks passed
@jamillambert
Copy link
Collaborator Author

Nice, you worked out the JSON shape, that stumped me.

Yeah it was a strange one. I assumed it would work like the others and using an Option would take care of the field being there or not. I had no idea Serde worked like that with a JSON array. AI first tried to write this massive deserialization function just for that one case, and I had to argue with it for a bit.

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

Successfully merging this pull request may close these issues.

2 participants