mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-21 22:42:21 +01:00
REF: improved RBF
This commit is contained in:
parent
4606634e5a
commit
c88b6ee113
5 changed files with 62 additions and 24 deletions
|
@ -40,6 +40,10 @@ export class AbstractWallet {
|
|||
return true;
|
||||
}
|
||||
|
||||
allowRBF() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns delta of unconfirmed balance. For example, if theres no
|
||||
* unconfirmed balance its 0
|
||||
|
|
|
@ -9,6 +9,10 @@ export class SegwitP2SHWallet extends LegacyWallet {
|
|||
this.type = 'segwitP2SH';
|
||||
}
|
||||
|
||||
allowRBF() {
|
||||
return true;
|
||||
}
|
||||
|
||||
getTypeReadable() {
|
||||
return 'SegWit (P2SH)';
|
||||
}
|
||||
|
|
|
@ -2,17 +2,26 @@
|
|||
import React, { Component } from 'react';
|
||||
import { TextInput } from 'react-native';
|
||||
import { Text, FormValidationMessage } from 'react-native-elements';
|
||||
import { BlueLoading, BlueSpacing20, BlueButton, SafeBlueArea, BlueCard, BlueText, BlueSpacing } from '../../BlueComponents';
|
||||
import {
|
||||
BlueLoading,
|
||||
BlueSpacing20,
|
||||
BlueButton,
|
||||
SafeBlueArea,
|
||||
BlueCard,
|
||||
BlueText,
|
||||
BlueSpacing,
|
||||
BlueNavigationStyle,
|
||||
} from '../../BlueComponents';
|
||||
import PropTypes from 'prop-types';
|
||||
let BigNumber = require('bignumber.js');
|
||||
let bitcoinjs = require('bitcoinjs-lib');
|
||||
let BlueApp = require('../../BlueApp');
|
||||
|
||||
export default class SendCreate extends Component {
|
||||
static navigationOptions = {
|
||||
tabBarVisible: false,
|
||||
};
|
||||
|
||||
static navigationOptions = () => ({
|
||||
...BlueNavigationStyle(null, false),
|
||||
title: 'Create RBF',
|
||||
});
|
||||
constructor(props) {
|
||||
super(props);
|
||||
console.log('send/create constructor');
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
import React, { Component } from 'react';
|
||||
import { ActivityIndicator, View } from 'react-native';
|
||||
import { BlueSpacing20, BlueButton, SafeBlueArea, BlueCard, BlueText, BlueFormInput, BlueSpacing } from '../../BlueComponents';
|
||||
import {
|
||||
BlueSpacing20,
|
||||
BlueButton,
|
||||
SafeBlueArea,
|
||||
BlueCard,
|
||||
BlueText,
|
||||
BlueFormInput,
|
||||
BlueSpacing,
|
||||
BlueNavigationStyle,
|
||||
} from '../../BlueComponents';
|
||||
import PropTypes from 'prop-types';
|
||||
/** @type {AppStorage} */
|
||||
let BlueApp = require('../../BlueApp');
|
||||
|
||||
export default class RBF extends Component {
|
||||
static navigationOptions = {
|
||||
tabBarVisible: false,
|
||||
};
|
||||
static navigationOptions = () => ({
|
||||
...BlueNavigationStyle(null, false),
|
||||
title: 'RBF',
|
||||
});
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
|
|
@ -61,11 +61,22 @@ export default class TransactionsDetails extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
let wallet = false;
|
||||
for (let w of BlueApp.getWallets()) {
|
||||
for (let t of w.getTransactions()) {
|
||||
if (t.hash === hash) {
|
||||
console.log('tx', hash, 'belongs to', w.getLabel());
|
||||
wallet = w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.state = {
|
||||
isLoading: true,
|
||||
tx: foundTx,
|
||||
from,
|
||||
to,
|
||||
wallet,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -85,6 +96,21 @@ export default class TransactionsDetails extends Component {
|
|||
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
||||
<BlueHeaderDefaultSub leftText={loc.transactions.details.title} rightComponent={null} />
|
||||
<ScrollView style={{ flex: 1 }}>
|
||||
{(() => {
|
||||
if (this.state.tx.confirmations === 0 && this.state.wallet && this.state.wallet.allowRBF()) {
|
||||
return (
|
||||
<BlueButton
|
||||
onPress={() =>
|
||||
this.props.navigation.navigate('RBF', {
|
||||
txid: this.state.tx.hash,
|
||||
})
|
||||
}
|
||||
title="Replace-By-Fee (RBF)"
|
||||
/>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
|
||||
<BlueCard>
|
||||
{(() => {
|
||||
if (BlueApp.tx_metadata[this.state.tx.hash]) {
|
||||
|
@ -176,21 +202,6 @@ export default class TransactionsDetails extends Component {
|
|||
</React.Fragment>
|
||||
)}
|
||||
</BlueCard>
|
||||
|
||||
{(() => {
|
||||
if (this.state.tx.confirmations === 0) {
|
||||
return (
|
||||
<BlueButton
|
||||
onPress={() =>
|
||||
this.props.navigation.navigate('RBF', {
|
||||
txid: this.state.tx.hash,
|
||||
})
|
||||
}
|
||||
title="Replace-By-Fee (RBF)"
|
||||
/>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</ScrollView>
|
||||
</SafeBlueArea>
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue