Skip to content

Commit

Permalink
Hodl invoice fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Jun 21, 2023
1 parent 47e8d39 commit e7a21f1
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/state/Send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const send: ISendModel = {
/**
* @throws
*/
sendPayment: thunk(async (_, payload, { getState, dispatch, injections, getStoreState }) => {
sendPayment: thunk(async (_, payload, { getState, dispatch, injections, getStoreState, getStoreActions }) => {
const start = new Date().getTime();

const sendPaymentV2Sync = injections.lndMobile.index.sendPaymentV2Sync;
Expand Down Expand Up @@ -151,9 +151,10 @@ export const send: ISendModel = {
const name = getStoreState().settings.name;
const multiPathPaymentsEnabled = getStoreState().settings.multiPathPaymentsEnabled;
const maxLNFeePercentage = getStoreState().settings.maxLNFeePercentage;
const getTransactionByPaymentRequest = getStoreState().transaction.getTransactionByPaymentRequest;

// Pre-settlement tx insert
const preTransaction: ITransaction = {
const preTransaction: ITransaction = getTransactionByPaymentRequest(paymentRequestStr) ?? {
date: paymentRequest.timestamp,
description: extraData.lnurlPayTextPlain ?? paymentRequest.description,
duration: 0,
Expand Down Expand Up @@ -192,14 +193,23 @@ export const send: ISendModel = {
log.d("IPreTransaction", [preTransaction]);
await dispatch.transaction.syncTransaction(preTransaction);

const sendPaymentResult = await sendPaymentV2Sync(
paymentRequestStr,
payload && payload.amount ? Long.fromValue(payload.amount) : undefined,
paymentRequest.numSatoshis,
name,
multiPathPaymentsEnabled,
maxLNFeePercentage,
);
let sendPaymentResult: lnrpc.Payment | undefined;
try {
sendPaymentResult = await sendPaymentV2Sync(
paymentRequestStr,
payload && payload.amount ? Long.fromValue(payload.amount) : undefined,
paymentRequest.numSatoshis,
name,
multiPathPaymentsEnabled,
maxLNFeePercentage,
);
} catch (error) {
await dispatch.transaction.syncTransaction({
...preTransaction,
status: preTransaction.status === "SETTLED" ? preTransaction.status : "CANCELED",
});
throw error;
}

log.i("status", [sendPaymentResult.status, sendPaymentResult.failureReason]);
if (sendPaymentResult.status !== lnrpc.Payment.PaymentStatus.SUCCEEDED) {
Expand Down

1 comment on commit e7a21f1

@vercel
Copy link

@vercel vercel bot commented on e7a21f1 Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blixt-wallet – ./

blixt-wallet-git-master-hsjoberg.vercel.app
blixt-wallet-hsjoberg.vercel.app

Please sign in to comment.