Skip to content

Commit

Permalink
display keysend messages like memos in activity and payment
Browse files Browse the repository at this point in the history
  • Loading branch information
myxmaster committed Dec 16, 2024
1 parent 5d265b4 commit 4c92a6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions models/Payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Base64Utils from '../utils/Base64Utils';
import { lnrpc } from '../proto/lightning';
import { notesStore } from '../stores/storeInstances';

const keySendMessageType = '34349334';

interface preimageBuffer {
data: Array<number>;
type: string;
Expand Down Expand Up @@ -79,17 +81,23 @@ export default class Payment extends BaseModel {
}

@computed public get getMemo(): string | undefined {
if (this.getPaymentRequest) {
if (
this.htlcs?.[0]?.route?.hops?.[0]?.custom_records?.[
keySendMessageType
]
) {
const customRecords = this.htlcs[0].route.hops[0].custom_records;
return Base64Utils.base64ToUtf8(customRecords[keySendMessageType]);
} else if (this.getPaymentRequest) {
try {
const decoded: any = bolt11.decode(this.getPaymentRequest);
for (let i = 0; i < decoded.tags.length; i++) {
const tag = decoded.tags[i];
switch (tag.tagName) {
case 'description':
return tag.data;
}
if (tag.tagName === 'description') return tag.data;
}
} catch (e) {}
} catch (e) {
console.log('Error decoding payment request:', e);
}
}
return undefined;
}
Expand Down
6 changes: 3 additions & 3 deletions views/Activity/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ export default class Activity extends React.PureComponent<
subTitle = (
<Text>
{localeString('general.lightning')}
{item.memo ? ': ' : ''}
{item.memo ? (
{item.getMemo ? ': ' : ''}
{item.getMemo ? (
<Text
style={{ fontStyle: 'italic' }}
>
{item.memo}
{item.getMemo}
</Text>
) : (
''
Expand Down

0 comments on commit 4c92a6f

Please sign in to comment.