diff --git a/src/components/MultinutPicker.vue b/src/components/MultinutPicker.vue new file mode 100644 index 00000000..3c6887cf --- /dev/null +++ b/src/components/MultinutPicker.vue @@ -0,0 +1,146 @@ + + + diff --git a/src/components/PayInvoiceDialog.vue b/src/components/PayInvoiceDialog.vue index 96420a18..1eb92e19 100644 --- a/src/components/PayInvoiceDialog.vue +++ b/src/components/PayInvoiceDialog.vue @@ -64,6 +64,9 @@
+
+ +
- - -
- - Close - -
-
--> @@ -262,6 +252,7 @@ import ToggleUnit from "components/ToggleUnit.vue"; // import * as bolt11Decoder from "light-bolt11-decoder"; import * as _ from "underscore"; +import MultinutPicker from "./MultinutPicker.vue"; import { Scan as ScanIcon } from "lucide-vue-next"; export default defineComponent({ @@ -270,6 +261,7 @@ export default defineComponent({ components: { ChooseMint, ToggleUnit, + MultinutPicker, ScanIcon, }, props: {}, diff --git a/src/stores/wallet.ts b/src/stores/wallet.ts index 4b011b0c..23d8d3d1 100644 --- a/src/stores/wallet.ts +++ b/src/stores/wallet.ts @@ -135,15 +135,10 @@ export const useWalletStore = defineStore("wallet", { lnurlauth: {}, input: { request: "", - amount: null, + amount: undefined, comment: "", quote: "", - } as { - request: string; - amount: number | null; - comment: string; - quote: string; - }, + } as { request: string, amount: number | undefined, comment: string, quote: string }, }, }; }, @@ -706,10 +701,8 @@ export const useWalletStore = defineStore("wallet", { const data = await this.meltQuote(mintWallet, payload.request); mintStore.assertMintError(data); this.payInvoiceData.meltQuote.response = data; - this.payInvoiceData.blocking = false; return data; } catch (error: any) { - this.payInvoiceData.blocking = false; this.payInvoiceData.meltQuote.error = error; console.error(error); notifyApiError(error); @@ -717,12 +710,20 @@ export const useWalletStore = defineStore("wallet", { } finally { } }, - meltQuote: async function ( - wallet: CashuWallet, - request: string - ): Promise { + meltQuote: async function (wallet: CashuWallet, request: string, mpp_amount: number | undefined = undefined): Promise { + // const payload: MeltQuotePayload = { + // unit: mintStore.activeUnit, + // request: this.payInvoiceData.input.request, + // }; + // this.payInvoiceData.meltQuote.payload = payload; + // const data = await mintStore.activeMint().api.createMeltQuote(payload); + // const data = await this.wallet.createMeltQuote(this.payInvoiceData.input.request, { mpp_amount: this.payInvoiceData.input.amount }); const mintStore = useMintsStore(); - const data = await wallet.createMeltQuote(request); + let options = {}; + if (mpp_amount) { + options = { mpp: { amount: mpp_amount } }; + } + const data = await wallet.createMeltQuote(request, options); mintStore.assertMintError(data); return data; }, @@ -835,8 +836,8 @@ export const useWalletStore = defineStore("wallet", { notifySuccess( "Paid " + - uIStore.formatCurrency(amount_paid, mintWallet.unit) + - " via Lightning" + uIStore.formatCurrency(amount_paid, mintWallet.unit) + + " via Lightning" ); console.log("#### pay lightning: token paid"); // delete spent tokens from db @@ -953,8 +954,6 @@ export const useWalletStore = defineStore("wallet", { }); } } - // return unspent proofs - return spentProofs; } catch (error: any) { console.error(error); notifyApiError(error); @@ -1098,10 +1097,10 @@ export const useWalletStore = defineStore("wallet", { const proofStore = useProofsStore(); notifySuccess( "Sent " + - uIStore.formatCurrency( - proofStore.sumProofs(spentProofs), - historyToken.unit - ) + uIStore.formatCurrency( + proofStore.sumProofs(spentProofs), + historyToken.unit + ) ); } else { console.log("### token not paid yet"); @@ -1183,8 +1182,8 @@ export const useWalletStore = defineStore("wallet", { useUiStore().vibrate(); notifySuccess( "Received " + - uIStore.formatCurrency(invoice.amount, invoice.unit) + - " via Lightning" + uIStore.formatCurrency(invoice.amount, invoice.unit) + + " via Lightning" ); unsub(); return proofs; @@ -1241,8 +1240,8 @@ export const useWalletStore = defineStore("wallet", { useUiStore().vibrate(); notifySuccess( "Received " + - uIStore.formatCurrency(invoice.amount, invoice.unit) + - " via Lightning" + uIStore.formatCurrency(invoice.amount, invoice.unit) + + " via Lightning" ); return proofs; } catch (error) { @@ -1292,10 +1291,10 @@ export const useWalletStore = defineStore("wallet", { useUiStore().vibrate(); notifySuccess( "Sent " + - uIStore.formatCurrency( - useProofsStore().sumProofs(proofs), - invoice.unit - ) + uIStore.formatCurrency( + useProofsStore().sumProofs(proofs), + invoice.unit + ) ); } // set invoice in history to paid