Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about hodl invoice #852

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/routes/Send.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MutinyInvoice } from "@mutinywallet/mutiny-wasm";
import { MutinyInvoice, MutinyWallet } from "@mutinywallet/mutiny-wasm";
import { A, useNavigate, useSearchParams } from "@solidjs/router";
import {
createEffect,
Expand Down Expand Up @@ -451,11 +451,15 @@ export function Send() {
function processInvoice(source: ParsedParams & { invoice: string }) {
state.mutiny_wallet
?.decode_invoice(source.invoice!)
.then((invoice) => {
.then(async (invoice) => {
if (invoice.expire <= Date.now() / 1000) {
navigate("/search");
throw new Error(i18n.t("send.error_expired"));
}
const isHodl = await MutinyWallet.is_potential_hodl_invoice(
source.invoice!
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should just happen below in a single spot where it is being set. Now you have it here twice. I think this method can just replace the previous.

);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is source here and not not invoice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

invoice isn't a string, it is a MutinyInvoice

setIsHodlInvoice(isHodl);

if (invoice?.amount_sats) {
setAmountSats(invoice.amount_sats);
Expand Down
Loading