Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(ui): display destination when sending keysend payments
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Mar 24, 2020
1 parent fa894ba commit 5572048
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions renderer/reducers/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -202,19 +203,20 @@ 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,
payment_hash: paymentHash,
final_cltv_delta: defaultCltvDelta,
dest: Buffer.from(payReq, 'hex'),
dest_custom_records: {
[keySendPreimageType]: Buffer.from(secret, 'hex'),
[keySendPreimageType]: preimage,
},
}
}
Expand All @@ -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,
}
}

Expand All @@ -237,8 +240,9 @@ export const payInvoice = ({
} else {
dispatch(
sendPayment({
paymentId,
path: [pubkey],
paymentHash,
paymentId,
feeLimit,
value: amt,
remainingRetries: retries,
Expand Down

0 comments on commit 5572048

Please # to comment.