mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
Merge pull request #2586 from BlueWallet/2555
This commit is contained in:
commit
f6c6be0577
@ -1265,7 +1265,7 @@ export const BlueReceiveButtonIcon = props => {
|
||||
);
|
||||
};
|
||||
|
||||
export const BlueTransactionListItem = React.memo(({ item, itemPriceUnit = BitcoinUnit.BTC, timeElapsed }) => {
|
||||
export const BlueTransactionListItem = React.memo(({ item, itemPriceUnit = BitcoinUnit.BTC, walletID }) => {
|
||||
const [subtitleNumberOfLines, setSubtitleNumberOfLines] = useState(1);
|
||||
const { colors } = useTheme();
|
||||
const { navigate } = useNavigation();
|
||||
@ -1422,46 +1422,38 @@ export const BlueTransactionListItem = React.memo(({ item, itemPriceUnit = Bitco
|
||||
|
||||
const onPress = useCallback(async () => {
|
||||
if (item.hash) {
|
||||
navigate('TransactionStatus', { hash: item.hash });
|
||||
navigate('TransactionStatus', { hash: item.hash, walletID });
|
||||
} else if (item.type === 'user_invoice' || item.type === 'payment_request' || item.type === 'paid_invoice') {
|
||||
const lightningWallet = wallets.filter(wallet => {
|
||||
if (typeof wallet === 'object') {
|
||||
if ('secret' in wallet) {
|
||||
return wallet.getSecret() === item.fromWallet;
|
||||
}
|
||||
try {
|
||||
// is it a successful lnurl-pay?
|
||||
const LN = new Lnurl(false, AsyncStorage);
|
||||
let paymentHash = item.payment_hash;
|
||||
if (typeof paymentHash === 'object') {
|
||||
paymentHash = Buffer.from(paymentHash.data).toString('hex');
|
||||
}
|
||||
});
|
||||
if (lightningWallet.length === 1) {
|
||||
try {
|
||||
// is it a successful lnurl-pay?
|
||||
const LN = new Lnurl(false, AsyncStorage);
|
||||
let paymentHash = item.payment_hash;
|
||||
if (typeof paymentHash === 'object') {
|
||||
paymentHash = Buffer.from(paymentHash.data).toString('hex');
|
||||
}
|
||||
const loaded = await LN.loadSuccessfulPayment(paymentHash);
|
||||
if (loaded) {
|
||||
NavigationService.navigate('ScanLndInvoiceRoot', {
|
||||
screen: 'LnurlPaySuccess',
|
||||
params: {
|
||||
paymentHash,
|
||||
justPaid: false,
|
||||
fromWalletID: lightningWallet[0].getID(),
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
const loaded = await LN.loadSuccessfulPayment(paymentHash);
|
||||
if (loaded) {
|
||||
NavigationService.navigate('ScanLndInvoiceRoot', {
|
||||
screen: 'LnurlPaySuccess',
|
||||
params: {
|
||||
paymentHash,
|
||||
justPaid: false,
|
||||
fromWalletID: walletID,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
navigate('LNDViewInvoice', {
|
||||
invoice: item,
|
||||
walletID: lightningWallet[0].getID(),
|
||||
isModal: false,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
navigate('LNDViewInvoice', {
|
||||
invoice: item,
|
||||
walletID,
|
||||
isModal: false,
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [item, wallets]);
|
||||
|
||||
@ -1484,7 +1476,7 @@ export const BlueTransactionListItem = React.memo(({ item, itemPriceUnit = Bitco
|
||||
onPress={onPress}
|
||||
onLongPress={onLongPress}
|
||||
chevron={false}
|
||||
Component={TouchableOpacity}
|
||||
Component={item.type === 'bitcoind_tx' ? View : TouchableOpacity}
|
||||
rightTitle={rowTitle}
|
||||
rightTitleStyle={rowTitleStyle}
|
||||
containerStyle={containerStyle}
|
||||
|
@ -567,6 +567,7 @@ export class AppStorage {
|
||||
const walletTransactions = wallet.getTransactions();
|
||||
for (const t of walletTransactions) {
|
||||
t.walletPreferredBalanceUnit = wallet.getPreferredBalanceUnit();
|
||||
t.walletID = wallet.getID();
|
||||
}
|
||||
txs = txs.concat(walletTransactions);
|
||||
}
|
||||
|
@ -251,13 +251,13 @@ PODS:
|
||||
- React
|
||||
- react-native-blur (0.8.0):
|
||||
- React
|
||||
- react-native-camera (3.40.0):
|
||||
- react-native-camera (3.42.0):
|
||||
- React-Core
|
||||
- react-native-camera/RCT (= 3.40.0)
|
||||
- react-native-camera/RN (= 3.40.0)
|
||||
- react-native-camera/RCT (3.40.0):
|
||||
- react-native-camera/RCT (= 3.42.0)
|
||||
- react-native-camera/RN (= 3.42.0)
|
||||
- react-native-camera/RCT (3.42.0):
|
||||
- React-Core
|
||||
- react-native-camera/RN (3.40.0):
|
||||
- react-native-camera/RN (3.42.0):
|
||||
- React-Core
|
||||
- react-native-document-picker (3.5.4):
|
||||
- React
|
||||
@ -367,7 +367,7 @@ PODS:
|
||||
- React
|
||||
- RNInAppBrowser (3.5.1):
|
||||
- React-Core
|
||||
- RNLocalize (1.4.2):
|
||||
- RNLocalize (2.0.1):
|
||||
- React-Core
|
||||
- RNPrivacySnapshot (1.0.0):
|
||||
- React
|
||||
@ -379,14 +379,14 @@ PODS:
|
||||
- React-Core
|
||||
- RNReanimated (1.13.1):
|
||||
- React
|
||||
- RNScreens (2.11.0):
|
||||
- React
|
||||
- RNScreens (2.16.1):
|
||||
- React-Core
|
||||
- RNSecureKeyStore (1.0.0):
|
||||
- React
|
||||
- RNSentry (1.9.0):
|
||||
- React-Core
|
||||
- Sentry (~> 5.2.0)
|
||||
- RNShare (4.0.2):
|
||||
- RNShare (5.1.0):
|
||||
- React-Core
|
||||
- RNSVG (12.1.0):
|
||||
- React
|
||||
@ -699,7 +699,7 @@ SPEC CHECKSUMS:
|
||||
React-jsinspector: 8e68ffbfe23880d3ee9bafa8be2777f60b25cbe2
|
||||
react-native-blue-crypto: 23f1558ad3d38d7a2edb7e2f6ed1bc520ed93e56
|
||||
react-native-blur: cad4d93b364f91e7b7931b3fa935455487e5c33c
|
||||
react-native-camera: 5c1fbfecf63b802b8ca4a71c60d30a71550fb348
|
||||
react-native-camera: d145df27a9178041b48b839b80ad79c9ef373fbd
|
||||
react-native-document-picker: c5752781fbc0c126c627c1549b037c139444a4cf
|
||||
react-native-fingerprint-scanner: c68136ca57e3704d7bdf5faa554ea535ce15b1d0
|
||||
react-native-idle-timer: 97b8283237d45146a7a5c25bdebe9e1e85f3687b
|
||||
@ -733,16 +733,16 @@ SPEC CHECKSUMS:
|
||||
RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39
|
||||
RNHandoff: d3b0754cca3a6bcd9b25f544f733f7f033ccf5fa
|
||||
RNInAppBrowser: 3733c1aa6699983a1c9b4963e85d5e5a48ad297e
|
||||
RNLocalize: 4071198b59b461f3b74eebc5fee8c50f13e39e79
|
||||
RNLocalize: dcf0fdb332b37b0d24178e876a7ce4dbbc9c838d
|
||||
RNPrivacySnapshot: 71919dde3c6a29dd332115409c2aec564afee8f4
|
||||
RNQuickAction: 6d404a869dc872cde841ad3147416a670d13fa93
|
||||
RNRate: 2b31dad120cd1b78e33c6034808561c386a3dddf
|
||||
RNReactNativeHapticFeedback: 653a8c126a0f5e88ce15ffe280b3ff37e1fbb285
|
||||
RNReanimated: dd8c286ab5dd4ba36d3a7fef8bff7e08711b5476
|
||||
RNScreens: 0e91da98ab26d5d04c7b59a9b6bd694124caf88c
|
||||
RNScreens: 45c457af3d2ee9e08fc01e70da87e653d46b1198
|
||||
RNSecureKeyStore: f1ad870e53806453039f650720d2845c678d89c8
|
||||
RNSentry: 1adaa43b01c6a3ab5091d4d1add66b7c58558898
|
||||
RNShare: 7a7277f3c313652422d9de072ac50714dff5e8a4
|
||||
RNShare: fed99fd743f80ca255903c1da46fc9a6430efab6
|
||||
RNSVG: ce9d996113475209013317e48b05c21ee988d42e
|
||||
RNVectorIcons: bc69e6a278b14842063605de32bec61f0b251a59
|
||||
RNWatch: e4c5d19506c94506860032fb68aedd5991beb985
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -20149,6 +20149,10 @@
|
||||
"object-assign": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"scryptsy": {
|
||||
"version": "file:blue_modules/scryptsy",
|
||||
"integrity": "sha512-1CdSqHQowJBnMAFyPEBRfqag/YP9OF394FV+4YREIJX4ljD7OxvQRDayyoyyCk+senRjSkP6VnUNQmVQqB6g7w=="
|
||||
},
|
||||
"secp256k1": {
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.8.0.tgz",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useContext, useEffect, useRef, useState } from 'react';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { View, ActivityIndicator, Text, TouchableOpacity, StyleSheet, StatusBar } from 'react-native';
|
||||
import { Icon } from 'react-native-elements';
|
||||
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
|
||||
@ -28,16 +28,16 @@ const buttonStatus = Object.freeze({
|
||||
notPossible: 3,
|
||||
});
|
||||
|
||||
const TransactionsStatus = () => {
|
||||
const TransactionStatus = () => {
|
||||
const { setSelectedWallet, wallets, txMetadata, getTransactions } = useContext(BlueStorageContext);
|
||||
const { hash } = useRoute().params;
|
||||
const { hash, walletID } = useRoute().params;
|
||||
const { navigate, setOptions } = useNavigation();
|
||||
const { colors } = useTheme();
|
||||
const wallet = useRef();
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
const [isCPFPPossible, setIsCPFPPossible] = useState();
|
||||
const [isRBFBumpFeePossible, setIsRBFBumpFeePossible] = useState();
|
||||
const [isRBFCancelPossible, setIsRBFCancelPossible] = useState();
|
||||
const [tx, setTX] = useState();
|
||||
const tx = getTransactions(null, Infinity, true).find(transactionHash => transactionHash.hash === hash);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const stylesHook = StyleSheet.create({
|
||||
root: {
|
||||
@ -76,27 +76,6 @@ const TransactionsStatus = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [colors]);
|
||||
|
||||
useEffect(() => {
|
||||
for (const w of wallets) {
|
||||
for (const t of w.getTransactions()) {
|
||||
if (t.hash === hash) {
|
||||
console.log('tx', hash, 'belongs to', w.getLabel());
|
||||
wallet.current = w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const tx of getTransactions(null, Infinity, true)) {
|
||||
if (tx.hash === hash) {
|
||||
setTX(tx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [hash]);
|
||||
|
||||
const initialState = async () => {
|
||||
try {
|
||||
await checkPossibilityOfCPFP();
|
||||
@ -118,7 +97,7 @@ const TransactionsStatus = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (wallet) {
|
||||
setSelectedWallet(wallet.current.getID());
|
||||
setSelectedWallet(wallet.getID());
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet]);
|
||||
@ -128,11 +107,11 @@ const TransactionsStatus = () => {
|
||||
}, []);
|
||||
|
||||
const checkPossibilityOfCPFP = async () => {
|
||||
if (!wallet.current.allowRBF()) {
|
||||
if (!wallet.allowRBF()) {
|
||||
return setIsCPFPPossible(buttonStatus.notPossible);
|
||||
}
|
||||
|
||||
const cpfbTx = new HDSegwitBech32Transaction(null, tx.hash, wallet.current);
|
||||
const cpfbTx = new HDSegwitBech32Transaction(null, tx.hash, wallet);
|
||||
if ((await cpfbTx.isToUsTransaction()) && (await cpfbTx.getRemoteConfirmationsNum()) === 0) {
|
||||
return setIsCPFPPossible(buttonStatus.possible);
|
||||
} else {
|
||||
@ -141,11 +120,11 @@ const TransactionsStatus = () => {
|
||||
};
|
||||
|
||||
const checkPossibilityOfRBFBumpFee = async () => {
|
||||
if (!wallet.current.allowRBF()) {
|
||||
if (!wallet.allowRBF()) {
|
||||
return setIsRBFBumpFeePossible(buttonStatus.notPossible);
|
||||
}
|
||||
|
||||
const rbfTx = new HDSegwitBech32Transaction(null, tx.hash, wallet.current);
|
||||
const rbfTx = new HDSegwitBech32Transaction(null, tx.hash, wallet);
|
||||
if (
|
||||
(await rbfTx.isOurTransaction()) &&
|
||||
(await rbfTx.getRemoteConfirmationsNum()) === 0 &&
|
||||
@ -159,11 +138,11 @@ const TransactionsStatus = () => {
|
||||
};
|
||||
|
||||
const checkPossibilityOfRBFCancel = async () => {
|
||||
if (!wallet.current.allowRBF()) {
|
||||
if (!wallet.allowRBF()) {
|
||||
return setIsRBFCancelPossible(buttonStatus.notPossible);
|
||||
}
|
||||
|
||||
const rbfTx = new HDSegwitBech32Transaction(null, tx.hash, wallet.current);
|
||||
const rbfTx = new HDSegwitBech32Transaction(null, tx.hash, wallet);
|
||||
if (
|
||||
(await rbfTx.isOurTransaction()) &&
|
||||
(await rbfTx.getRemoteConfirmationsNum()) === 0 &&
|
||||
@ -179,21 +158,21 @@ const TransactionsStatus = () => {
|
||||
const navigateToRBFBumpFee = () => {
|
||||
navigate('RBFBumpFee', {
|
||||
txid: tx.hash,
|
||||
wallet: wallet.current,
|
||||
wallet: wallet,
|
||||
});
|
||||
};
|
||||
|
||||
const navigateToRBFCancel = () => {
|
||||
navigate('RBFCancel', {
|
||||
txid: tx.hash,
|
||||
wallet: wallet.current,
|
||||
wallet: wallet,
|
||||
});
|
||||
};
|
||||
|
||||
const navigateToCPFP = () => {
|
||||
navigate('CPFP', {
|
||||
txid: tx.hash,
|
||||
wallet: wallet.current,
|
||||
wallet: wallet,
|
||||
});
|
||||
};
|
||||
const navigateToTransactionDetials = () => {
|
||||
@ -290,9 +269,9 @@ const TransactionsStatus = () => {
|
||||
<BlueCard>
|
||||
<View style={styles.center}>
|
||||
<Text style={[styles.value, stylesHook.value]}>
|
||||
{formatBalanceWithoutSuffix(tx.value, wallet.current.preferredBalanceUnit, true)}{' '}
|
||||
{wallet.current.preferredBalanceUnit !== BitcoinUnit.LOCAL_CURRENCY && (
|
||||
<Text style={[styles.valueUnit, stylesHook.valueUnit]}>{loc.units[wallet.current.preferredBalanceUnit]}</Text>
|
||||
{formatBalanceWithoutSuffix(tx.value, wallet.preferredBalanceUnit, true)}{' '}
|
||||
{wallet.preferredBalanceUnit !== BitcoinUnit.LOCAL_CURRENCY && (
|
||||
<Text style={[styles.valueUnit, stylesHook.valueUnit]}>{loc.units[wallet.preferredBalanceUnit]}</Text>
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
@ -331,8 +310,8 @@ const TransactionsStatus = () => {
|
||||
{tx.fee && (
|
||||
<View style={styles.fee}>
|
||||
<BlueText style={styles.feeText}>
|
||||
{loc.send.create_fee.toLowerCase()} {formatBalanceWithoutSuffix(tx.fee, wallet.current.preferredBalanceUnit, true)}{' '}
|
||||
{wallet.current.preferredBalanceUnit !== BitcoinUnit.LOCAL_CURRENCY && wallet.current.preferredBalanceUnit}
|
||||
{loc.send.create_fee.toLowerCase()} {formatBalanceWithoutSuffix(tx.fee, wallet.preferredBalanceUnit, true)}{' '}
|
||||
{wallet.preferredBalanceUnit !== BitcoinUnit.LOCAL_CURRENCY && wallet.preferredBalanceUnit}
|
||||
</BlueText>
|
||||
</View>
|
||||
)}
|
||||
@ -360,7 +339,7 @@ const TransactionsStatus = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default TransactionsStatus;
|
||||
export default TransactionStatus;
|
||||
const styles = StyleSheet.create({
|
||||
root: {
|
||||
flex: 1,
|
||||
@ -460,6 +439,6 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
TransactionsStatus.navigationOptions = navigationStyle({
|
||||
TransactionStatus.navigationOptions = navigationStyle({
|
||||
title: '',
|
||||
});
|
||||
|
@ -225,7 +225,7 @@ const WalletsList = () => {
|
||||
const renderTransactionListsRow = data => {
|
||||
return (
|
||||
<View style={styles.transaction}>
|
||||
<BlueTransactionListItem item={data.item} itemPriceUnit={data.item.walletPreferredBalanceUnit} />
|
||||
<BlueTransactionListItem item={data.item} itemPriceUnit={data.item.walletPreferredBalanceUnit} walletID={data.item.walletID} />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
@ -437,7 +437,9 @@ const WalletTransactions = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const renderItem = item => <BlueTransactionListItem item={item.item} itemPriceUnit={itemPriceUnit} timeElapsed={timeElapsed} />;
|
||||
const renderItem = item => (
|
||||
<BlueTransactionListItem item={item.item} itemPriceUnit={itemPriceUnit} timeElapsed={timeElapsed} walletID={walletID} />
|
||||
);
|
||||
|
||||
const onBarCodeRead = ret => {
|
||||
if (!isLoading) {
|
||||
|
Loading…
Reference in New Issue
Block a user