mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 11:18:24 +00:00
Merge remote-tracking branch 'origin/main' into fix-contacts-typedefs
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minibits_wallet",
|
||||
"version": "0.1.8-beta.36",
|
||||
"version": "0.1.8-beta.37",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android:clean": "cd android && ./gradlew clean",
|
||||
|
||||
@@ -276,12 +276,12 @@ useFocusEffect(
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const getMeltQuote = async function () {
|
||||
const createMeltQuote = async function () {
|
||||
try {
|
||||
log.trace('[getMeltQuote]', {mintBalanceToTransferFrom})
|
||||
log.trace('[createMeltQuote]', {mintBalanceToTransferFrom})
|
||||
if (!mintBalanceToTransferFrom || !encodedInvoice) {
|
||||
log.trace(
|
||||
'[getMeltQuote]',
|
||||
'[createMeltQuote]',
|
||||
'Not yet ready to request melt quote or melt quote already exists... exiting',
|
||||
{mintBalanceToTransferFrom,
|
||||
encodedInvoice}
|
||||
@@ -290,7 +290,7 @@ useEffect(() => {
|
||||
}
|
||||
|
||||
setIsLoading(true)
|
||||
const quote = await MintClient.getLightningMeltQuote(
|
||||
const quote = await MintClient.createLightningMeltQuote(
|
||||
mintBalanceToTransferFrom.mintUrl,
|
||||
unit,
|
||||
encodedInvoice,
|
||||
@@ -320,7 +320,7 @@ useEffect(() => {
|
||||
}
|
||||
}
|
||||
|
||||
getMeltQuote()
|
||||
createMeltQuote()
|
||||
|
||||
}, [mintBalanceToTransferFrom])
|
||||
|
||||
|
||||
@@ -338,19 +338,19 @@ const getSpentOrPendingProofsFromMint = async function (
|
||||
|
||||
|
||||
|
||||
const getLightningMeltQuote = async function (
|
||||
const createLightningMeltQuote = async function (
|
||||
mintUrl: string,
|
||||
unit: MintUnit,
|
||||
encodedInvoice: string,
|
||||
) {
|
||||
try {
|
||||
const cashuMint = getMint(mintUrl)
|
||||
const lightningQuote: MeltQuoteResponse = await cashuMint.meltQuote({
|
||||
const lightningQuote: MeltQuoteResponse = await cashuMint.createMeltQuote({
|
||||
unit,
|
||||
request: encodedInvoice
|
||||
})
|
||||
|
||||
log.info('[getLightningMeltQuote]', {mintUrl, unit, encodedInvoice}, {lightningQuote})
|
||||
log.info('[createLightningMeltQuote]', {mintUrl, unit, encodedInvoice}, {lightningQuote})
|
||||
|
||||
return lightningQuote
|
||||
|
||||
@@ -362,7 +362,7 @@ const getLightningMeltQuote = async function (
|
||||
message,
|
||||
{
|
||||
message: e.message,
|
||||
caller: 'getLightningMeltQuote',
|
||||
caller: 'createLightningMeltQuote',
|
||||
request: {mintUrl, unit, encodedInvoice},
|
||||
}
|
||||
)
|
||||
@@ -415,7 +415,7 @@ const payLightningMelt = async function (
|
||||
|
||||
|
||||
|
||||
const getBolt11MintQuote = async function (
|
||||
const createLightningMintQuote = async function (
|
||||
mintUrl: string,
|
||||
unit: MintUnit,
|
||||
amount: number,
|
||||
@@ -425,12 +425,12 @@ const getBolt11MintQuote = async function (
|
||||
const {
|
||||
request: encodedInvoice,
|
||||
quote: mintQuote,
|
||||
} = await cashuMint.mintQuote({
|
||||
} = await cashuMint.createMintQuote({
|
||||
unit,
|
||||
amount
|
||||
})
|
||||
|
||||
log.info('[getBolt11MintQuote]', {encodedInvoice, mintQuote})
|
||||
log.info('[createLightningMintQuote]', {encodedInvoice, mintQuote})
|
||||
|
||||
return {
|
||||
encodedInvoice,
|
||||
@@ -444,7 +444,7 @@ const getBolt11MintQuote = async function (
|
||||
message,
|
||||
{
|
||||
message: e.message,
|
||||
caller: 'getBolt11MintQuote',
|
||||
caller: 'createLightningMintQuote',
|
||||
mintUrl,
|
||||
}
|
||||
)
|
||||
@@ -452,7 +452,7 @@ const getBolt11MintQuote = async function (
|
||||
}
|
||||
|
||||
|
||||
const getBolt11MintQuoteIsPaid = async function (
|
||||
const checkLightningMintQuote = async function (
|
||||
mintUrl: string,
|
||||
quote: string,
|
||||
) {
|
||||
@@ -461,17 +461,17 @@ const getBolt11MintQuoteIsPaid = async function (
|
||||
const {
|
||||
request: encodedInvoice,
|
||||
quote: mintQuote,
|
||||
paid: isPaid
|
||||
} = await cashuMint.getMintQuote(
|
||||
state,
|
||||
} = await cashuMint.checkMintQuote(
|
||||
quote
|
||||
)
|
||||
|
||||
log.info('[getBolt11MintQuoteIsPaid]', {encodedInvoice, mintQuote, isPaid})
|
||||
log.info('[checkLightningMintQuote]', {encodedInvoice, mintQuote, state})
|
||||
|
||||
return {
|
||||
encodedInvoice,
|
||||
mintQuote,
|
||||
isPaid
|
||||
state
|
||||
}
|
||||
} catch (e: any) {
|
||||
let message = 'The mint could not return the state of a mint quote.'
|
||||
@@ -481,7 +481,7 @@ const getBolt11MintQuoteIsPaid = async function (
|
||||
message,
|
||||
{
|
||||
message: e.message,
|
||||
caller: 'getBolt11MintQuoteIsPaid',
|
||||
caller: 'checkLightningMintQuote',
|
||||
mintUrl,
|
||||
}
|
||||
)
|
||||
@@ -613,10 +613,10 @@ export const MintClient = {
|
||||
receiveFromMint,
|
||||
sendFromMint,
|
||||
getSpentOrPendingProofsFromMint,
|
||||
getBolt11MintQuote,
|
||||
getBolt11MintQuoteIsPaid,
|
||||
createLightningMintQuote,
|
||||
checkLightningMintQuote,
|
||||
mintProofs,
|
||||
getLightningMeltQuote,
|
||||
createLightningMeltQuote,
|
||||
payLightningMelt,
|
||||
restore,
|
||||
getMintInfo,
|
||||
|
||||
@@ -59,7 +59,7 @@ export const topupTask = async function (
|
||||
const storedTransaction: TransactionRecord = await transactionsStore.addTransaction(newTransaction)
|
||||
transactionId = storedTransaction.id as number
|
||||
|
||||
const {encodedInvoice, mintQuote} = await MintClient.getBolt11MintQuote(mintUrl, unit, amountToTopup)
|
||||
const {encodedInvoice, mintQuote} = await MintClient.createLightningMintQuote(mintUrl, unit, amountToTopup)
|
||||
|
||||
const decodedInvoice = LightningUtils.decodeInvoice(encodedInvoice)
|
||||
const {amount, payment_hash, expiry, timestamp} = LightningUtils.getInvoiceData(decodedInvoice)
|
||||
|
||||
@@ -13,7 +13,7 @@ import {LightningUtils} from './lightning/lightningUtils'
|
||||
import AppError, {Err} from '../utils/AppError'
|
||||
import {MintBalance, MintStatus} from '../models/Mint'
|
||||
import {Token} from '../models/Token'
|
||||
import {MeltQuoteResponse, type Proof as CashuProof} from '@cashu/cashu-ts'
|
||||
import {MeltQuoteResponse, MintQuoteState, type Proof as CashuProof} from '@cashu/cashu-ts'
|
||||
import {Mint} from '../models/Mint'
|
||||
import {pollerExists, stopPolling} from '../utils/poller'
|
||||
import EventEmitter from '../utils/eventEmitter'
|
||||
@@ -768,13 +768,13 @@ const _handlePendingTopupTask = async function (params: {paymentRequest: Payment
|
||||
log.trace('[_handlePendingTopupTask]', 'countOfInFlightProofs', countOfInFlightProofs)
|
||||
|
||||
// check is quote has been paid
|
||||
const { isPaid, mintQuote: quote } = await MintClient.getBolt11MintQuoteIsPaid(mint!, mintQuote)
|
||||
const { state, mintQuote: quote } = await MintClient.checkLightningMintQuote(mint!, mintQuote)
|
||||
|
||||
if (quote !== mintQuote) {
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Returned quote is different then the one requested', {mintUrl: mint, quote, mintQuote})
|
||||
}
|
||||
|
||||
if (isPaid !== true) {
|
||||
if (state !== MintQuoteState.PAID) {
|
||||
log.trace('[_handlePendingTopupTask] Quote not paid', {mintUrl: mint, mintQuote})
|
||||
|
||||
if (isBefore(pr.expiresAt as Date, new Date())) {
|
||||
@@ -928,13 +928,23 @@ const handleClaim = async function (): Promise<void> {
|
||||
|
||||
log.info('[handleClaim] start')
|
||||
const {walletId, seedHash, pubkey} = walletProfileStore
|
||||
let recoveredWalletId: string | null = null
|
||||
|
||||
|
||||
if(!walletId || !seedHash || !pubkey) {
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Skipping claim of ecash received to your lightning address, missing profile data', {walletId, seedHash, pubkey})
|
||||
if(!seedHash || !pubkey) {
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Skipping claim of ecash received to your lightning address, missing profile data. Reinstall wallet to fix it.', {walletId, seedHash, pubkey})
|
||||
}
|
||||
|
||||
const claimedInvoices = await MinibitsClient.createClaim(walletId, seedHash, pubkey)
|
||||
if(!walletId) {
|
||||
// fix immediately in case only walletId missing in walletProfile
|
||||
const profile = await MinibitsClient.getWalletProfileBySeedHash(seedHash)
|
||||
|
||||
if(profile) {
|
||||
recoveredWalletId = profile.walletId
|
||||
walletProfileStore.setWalletId(recoveredWalletId)
|
||||
}
|
||||
}
|
||||
|
||||
const claimedInvoices = await MinibitsClient.createClaim(walletId || recoveredWalletId as string, seedHash, pubkey)
|
||||
|
||||
if(claimedInvoices.length === 0) {
|
||||
log.debug('[handleClaim] No claimed invoices returned from server...')
|
||||
|
||||
@@ -1202,9 +1202,15 @@
|
||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
<<<<<<< HEAD
|
||||
"@cashu/cashu-ts@KraXen72/cashu-ts-minibits#8345e93ee408e1aa8fde79b7c35badc07ba60694":
|
||||
version "1.0.0-minibits"
|
||||
resolved "https://codeload.github.com/KraXen72/cashu-ts-minibits/tar.gz/8345e93ee408e1aa8fde79b7c35badc07ba60694"
|
||||
=======
|
||||
"@cashu/cashu-ts@minibits-cash/cashu-ts#1.0.0-minibits":
|
||||
version "1.0.0-minibits"
|
||||
resolved "https://codeload.github.com/minibits-cash/cashu-ts/tar.gz/95cd37801f54700bed1b84113a774bd23f36aecb"
|
||||
>>>>>>> origin/main
|
||||
dependencies:
|
||||
"@cashu/crypto" "^0.2.6"
|
||||
"@noble/curves" "^1.3.0"
|
||||
|
||||
Reference in New Issue
Block a user