This commit is contained in:
minibits-cash
2025-04-16 16:08:03 +02:00
4 changed files with 17 additions and 15 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "minibits_wallet",
"version": "0.2.2-beta.3",
"version": "0.2.2-beta.4",
"private": true,
"scripts": {
"android:clean": "cd android && ./gradlew clean",
+6 -12
View File
@@ -423,27 +423,21 @@ export const WalletStoreModel = types
log.debug('[WalletStore.receive] counter', currentCounter.counter)
// P2PK locked tokens can be received only by the wallet they are locked to
// P2PK locked tokens can be received only by the wallet they are locked to (if lock has not expired)
const isLocked = CashuUtils.isTokenP2PKLocked(decodedToken)
let isLockedToWallet = false
const walletKeys = yield self.getCachedWalletKeys()
if(isLocked) {
const lockedToPK = CashuUtils.getP2PKPubkeySecret(decodedToken.proofs[0].secret)
const locktime = CashuUtils.getP2PKLocktime(decodedToken.proofs[0].secret)
const walletP2PK = '02' + walletKeys.NOSTR.publicKey
isLockedToWallet = lockedToPK === walletP2PK
const locktime = CashuUtils.getP2PKLocktime(decodedToken.proofs[0].secret)
isLockedToWallet = lockedToPK === walletP2PK
if(!isLockedToWallet && !locktime) {
throw new AppError(Err.VALIDATION_ERROR, 'Ecash token is locked to another wallet, can not receive it.', {lockedToPK, walletP2PK})
}
const currentTimestamp = getUnixTime(new Date(Date.now()))
if(locktime && locktime > currentTimestamp) {
throw new AppError(Err.VALIDATION_ERROR, 'Ecash token is locked to another wallet, and lock has not yet expired. Try again later.', {locktime, currentTimestamp})
}
if(!isLockedToWallet) {
throw new AppError(Err.VALIDATION_ERROR, 'Ecash token is locked to another wallet, can not receive it.', {lockedToPK, walletP2PK, locktime})
}
}
const receiveParams: ReceiveParams = options?.inFlightRequest?.request || {
+1 -1
View File
@@ -182,7 +182,7 @@ export const ReceiveScreen = observer(function ReceiveScreen({ route }: Props) {
const decoded = getDecodedToken(encoded)
const tokenAmount = CashuUtils.getProofsAmount(decoded.proofs)
const isLocked = CashuUtils.isTokenP2PKLocked(decoded)
let isLockedToWallet = false
let isLockedToWallet = false
if(isLocked) {
const lockedToPK = CashuUtils.getP2PKPubkeySecret(decoded.proofs[0].secret)
+9 -1
View File
@@ -11,6 +11,7 @@ import {Proof} from '../../models/Proof'
import { log } from '../logService'
import { decodePaymentRequest, sumProofs } from '@cashu/cashu-ts/src/utils'
import { NostrClient } from '../nostrService'
import { getUnixTime } from 'date-fns/getUnixTime'
export {CashuProof}
@@ -301,7 +302,14 @@ const isTokenP2PKLocked = function (token: Token) {
for (const secret of secrets) {
try {
if (getP2PKPubkeySecret(secret)) {
return true
const locktime = CashuUtils.getP2PKLocktime(secret)
const currentTimestamp = getUnixTime(new Date(Date.now()))
if(!locktime) {
return true
} else if (locktime > currentTimestamp) {
return true
}
}
} catch {}
}