FIX: import *.txn file with txhex - extra newline characted prevented it from being recognized (closes #2161)

This commit is contained in:
Overtorment 2020-11-27 16:35:14 +00:00
parent 81c96cc42c
commit c99a2ba296
3 changed files with 25 additions and 3 deletions

View file

@ -922,7 +922,8 @@ export default class SendDetails extends Component {
this.setState({ isLoading: false, isAdvancedTransactionOptionsVisible: false });
} else if (DeeplinkSchemaMatch.isTXNFile(res.uri)) {
// plain text file with txhex ready to broadcast
const file = await RNFS.readFile(res.uri, 'ascii');
const file = (await RNFS.readFile(res.uri, 'ascii')).replace('\n', '').replace('\r', '');
console.warn(JSON.stringify(file));
this.props.navigation.navigate('PsbtWithHardwareWallet', {
memo: this.state.memo,
fromWallet: this.state.fromWallet,

View file

@ -131,8 +131,9 @@ const PsbtWithHardwareWallet = () => {
if (memo) {
txMetadata[txid] = { memo };
}
fetchAndSaveWalletTransactions(fromWallet.getID());
navigation.navigate('Success', { amount: undefined });
await new Promise(resolve => setTimeout(resolve, 3000)); // sleep to make sure network propagates
fetchAndSaveWalletTransactions(fromWallet.getID());
} else {
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
setIsLoading(false);

View file

@ -302,6 +302,24 @@ const WalletDetails = () => {
}
};
const purgeTransactions = async () => {
if (backdoorPressed < 10) return setBackdoorPressed(backdoorPressed + 1);
setBackdoorPressed(0);
const msg = 'Transactions purged. Pls go to main screen and back to rerender screen';
if (wallet.type === HDSegwitBech32Wallet.type) {
wallet._txs_by_external_index = {};
wallet._txs_by_internal_index = {};
alert(msg);
}
if (wallet._hdWalletInstance) {
wallet._hdWalletInstance._txs_by_external_index = {};
wallet._hdWalletInstance._txs_by_internal_index = {};
alert(msg);
}
};
const navigateToBroadcast = () => {
navigate('Broadcast');
};
@ -435,7 +453,9 @@ const WalletDetails = () => {
</View>
</>
<>
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.transactions.transactions_count.toLowerCase()}</Text>
<Text onPress={purgeTransactions} style={[styles.textLabel2, stylesHook.textLabel2]}>
{loc.transactions.transactions_count.toLowerCase()}
</Text>
<BlueText>{wallet.getTransactions().length}</BlueText>
</>
<View>