diff --git a/src/models/NwcStore.ts b/src/models/NwcStore.ts index 166e31c2..271ac42e 100644 --- a/src/models/NwcStore.ts +++ b/src/models/NwcStore.ts @@ -478,11 +478,11 @@ export const NwcConnectionModel = types.model('NwcConnection', { let transactionsStore = self.getTransactionsStore() if(nwcRequest.params.payment_hash) { - transaction = transactionsStore.findByPaymentId(nwcRequest.params.payment_hash) + transaction = transactionsStore.findBy({paymentId: nwcRequest.params.payment_hash}) } if(nwcRequest.params.invoice) { - transaction = transactionsStore.findByPaymentRequest(nwcRequest.params.invoice) + transaction = transactionsStore.findBy({paymentRequest: nwcRequest.params.invoice}) } if(!transaction) { diff --git a/src/models/WalletStore.ts b/src/models/WalletStore.ts index fa9a446d..f64b54da 100644 --- a/src/models/WalletStore.ts +++ b/src/models/WalletStore.ts @@ -491,7 +491,7 @@ export const WalletStoreModel = types options?: { increaseCounterBy?: number, inFlightRequest?: InFlightRequest - p2pk: { pubkey: string; locktime?: number; refundKeys?: Array } + p2pk?: { pubkey: string; locktime?: number; refundKeys?: Array } } ) { @@ -517,15 +517,16 @@ export const WalletStoreModel = types } log.debug('[WalletStore.send] counter', currentCounter.counter) + const {p2pk} = options const sendParams: SendParams = options?.inFlightRequest?.request || { amount: amountToSend, proofs: proofsToSendFrom, options: { keysetId: cashuWallet.keysetId, - counter: options?.p2pk ? undefined : currentCounter.counter, // p2pk is not deterministic + counter: p2pk && p2pk.pubkey ? undefined : currentCounter.counter, // p2pk is not deterministic includeFees: false, // fee reserve needs to be already in proofsToSendFrom - p2pk: options?.p2pk + p2pk } } diff --git a/src/screens/SendScreen.tsx b/src/screens/SendScreen.tsx index ad8f5b11..9ae62e32 100644 --- a/src/screens/SendScreen.tsx +++ b/src/screens/SendScreen.tsx @@ -102,8 +102,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { const [encodedTokenToSend, setEncodedTokenToSend] = useState() const [encodedCashuPaymentRequest, setEncodedCashuPaymentRequest] = useState() const [decodedCashuPaymentRequest, setDecodedCashuPaymentRequest] = useState() - const [amountToSend, setAmountToSend] = useState('0') - //const [unit, setUnit] = useState('sat') + const [amountToSend, setAmountToSend] = useState('0') const [contactToSendFrom, setContactToSendFrom] = useState() const [contactToSendTo, setContactToSendTo] = useState() const [relaysToShareTo, setRelaysToShareTo] = useState([]) @@ -115,11 +114,8 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { const [transaction, setTransaction] = useState() const [transactionId, setTransactionId] = useState() const [info, setInfo] = useState('') - const [error, setError] = useState() - const [isAmountEndEditing, setIsAmountEndEditing] = useState(false) - const [isSharedAsNostrDirectMessage, setIsSharedAsNostrDirectMessage] = useState(false) - const [resultModalInfo, setResultModalInfo] = useState<{status: TransactionStatus, title?: string, message: string} | undefined>() - const [isMemoEndEditing, setIsMemoEndEditing] = useState(false) + const [error, setError] = useState() + const [resultModalInfo, setResultModalInfo] = useState<{status: TransactionStatus, title?: string, message: string} | undefined>() const [isLoading, setIsLoading] = useState(false) const [isMintSelectorVisible, setIsMintSelectorVisible] = useState(false) @@ -132,7 +128,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { const [isResultModalVisible, setIsResultModalVisible] = useState(false) const [isNostrDMSending, setIsNostrDMSending] = useState(false) const [isNostrDMSuccess, setIsNostrDMSuccess] = useState(false) - const [isLockedToPubkey, setIsLockedToPubkey] = useState(false) + const [isPubkeySelectorModalVisible, setIsPubkeySelectorModalVisible] = useState(false) const [lockedPubkey, setLockedPubkey] = useState() // Added lockedPubkey state const [lockTime, setLockTime] = useState(1) @@ -596,8 +592,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { setAvailableMintBalances(availableBalances) // Default mint if not set from route params is with the one with highest balance - if(!mintBalanceToSendFrom) {setMintBalanceToSendFrom(availableBalances[0])} - setIsAmountEndEditing(true) + if(!mintBalanceToSendFrom) {setMintBalanceToSendFrom(availableBalances[0])} // We do not make memo focus mandatory // Show mint selector setIsMintSelectorVisible(true) @@ -614,8 +609,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { // Show mint selector if (availableMintBalances.length > 0) { setIsMintSelectorVisible(true) - } - setIsMemoEndEditing(true) + } } @@ -676,8 +670,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { setContactToSendTo(contact) setRelaysToShareTo(relays) } - - setIsLockedToPubkey(true) + togglePubkeySelectorModal() } @@ -701,7 +694,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { pubkey: string; locktime?: number; refundKeys?: Array - } = {} + } | undefined = undefined log.trace('[onMintBalanceConfirm] lockedPubkey', {lockedPubkey}) @@ -732,7 +725,7 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { unitRef.current, memo, selectedProofs, - p2pk, + p2pk.pubkey ? p2pk : undefined, draftTransactionIdRef.current ) } @@ -929,20 +922,16 @@ export const SendScreen = observer(function SendScreen({ route }: Props) { const resetState = function () { // reset state so it does not interfere next payment setAmountToSend('') - setMemo('') - setIsAmountEndEditing(false) - setIsMemoEndEditing(false) + setMemo('') setIsMintSelectorVisible(false) - setIsNostrDMModalVisible(false) - setIsSharedAsNostrDirectMessage(false) + setIsNostrDMModalVisible(false) setIsNostrDMSending(false) setIsNostrDMModalVisible(false) setIsProofSelectorModalVisible(false) setIsLoading(false) setResultModalInfo(undefined) setIsResultModalVisible(false) - setLockTime(undefined) - setIsLockedToPubkey(false) + setLockTime(undefined) setLockedPubkey(undefined) } diff --git a/src/services/wallet/sendTask.ts b/src/services/wallet/sendTask.ts index 5ccf042b..fa06dc49 100644 --- a/src/services/wallet/sendTask.ts +++ b/src/services/wallet/sendTask.ts @@ -341,7 +341,7 @@ export const sendFromMintSync = async function ( let returnedProofs: CashuProof[] = [] let isSwapNeeded: boolean = false - if(p2pk || proofsToSendFromAmount - amountToSend > 0) { + if((p2pk && p2pk.pubkey) || proofsToSendFromAmount - amountToSend > 0) { isSwapNeeded = true } @@ -393,7 +393,7 @@ export const sendFromMintSync = async function ( unit, proofsToSendFrom, transactionId, - {p2pk} + {p2pk: p2pk && p2pk.pubkey ? p2pk : undefined} ) } catch (e: any) { if(e.params && e.params.message.includes('outputs have already been signed before')) { @@ -404,7 +404,7 @@ export const sendFromMintSync = async function ( unit, proofsToSendFrom, transactionId, - {p2pk, increaseCounterBy: 10} + {p2pk: p2pk && p2pk.pubkey ? p2pk : undefined, increaseCounterBy: 10} ) } else { throw e diff --git a/src/services/walletService.ts b/src/services/walletService.ts index 860d3318..1b8049a9 100644 --- a/src/services/walletService.ts +++ b/src/services/walletService.ts @@ -1931,7 +1931,7 @@ const recoverMeltQuoteChange = async function (params: {mintUrl: string, meltQuo let transaction: Transaction | undefined = undefined let transactionId: number | undefined = undefined - transaction = transactionsStore.findByQuote(meltQuote) + transaction = transactionsStore.findBy({quote: meltQuote}) transactionId = transaction?.id const transactionData: TransactionData[] = transaction ? JSON.parse(transaction.data) : []