xrpl.js
xrpl.js copied to clipboard
[Improvement] Add additional checks for Memo field
When crafting a new transaction and adding Memo(s), it can happen that one does put UTF8 encoded strings in the memo fields. But the XRP Ledger actually requires HEX encoded data.
If one puts UTF8 data in the Memo fields, the transaction will fail before being submitted. But from the shown error it can not be determined what the problem is.
An example transaction is:
{ "TransactionType":"Payment", "Account":"rbKLnSN2GkKKH8CLhAmtVoxZjoi9dpPev", "Amount":"200000", "Destination":"rDnhsNYVoHGNZQ9Dx5oLqSaXTKH8dcByZW", "Memos":[ {"Memo":{"MemoType":"ChristmasTree","MemoData":"IoT christmas tree"}}, {"Memo":{"MemoType":"TreeWasShiningFor","MemoData":"4 minutes"}}, {"Memo":{"MemoType":"Sending","MemoData":"0.2 XRP to @XRP_IoT_Tree -> (0.05 XRP per minute)"}} ] }
and the error xrpl.js throws is:
2 improvements could be made:
- improve the error message to give a hint what the problem could be
- add validators for the Memo fields which check if the input string is actually HEX encoded
Best, nixer