Skip to content

Commit

Permalink
fix: stop beignet wallet before replace/wipe it
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Dec 4, 2024
1 parent b5d6bb3 commit e8dc728
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@synonymdev/slashtags-widget-price-feed": "1.1.0",
"@synonymdev/web-relay": "1.0.7",
"bech32": "2.0.0",
"beignet": "0.0.48",
"beignet": "0.0.49",
"bip21": "2.0.3",
"bip32": "4.0.0",
"bitcoin-address-validation": "2.2.3",
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Settings/AddressViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ const AddressViewer = ({
if (utxosLength <= 0) {
return;
}
resetSendTransaction();
await resetSendTransaction();
const transactionRes = await setupOnChainTransaction({
utxos: selectedUtxosLength > 0 ? selectedUtxos : utxos,
rbf: true,
Expand Down
6 changes: 5 additions & 1 deletion src/store/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { removePin } from '../../utils/settings';
import { wipeKeychain } from '../../utils/keychain';
import { showToast } from '../../utils/notifications';
import { wipeLdkStorage } from '../../utils/lightning';
import { getSelectedWallet } from '../../utils/wallet';
import { getOnChainWalletAsync, getSelectedWallet } from '../../utils/wallet';
import { TWalletName } from '../types/wallet';
import { __E2E__ } from '../../constants/env';

Expand All @@ -31,6 +31,10 @@ export const wipeApp = async ({
restartApp?: boolean;
} = {}): Promise<Result<string>> => {
try {
// stop onchain wallet
const wallet = await getOnChainWalletAsync();
await wallet.stop();

// Reset Redux stores & persisted storage
dispatch({ type: actions.WIPE_APP });

Expand Down
10 changes: 2 additions & 8 deletions src/utils/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,14 +1108,8 @@ export const setupOnChainWallet = async ({
addressTypesToMonitor?: EAddressType[];
gapLimitOptions?: TGapLimitOptions;
}): Promise<Result<Wallet>> => {
// Disconnect from Electrum before setting up a new wallet
if (globalWallet) {
// If wallet refresh is in progress, wait for it to complete
if (globalWallet.isRefreshing) {
await globalWallet.refreshWallet();
}
await globalWallet.electrum?.disconnect();
}
// if wallet alrady exists, prepare it to be re-created
await globalWallet?.stop();

if (!mnemonic) {
const mnemonicRes = await getMnemonicPhrase(name);
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6351,9 +6351,9 @@ __metadata:
languageName: node
linkType: hard

"beignet@npm:0.0.48":
version: 0.0.48
resolution: "beignet@npm:0.0.48"
"beignet@npm:0.0.49":
version: 0.0.49
resolution: "beignet@npm:0.0.49"
dependencies:
"@bitcoinerlab/secp256k1": 1.0.5
bech32: 2.0.0
Expand All @@ -6367,7 +6367,7 @@ __metadata:
lodash.clonedeep: 4.5.0
net: 1.0.2
rn-electrum-client: 0.0.18
checksum: 4aab9ec50b339bde6ef291fc9e9a2e6845f6f7bac9a07be292cfc0eaac5bcd387ed08d5a54e416f476a40d332cf6a1946c028387eba76a0e81890e33b5e73615
checksum: fef6246edf066cb1dad9a3969d10e7a5497524aa9220fab24b3a11cb0644d04b23bddab48912b9485e67b7b58c58e3da951fa5e349c92a5121a042663def0280
languageName: node
linkType: hard

Expand Down Expand Up @@ -6612,7 +6612,7 @@ __metadata:
babel-jest: ^29.7.0
babel-plugin-transform-remove-console: ^6.9.4
bech32: 2.0.0
beignet: 0.0.48
beignet: 0.0.49
bip21: 2.0.3
bip32: 4.0.0
bitcoin-address-validation: 2.2.3
Expand Down

0 comments on commit e8dc728

Please sign in to comment.