New button to fix and retry immediately if mint returns "outputs have already been signed" error

This commit is contained in:
minibits-cash
2024-08-05 23:55:36 +02:00
parent 7f0e1579d4
commit c1e31afc13
7 changed files with 146 additions and 26 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "minibits_wallet",
"version": "0.1.8-beta.46",
"version": "0.1.8-beta.47",
"private": true,
"scripts": {
"android:clean": "cd android && ./gradlew clean",
+42 -7
View File
@@ -39,7 +39,7 @@ import { translate } from '../i18n'
export const ReceiveScreen: FC<WalletStackScreenProps<'Receive'>> = observer(
function ReceiveScreen({route, navigation}) {
const isInternetReachable = useIsInternetReachable()
const {mintsStore} = useStores()
const {mintsStore, walletStore} = useStores()
const [token, setToken] = useState<TokenV3 | undefined>()
const [encodedToken, setEncodedToken] = useState<string | undefined>()
@@ -83,7 +83,7 @@ export const ReceiveScreen: FC<WalletStackScreenProps<'Receive'>> = observer(
setIsLoading(false)
const {error, message, transaction, receivedAmount} = result
const {error, message, transaction, receivedAmount, mintUrl} = result
const {status} = transaction as Transaction
setTransactionStatus(status)
@@ -186,6 +186,33 @@ export const ReceiveScreen: FC<WalletStackScreenProps<'Receive'>> = observer(
}
const increaseProofsCounterAndRetry = async function () {
try {
if(!transaction) {
return
}
const {mint} = transaction
const walletInstance = await walletStore.getWallet(
mint,
unit,
{withSeed: true}
)
const mintInstance = mintsStore.findByUrl(mint)
const counter = mintInstance!.getProofsCounterByKeysetId!(walletInstance.keys.id)
counter!.increaseProofsCounter(50)
// retry receive
receiveToken()
} catch (e: any) {
handleError(e)
} finally {
toggleResultModal() //close
}
}
const receiveOfflineToken = async function () {
setIsLoading(true)
setIsReceiveTaskSentToQueue(true)
@@ -434,11 +461,19 @@ export const ReceiveScreen: FC<WalletStackScreenProps<'Receive'>> = observer(
message={resultModalInfo?.message as string}
/>
<View style={$buttonContainer}>
<Button
preset="secondary"
tx='common.close'
onPress={toggleResultModal}
/>
{resultModalInfo.message.includes('outputs have already been signed before') ? (
<Button
preset="secondary"
text={"Try again"}
onPress={increaseProofsCounterAndRetry}
/>
) : (
<Button
preset="secondary"
tx={'common.close'}
onPress={toggleResultModal}
/>
)}
</View>
</>
)}
+10 -3
View File
@@ -58,8 +58,15 @@ export const RemoteRecoveryScreen: FC<AppStackScreenProps<'RemoteRecovery'>> = o
},
})
const {mintsStore, proofsStore, userSettingsStore, transactionsStore, walletProfileStore, walletStore} = useStores()
// const {walletStore} = nonPersistedStores
const {
mintsStore,
proofsStore,
userSettingsStore,
transactionsStore,
walletProfileStore,
walletStore
} = useStores()
const mnemonicInputRef = useRef<TextInput>(null)
const indexInputRef = useRef<TextInput>(null)
@@ -550,7 +557,7 @@ export const RemoteRecoveryScreen: FC<AppStackScreenProps<'RemoteRecovery'>> = o
userSettingsStore.setIsOnboarded(true)
setStatusMessage('')
setIsLoading(false)
navigation.navigate('Tabs')
navigation.goBack()
} catch (e: any) {
handleError(e)
}
+42 -6
View File
@@ -77,7 +77,14 @@ export const SendScreen: FC<WalletStackScreenProps<'Send'>> = observer(
const isInternetReachable = useIsInternetReachable()
const {proofsStore, walletProfileStore, transactionsStore, mintsStore, relaysStore} = useStores()
const {
proofsStore,
walletProfileStore,
transactionsStore,
mintsStore,
relaysStore,
walletStore
} = useStores()
const amountInputRef = useRef<TextInput>(null)
const memoInputRef = useRef<TextInput>(null)
@@ -416,6 +423,27 @@ export const SendScreen: FC<WalletStackScreenProps<'Send'>> = observer(
}
const increaseProofsCounterAndRetry = async function () {
try {
const walletInstance = await walletStore.getWallet(
mintBalanceToSendFrom?.mintUrl as string,
unit,
{withSeed: true}
)
const mintInstance = mintsStore.findByUrl(mintBalanceToSendFrom?.mintUrl as string)
const counter = mintInstance!.getProofsCounterByKeysetId!(walletInstance.keys.id)
counter!.increaseProofsCounter(50)
// retry send
onMintBalanceConfirm()
} catch (e: any) {
handleError(e)
} finally {
toggleResultModal() //close
}
}
const onSelectProofsOffline = async function () {
if (!mintBalanceToSendFrom) {
return
@@ -766,11 +794,19 @@ export const SendScreen: FC<WalletStackScreenProps<'Send'>> = observer(
message={resultModalInfo?.message}
/>
<View style={$buttonContainer}>
<Button
preset="secondary"
tx={'common.close'}
onPress={toggleResultModal}
/>
{resultModalInfo.message.includes('outputs have already been signed before') ? (
<Button
preset="secondary"
text={"Try again"}
onPress={increaseProofsCounterAndRetry}
/>
) : (
<Button
preset="secondary"
tx={'common.close'}
onPress={toggleResultModal}
/>
)}
</View>
</>
)}
+34 -7
View File
@@ -562,8 +562,7 @@ const transfer = async function () {
}
setIsLoading(true)
setIsTransferTaskSentToQueue(true)
setIsTransferTaskSentToQueue(true)
log.trace('[transfer]', {isInvoiceDonation})
@@ -582,6 +581,26 @@ const transfer = async function () {
handleError(e)
}
}
const increaseProofsCounterAndRetry = async function () {
try {
const walletInstance = await walletStore.getWallet(
mintBalanceToTransferFrom?.mintUrl as string,
unit,
{withSeed: true}
)
const mintInstance = mintsStore.findByUrl(mintBalanceToTransferFrom?.mintUrl as string)
const counter = mintInstance!.getProofsCounterByKeysetId!(walletInstance.keys.id)
counter!.increaseProofsCounter(50)
// retry transfer
transfer()
} catch (e: any) {
handleError(e)
} finally {
toggleResultModal() //close
}
}
const onClose = function () {
@@ -832,11 +851,19 @@ const iconColor = useThemeColor('textDim')
message={resultModalInfo?.message}
/>
<View style={$buttonContainer}>
<Button
preset="secondary"
tx={'common.close'}
onPress={toggleResultModal}
/>
{resultModalInfo.message.includes('outputs have already been signed before') ? (
<Button
preset="secondary"
text={"Try again"}
onPress={increaseProofsCounterAndRetry}
/>
) : (
<Button
preset="secondary"
tx={'common.close'}
onPress={toggleResultModal}
/>
)}
</View>
</>
)}
+15 -1
View File
@@ -689,7 +689,21 @@ const PromoBlock = function (props: {addMint: any}) {
<Card
HeadingComponent={
<View style={$promoIconContainer}>
<Icon icon='faBurst' size={50} color={colors.palette.accent400} />
<View
style={{
flex: 0,
borderRadius: spacing.small,
padding: spacing.extraSmall,
backgroundColor: colors.palette.orange600
}}
>
<SvgXml
width={spacing.extraLarge}
height={spacing.extraLarge}
xml={MintIcon}
fill='white'
/>
</View>
</View>
}
ContentComponent={
+2 -1
View File
@@ -374,7 +374,8 @@ export const sendFromMint = async function (
// Increase the proofs counter before the mint call so that in case the response
// is not received our recovery index counts for sigs the mint has already issued (prevents duplicate b_b bug)
// + acquire lock and set inFlight values
// + acquire lock and set inFlight values
// Warning/TBD: if proofs from inactive keysets are in proofsToSendFrom, this still locks only an active keyset
lockedProofsCounter = await WalletUtils.lockAndSetInFlight(
mintInstance,
unit,