Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 13db55a

Browse files
committed
Do not navigate to success/fail screen after timeout
1 parent 33c37e4 commit 13db55a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/action/payment.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ class PaymentAction {
170170
* @return {Promise<undefined>}
171171
*/
172172
async payLightning() {
173-
const to = setTimeout(() => this._nav.goPaymentFailed(), PAYMENT_TIMEOUT);
173+
let failed = false;
174+
const timeout = setTimeout(() => {
175+
failed = true;
176+
this._nav.goPaymentFailed();
177+
}, PAYMENT_TIMEOUT);
174178
try {
175179
this._nav.goWait();
176180
const invoice = this._store.payment.address.replace(PREFIX_URI, '');
@@ -186,12 +190,14 @@ class PaymentAction {
186190
stream.on('error', reject);
187191
stream.write(JSON.stringify({ payment_request: invoice }), 'utf8');
188192
});
193+
if (failed) return;
189194
this._nav.goPayLightningDone();
190195
} catch (err) {
196+
if (failed) return;
191197
this._nav.goPayLightningConfirm();
192198
this._notification.display({ msg: 'Lightning payment failed!', err });
193199
} finally {
194-
clearTimeout(to);
200+
clearTimeout(timeout);
195201
}
196202
}
197203
}

0 commit comments

Comments
 (0)