From 03eba4d152b12642f1d3343668fc6ba9288ba277 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 1 Feb 2024 23:37:18 -0500 Subject: [PATCH] Activity: Payment: include destination --- locales/en.json | 1 + models/Payment.ts | 15 +++++++++++++++ views/Channels/Channel.tsx | 6 +++--- views/Payment.tsx | 31 +++++++++++++++++++++++++++---- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/locales/en.json b/locales/en.json index bd808ded8..4dede0788 100644 --- a/locales/en.json +++ b/locales/en.json @@ -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", diff --git a/models/Payment.ts b/models/Payment.ts index 5096d58db..275212605 100644 --- a/models/Payment.ts +++ b/models/Payment.ts @@ -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); diff --git a/views/Channels/Channel.tsx b/views/Channels/Channel.tsx index 0aebad141..c724e1915 100644 --- a/views/Channels/Channel.tsx +++ b/views/Channels/Channel.tsx @@ -311,7 +311,7 @@ export default class ChannelView extends React.Component< UrlUtils.goToBlockExplorerBlockHeight( @@ -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, @@ -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, diff --git a/views/Payment.tsx b/views/Payment.tsx index d9809424f..7a844db84 100644 --- a/views/Payment.tsx +++ b/views/Payment.tsx @@ -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 { state = { @@ -68,8 +72,9 @@ export default class PaymentView extends React.Component { } 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 = @@ -82,6 +87,7 @@ export default class PaymentView extends React.Component { getFeePercentage, paymentHash, getPreimage, + getDestination, enhancedPath, getMemo, isIncomplete, @@ -181,6 +187,23 @@ export default class PaymentView extends React.Component { /> )} + {getDestination && ( + + UrlUtils.goToBlockExplorerPubkey( + getDestination, + testnet + ) + } + /> + )} + {paymentHash && (