Nyzo version 609 (commit on GitHub) adds an amount option to Nyzo prefilled-data strings.
This version affects the client.
Nyzo prefilled-data strings were originally created to allow recipients to bundle a data field with their receiver identifier. This is especially useful for exchanges, which can use the data field to identify an account within the exchange. It would also be useful for many purchase scenarios, allowing bundling of an invoice identifier or other reference number.
A community member suggested in a GitHub issue that adding an amount option to prefilled-data strings would be useful. This version implements that suggestion.
In CommandEndpointApi, the command is now wrapped in a try/catch. This allows the endpoint to produce a result even if the command fails with an exception.
In future versions, CommandEndpointApi should perform proper validation of arguments and return the validation results in the response.
In PrefilledDataCreateCommand, an optional field for amount was added.
When sender data is validated in PrefilledDataCreateCommand.validate() the truncation warning is now attached to the validation result instead of being written to the output.
The amount is now validated, producing a warning if an unparseable value is provided.
In the PrefilledDataCreateCommand.run() method, the amount is now processed, included in the prefilled-data string, and written to the output table.
In PrefilledDataSendCommand, the amount is now indicated as optional if an amount is included in the prefilled-data string.
In PrefilledDataSendCommand.validate() the amount is now fetched from the prefilled-data string. For backwards compatibility, strings without an amount specified behave as having an amount of 0.
When processing the amount in PrefilledDataSendCommand.validate(), the amount from the prefilled-data string is used as a fallback if a valid amount is not specified as an argument to the command.
In PrefilledDataSendCommand.run(), the same behavior applies. If the amount is not specified in a command argument, or if the amount specified is invalid, then the amount from the prefilled-data string is used.
In NyzoStringPrefilledData, a field for amount was added.
In the byte encoding of the prefilled-data string, the most significant bit of the sender-data length field is now used to encode the presence or absence of an amount. This makes all existing prefilled-data strings compatible with the new code.
When decoding a prefilled-data string from bytes, the amount is now considered also. The comments explain in more detail how the bits of the sender-data length field are used.
The NyzoStringPrefilledData.toString() method was added to improve debuggability.
In NyzoStringTest.testPrefilledDataStrings(), amounts are now populated and tested.