mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
Merge pull request #7021 from BlueWallet/fix-lndhub-refill
Fix lndhub refill
This commit is contained in:
commit
71e674bab4
@ -54,7 +54,7 @@
|
||||
"clean:ios": "rm -fr node_modules && rm -fr ios/Pods && npm i && cd ios && pod update && cd ..; npm start -- --reset-cache",
|
||||
"releasenotes2json": "./scripts/release-notes.sh > release-notes.txt; node -e 'console.log(JSON.stringify(require(\"fs\").readFileSync(\"release-notes.txt\", \"utf8\")));' > release-notes.json",
|
||||
"branch2json": "./scripts/current-branch.sh > current-branch.json",
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||
"start": "react-native start",
|
||||
"android": "react-native run-android",
|
||||
"android:clean": "cd android; ./gradlew clean ; cd .. ; npm run android",
|
||||
"ios": "react-native run-ios",
|
||||
|
@ -74,8 +74,8 @@ const SelectWallet: React.FC = () => {
|
||||
|
||||
const onPress = (item: TWallet) => {
|
||||
triggerHapticFeedback(HapticFeedbackTypes.Selection);
|
||||
if (isModal) {
|
||||
onWalletSelect?.(item, { navigation: { pop, navigate } });
|
||||
if (onWalletSelect) {
|
||||
onWalletSelect(item, { navigation: { pop, navigate } });
|
||||
} else {
|
||||
navigate(previousRouteName, { walletID: item.getID(), merge: true });
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamL
|
||||
import { Transaction, TWallet } from '../../class/wallets/types';
|
||||
import getWalletTransactionsOptions from '../../navigation/helpers/getWalletTransactionsOptions';
|
||||
import { presentWalletExportReminder } from '../../helpers/presentWalletExportReminder';
|
||||
import selectWallet from '../../helpers/select-wallet';
|
||||
import assert from 'assert';
|
||||
|
||||
const buttonFontSize =
|
||||
PixelRatio.roundToNearestPixel(Dimensions.get('window').width / 26) > 22
|
||||
@ -177,34 +179,35 @@ const WalletTransactions: React.FC<WalletTransactionsProps> = ({ route }) => {
|
||||
};
|
||||
|
||||
const onWalletSelect = async (selectedWallet: TWallet) => {
|
||||
if (selectedWallet) {
|
||||
navigate('WalletTransactions', {
|
||||
walletType: wallet?.type,
|
||||
walletID: wallet?.getID(),
|
||||
key: `WalletTransactions-${wallet?.getID()}`,
|
||||
});
|
||||
if (wallet?.type === LightningCustodianWallet.type) {
|
||||
let toAddress;
|
||||
if (wallet?.refill_addressess.length > 0) {
|
||||
toAddress = wallet.refill_addressess[0];
|
||||
} else {
|
||||
try {
|
||||
await wallet?.fetchBtcAddress();
|
||||
toAddress = wallet?.refill_addressess[0];
|
||||
} catch (Err) {
|
||||
return presentAlert({ message: (Err as Error).message, type: AlertType.Toast });
|
||||
}
|
||||
}
|
||||
navigate('SendDetailsRoot', {
|
||||
screen: 'SendDetails',
|
||||
params: {
|
||||
memo: loc.lnd.refill_lnd_balance,
|
||||
address: toAddress,
|
||||
walletID: selectedWallet.getID(),
|
||||
},
|
||||
});
|
||||
assert(wallet?.type === LightningCustodianWallet.type, `internal error, wallet is not ${LightningCustodianWallet.type}`);
|
||||
navigate('WalletTransactions', {
|
||||
walletType: wallet?.type,
|
||||
walletID: wallet?.getID(),
|
||||
key: `WalletTransactions-${wallet?.getID()}`,
|
||||
}); // navigating back to ln wallet screen
|
||||
|
||||
// getting refill address, either cached or from the server:
|
||||
let toAddress;
|
||||
if (wallet?.refill_addressess.length > 0) {
|
||||
toAddress = wallet.refill_addressess[0];
|
||||
} else {
|
||||
try {
|
||||
await wallet?.fetchBtcAddress();
|
||||
toAddress = wallet?.refill_addressess[0];
|
||||
} catch (Err) {
|
||||
return presentAlert({ message: (Err as Error).message, type: AlertType.Toast });
|
||||
}
|
||||
}
|
||||
|
||||
// navigating to pay screen where user can pay to refill address:
|
||||
navigate('SendDetailsRoot', {
|
||||
screen: 'SendDetails',
|
||||
params: {
|
||||
memo: loc.lnd.refill_lnd_balance,
|
||||
address: toAddress,
|
||||
walletID: selectedWallet.getID(),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const navigateToViewEditCosigners = () => {
|
||||
@ -222,7 +225,7 @@ const WalletTransactions: React.FC<WalletTransactionsProps> = ({ route }) => {
|
||||
if (availableWallets.length === 0) {
|
||||
presentAlert({ message: loc.lnd.refill_create });
|
||||
} else {
|
||||
navigate('SelectWallet', { onWalletSelect, chainType: Chain.ONCHAIN });
|
||||
selectWallet(navigate, name, Chain.ONCHAIN).then(onWalletSelect);
|
||||
}
|
||||
} else if (id === actionKeys.RefillWithExternalWallet) {
|
||||
navigate('ReceiveDetailsRoot', {
|
||||
|
Loading…
Reference in New Issue
Block a user