From 557204897a6fe1ecc66abdaad0e496023812b0c5 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 22 Mar 2020 10:29:22 +0100 Subject: [PATCH] fix(ui): display destination when sending keysend payments --- renderer/reducers/payment.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/renderer/reducers/payment.js b/renderer/reducers/payment.js index 25de79e58cd..712be6061a7 100644 --- a/renderer/reducers/payment.js +++ b/renderer/reducers/payment.js @@ -186,9 +186,10 @@ export const payInvoice = ({ retries = 0, originalPaymentId, }) => async dispatch => { - let paymentHash const paymentId = originalPaymentId || genId() const isKeysend = isPubkey(payReq) + let pubkey + let paymentHash let payload = { paymentId, @@ -202,11 +203,12 @@ export const payInvoice = ({ const defaultCltvDelta = 43 const keySendPreimageType = '5482373484' const preimageByteLength = 32 + const preimage = randomBytes(preimageByteLength) - const secret = preimage.toString('hex') paymentHash = createHash('sha256') .update(preimage) .digest() + pubkey = payReq payload = { ...payload, @@ -214,7 +216,7 @@ export const payInvoice = ({ final_cltv_delta: defaultCltvDelta, dest: Buffer.from(payReq, 'hex'), dest_custom_records: { - [keySendPreimageType]: Buffer.from(secret, 'hex'), + [keySendPreimageType]: preimage, }, } } @@ -223,10 +225,11 @@ export const payInvoice = ({ else { const invoice = decodePayReq(payReq) paymentHash = getTag(invoice, 'payment_hash') + pubkey = invoice.payeeNodeKey payload = { ...payload, - payment_request: payReq, + payment_request: invoice.payeeNodeKey, } } @@ -237,8 +240,9 @@ export const payInvoice = ({ } else { dispatch( sendPayment({ - paymentId, + path: [pubkey], paymentHash, + paymentId, feeLimit, value: amt, remainingRetries: retries,