From 3602916783eaf4e55294abbc84471135b2888898 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 1 Feb 2024 23:47:30 -0500 Subject: [PATCH 1/2] Sending Lightning: Success: display preimage --- views/SendingLightning.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/SendingLightning.tsx b/views/SendingLightning.tsx index da933d209..24e7d8214 100644 --- a/views/SendingLightning.tsx +++ b/views/SendingLightning.tsx @@ -317,19 +317,19 @@ export default class SendingLightning extends React.Component< /> )} - {!!payment_hash && !error && !payment_error && ( + {!!payment_preimage && !error && !payment_error && ( )} From 1972361416103e46083ae7c0bda63170777ce823 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Mon, 5 Feb 2024 12:26:35 -0500 Subject: [PATCH 2/2] Sending Lightning: Success: display preimage - handle lndhub and null preimages --- models/Payment.ts | 16 +++++++++++++++- stores/TransactionsStore.ts | 10 ++++++++-- views/SendingLightning.tsx | 38 ++++++++++++++++++++----------------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/models/Payment.ts b/models/Payment.ts index 5096d58db..48de2208c 100644 --- a/models/Payment.ts +++ b/models/Payment.ts @@ -74,7 +74,21 @@ export default class Payment extends BaseModel { } @computed public get getPreimage(): string { - return this.preimage || this.payment_preimage; + if (this.preimage) { + if (this.preimage?.type === 'Buffer') { + this.preimage = Base64Utils.bytesToHex(this.preimage.data); + } + return this.preimage; + } + if (this.payment_preimage) { + if (this.payment_preimage?.type === 'Buffer') { + this.payment_preimage = Base64Utils.bytesToHex( + this.payment_preimage.data + ); + } + return this.payment_preimage; + } + return ''; } @computed public get isIncomplete(): boolean { diff --git a/stores/TransactionsStore.ts b/stores/TransactionsStore.ts index 60f1aaa1b..9836832b0 100644 --- a/stores/TransactionsStore.ts +++ b/stores/TransactionsStore.ts @@ -39,6 +39,7 @@ export default class TransactionsStore { @observable transaction: Transaction | null; @observable payment_route: any; // Route @observable payment_preimage: string | null; + @observable isIncomplete: boolean | null; @observable payment_hash: any; @observable payment_error: any; @observable onchain_address: string; @@ -70,6 +71,7 @@ export default class TransactionsStore { this.transaction = null; this.payment_route = null; this.payment_preimage = null; + this.isIncomplete = null; this.payment_hash = null; this.payment_error = null; this.onchain_address = ''; @@ -209,6 +211,7 @@ export default class TransactionsStore { this.error = false; this.payment_route = null; this.payment_preimage = null; + this.isIncomplete = null; this.payment_hash = null; this.payment_error = null; this.status = null; @@ -306,8 +309,11 @@ export default class TransactionsStore { public handlePayment = (result: any) => { this.loading = false; this.payment_route = result.payment_route; - this.payment_preimage = result.payment_preimage; - this.payment_hash = new Payment(result).paymentHash; + + const payment = new Payment(result); + this.payment_preimage = payment.getPreimage; + this.payment_hash = payment.paymentHash; + this.isIncomplete = payment.isIncomplete; const implementation = this.settingsStore.implementation; diff --git a/views/SendingLightning.tsx b/views/SendingLightning.tsx index 24e7d8214..a53656698 100644 --- a/views/SendingLightning.tsx +++ b/views/SendingLightning.tsx @@ -113,7 +113,8 @@ export default class SendingLightning extends React.Component< error_msg, payment_hash, payment_preimage, - payment_error + payment_error, + isIncomplete } = TransactionsStore; const { storedNotes } = this.state; @@ -317,22 +318,25 @@ export default class SendingLightning extends React.Component< /> )} - {!!payment_preimage && !error && !payment_error && ( - - - - )} + {!!payment_preimage && + !isIncomplete && + !error && + !payment_error && ( + + + + )} {