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

Activity: Payment: include destination #1969

Merged
merged 1 commit into from
Feb 5, 2024
Merged
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
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
"views.Payment.fee": "Fee",
"views.Payment.paymentHash": "Payment Hash",
"views.Payment.paymentPreimage": "Payment Preimage",
"views.Payment.destination": "Destination",
"views.Payment.creationDate": "Creation Date",
"views.Payment.path": "Path",
"views.Payment.paths": "Paths",
Expand Down
15 changes: 15 additions & 0 deletions models/Payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ export default class Payment extends BaseModel {
return this.payment_request || this.bolt11;
}

@computed public get getDestination(): string | undefined {
if (this.destination) return this.destination;
const pay_req = this.getPaymentRequest;
if (pay_req) {
try {
const decoded = bolt11.decode(pay_req);
return decoded.payeeNodeKey;
} catch {
return undefined;
}
} else {
return undefined;
}
}

@computed public get getMemo(): string | undefined {
if (this.getPaymentRequest) {
const decoded: any = bolt11.decode(this.getPaymentRequest);
Expand Down
6 changes: 3 additions & 3 deletions views/Channels/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export default class ChannelView extends React.Component<
<KeyValue
keyValue={localeString('views.Channel.closeHeight')}
value={closeHeight}
color={themeColor('chain')}
color={themeColor('highlight')}
sensitive
mempoolLink={() =>
UrlUtils.goToBlockExplorerBlockHeight(
Expand Down Expand Up @@ -351,7 +351,7 @@ export default class ChannelView extends React.Component<
keyValue={localeString('views.Channel.closingTxId')}
value={closing_txid}
sensitive
color={themeColor('chain')}
color={themeColor('highlight')}
mempoolLink={() =>
UrlUtils.goToBlockExplorerTXID(
closing_txid,
Expand All @@ -367,7 +367,7 @@ export default class ChannelView extends React.Component<
)}
value={closing_tx_hash}
sensitive
color={themeColor('chain')}
color={themeColor('highlight')}
mempoolLink={() =>
UrlUtils.goToBlockExplorerTXID(
closing_tx_hash,
Expand Down
31 changes: 27 additions & 4 deletions views/Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,33 @@ import { inject, observer } from 'mobx-react';

import { Row } from '../components/layout/Row';
import Amount from '../components/Amount';
import Button from '../components/Button';
import Header from '../components/Header';
import KeyValue from '../components/KeyValue';
import Screen from '../components/Screen';

import Payment from '../models/Payment';
import { localeString } from '../utils/LocaleUtils';
import { themeColor } from '../utils/ThemeUtils';
import UrlUtils from '../utils/UrlUtils';

import Payment from '../models/Payment';

import LnurlPayStore from '../stores/LnurlPayStore';
import NodeInfoStore from '../stores/NodeInfoStore';
import SettingsStore from '../stores/SettingsStore';

import LnurlPayHistorical from './LnurlPay/Historical';

import EditNotes from '../assets/images/SVG/Pen.svg';
import Button from '../components/Button';

interface PaymentProps {
navigation: any;
LnurlPayStore?: LnurlPayStore;
NodeInfoStore?: NodeInfoStore;
SettingsStore?: SettingsStore;
}

@inject('LnurlPayStore', 'SettingsStore')
@inject('LnurlPayStore', 'NodeInfoStore', 'SettingsStore')
@observer
export default class PaymentView extends React.Component<PaymentProps> {
state = {
Expand Down Expand Up @@ -68,8 +72,9 @@ export default class PaymentView extends React.Component<PaymentProps> {
}

render() {
const { navigation, SettingsStore } = this.props;
const { navigation, SettingsStore, NodeInfoStore } = this.props;
const { storedNotes, lnurlpaytx } = this.state;
const { testnet } = NodeInfoStore;

const payment: Payment = navigation.getParam('payment', null);
const formattedOriginalTimeUntilExpiry =
Expand All @@ -82,6 +87,7 @@ export default class PaymentView extends React.Component<PaymentProps> {
getFeePercentage,
paymentHash,
getPreimage,
getDestination,
enhancedPath,
getMemo,
isIncomplete,
Expand Down Expand Up @@ -181,6 +187,23 @@ export default class PaymentView extends React.Component<PaymentProps> {
/>
)}

{getDestination && (
<KeyValue
keyValue={localeString(
'views.Payment.destination'
)}
value={getDestination}
sensitive
color={themeColor('highlight')}
mempoolLink={() =>
UrlUtils.goToBlockExplorerPubkey(
getDestination,
testnet
)
}
/>
)}

{paymentHash && (
<KeyValue
keyValue={localeString(
Expand Down
Loading