Skip to content

Commit

Permalink
fix(wallet): Fix On-Chain Address Scanning
Browse files Browse the repository at this point in the history
Removes resetOnChainTransaction from onOpen in SendNavigation.tsx.
Updates address variable in ReviewAndSend.tsx.
Adds comments to resetOnChainTransaction & setupOnChainTransaction methods.
  • Loading branch information
coreyphillips committed May 5, 2023
1 parent f63ddae commit 78048f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/navigation/bottom-sheet/SendNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const SendNavigation = (): ReactElement => {
const initialRouteName = screen ?? 'Recipient';

const onOpen = async (): Promise<void> => {
resetOnChainTransaction();
await setupOnChainTransaction();
setupFeeForOnChainTransaction();
};
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Wallets/Send/ReviewAndSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const ReviewAndSend = ({
const transactionTotal = amount + transaction.fee;
const selectedFeeId = transaction.selectedFeeId;
const satsPerByte = transaction.satsPerByte;
const address = transaction.outputs[outputIndex].address ?? '';
const address = transaction?.outputs[outputIndex]?.address ?? '';

useEffect(() => {
setupFeeForOnChainTransaction();
Expand Down
17 changes: 17 additions & 0 deletions src/store/actions/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,17 @@ export const resetWalletStore = async (): Promise<Result<string>> => {
return ok('');
};

/**
* Sets up a transaction for a given wallet by gathering inputs, setting the next available change address as an output and sets up the baseline fee structure.
* This function will not override previously set transaction data. To do that you'll need to call resetOnChainTransaction.
* @param {TWalletName} [selectedWallet]
* @param {TAvailableNetworks} [selectedNetwork]
* @param {EAddressType} [addressType]
* @param {string[]} [inputTxHashes]
* @param {IUtxo[]} [utxos]
* @param {boolean} [rbf]
* @returns {Promise<Result<Partial<IBitcoinTransactionData>>>}
*/
export const setupOnChainTransaction = async ({
selectedWallet,
selectedNetwork,
Expand Down Expand Up @@ -1155,6 +1166,12 @@ export const updateSelectedFeeId = async ({
}
};

/**
* This completely resets the on-chain transaction data for the specified wallet and network.
* @param {TWalletName} [selectedWallet]
* @param {TAvailableNetworks} [selectedNetwork]
* @returns {Result<string>}
*/
export const resetOnChainTransaction = ({
selectedWallet,
selectedNetwork,
Expand Down

0 comments on commit 78048f4

Please sign in to comment.