Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display keysend messages like memos in Activity and Payment #2634

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading