Skip to content

Commit

Permalink
adds memoHex to RpcWalletNote (#4860)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hughy authored Mar 27, 2024
1 parent ca1029b commit ab718d6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ routes.register<typeof GetAccountNotesStreamRequestSchema, GetAccountNotesStream
assetId: note.assetId().toString('hex'),
assetName: asset?.name.toString('hex') || '',
memo: BufferUtils.toHuman(note.memo()),
memoHex: note.memo().toString('hex'),
sender: note.sender(),
owner: note.owner(),
noteHash: note.hash().toString('hex'),
Expand Down
3 changes: 3 additions & 0 deletions ironfish/src/rpc/routes/wallet/getAccountTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ describe('Route wallet/getAccountTransaction', () => {
})),
)
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())
})
})
2 changes: 2 additions & 0 deletions ironfish/src/rpc/routes/wallet/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type RpcWalletNote = {
assetId: string
value: string
memo: string
memoHex: string
sender: string
owner: string
noteHash: string
Expand Down Expand Up @@ -77,6 +78,7 @@ export const RpcWalletNoteSchema: yup.ObjectSchema<RpcWalletNote> = 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(),
Expand Down
1 change: 1 addition & 0 deletions ironfish/src/rpc/routes/wallet/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit ab718d6

Please sign in to comment.