From ab718d67011b4f4b07e9175ff577cba30acde279 Mon Sep 17 00:00:00 2001 From: Hugh Cunningham <57735705+hughy@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:23:01 -0700 Subject: [PATCH] adds memoHex to RpcWalletNote (#4860) the 'memo' included with each note is modified to remove non-human-readable characters. if the memo included in the note is encoding data then this can make it impossible to recover the data from the rpc response. adds memoHex to return the memo as a hex string to preserve memo data in wallet rpc responses --- ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts | 1 + ironfish/src/rpc/routes/wallet/getAccountTransaction.test.ts | 3 +++ ironfish/src/rpc/routes/wallet/types.ts | 2 ++ ironfish/src/rpc/routes/wallet/utils.ts | 1 + 4 files changed, 7 insertions(+) diff --git a/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts b/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts index 82a53f64c6..a078bfa2f1 100644 --- a/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts +++ b/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts @@ -50,6 +50,7 @@ routes.register { })), ) expect(responseTransaction.notes).toHaveLength(transaction.notes.length) + + // each note should include a hex representation of the memo in memoHex + responseTransaction.notes?.map((note) => expect(note.memoHex).toBeDefined()) }) }) diff --git a/ironfish/src/rpc/routes/wallet/types.ts b/ironfish/src/rpc/routes/wallet/types.ts index ea1b6b5257..07516b026b 100644 --- a/ironfish/src/rpc/routes/wallet/types.ts +++ b/ironfish/src/rpc/routes/wallet/types.ts @@ -50,6 +50,7 @@ export type RpcWalletNote = { assetId: string value: string memo: string + memoHex: string sender: string owner: string noteHash: string @@ -77,6 +78,7 @@ export const RpcWalletNoteSchema: yup.ObjectSchema = yup assetId: yup.string().defined(), assetName: yup.string().defined(), memo: yup.string().defined(), + memoHex: yup.string().defined(), sender: yup.string().defined(), owner: yup.string().defined(), noteHash: yup.string().defined(), diff --git a/ironfish/src/rpc/routes/wallet/utils.ts b/ironfish/src/rpc/routes/wallet/utils.ts index e4c19c1e6b..f850eb25a0 100644 --- a/ironfish/src/rpc/routes/wallet/utils.ts +++ b/ironfish/src/rpc/routes/wallet/utils.ts @@ -248,6 +248,7 @@ export function serializeRpcWalletNote( assetId: note.note.assetId().toString('hex'), assetName: asset?.name.toString('hex') || '', memo: BufferUtils.toHuman(note.note.memo()), + memoHex: note.note.memo().toString('hex'), owner: note.note.owner(), sender: note.note.sender(), noteHash: note.note.hash().toString('hex'),