mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 06:52:41 +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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allowRBF() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns delta of unconfirmed balance. For example, if theres no
|
* Returns delta of unconfirmed balance. For example, if theres no
|
||||||
* unconfirmed balance its 0
|
* unconfirmed balance its 0
|
||||||
|
|
|
@ -9,6 +9,10 @@ export class SegwitP2SHWallet extends LegacyWallet {
|
||||||
this.type = 'segwitP2SH';
|
this.type = 'segwitP2SH';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allowRBF() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
getTypeReadable() {
|
getTypeReadable() {
|
||||||
return 'SegWit (P2SH)';
|
return 'SegWit (P2SH)';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,26 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { TextInput } from 'react-native';
|
import { TextInput } from 'react-native';
|
||||||
import { Text, FormValidationMessage } from 'react-native-elements';
|
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';
|
import PropTypes from 'prop-types';
|
||||||
let BigNumber = require('bignumber.js');
|
let BigNumber = require('bignumber.js');
|
||||||
let bitcoinjs = require('bitcoinjs-lib');
|
let bitcoinjs = require('bitcoinjs-lib');
|
||||||
let BlueApp = require('../../BlueApp');
|
let BlueApp = require('../../BlueApp');
|
||||||
|
|
||||||
export default class SendCreate extends Component {
|
export default class SendCreate extends Component {
|
||||||
static navigationOptions = {
|
static navigationOptions = () => ({
|
||||||
tabBarVisible: false,
|
...BlueNavigationStyle(null, false),
|
||||||
};
|
title: 'Create RBF',
|
||||||
|
});
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
console.log('send/create constructor');
|
console.log('send/create constructor');
|
||||||
|
|
|
@ -1,14 +1,24 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { ActivityIndicator, View } from 'react-native';
|
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';
|
import PropTypes from 'prop-types';
|
||||||
/** @type {AppStorage} */
|
/** @type {AppStorage} */
|
||||||
let BlueApp = require('../../BlueApp');
|
let BlueApp = require('../../BlueApp');
|
||||||
|
|
||||||
export default class RBF extends Component {
|
export default class RBF extends Component {
|
||||||
static navigationOptions = {
|
static navigationOptions = () => ({
|
||||||
tabBarVisible: false,
|
...BlueNavigationStyle(null, false),
|
||||||
};
|
title: 'RBF',
|
||||||
|
});
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(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 = {
|
this.state = {
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
tx: foundTx,
|
tx: foundTx,
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
|
wallet,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +96,21 @@ export default class TransactionsDetails extends Component {
|
||||||
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
||||||
<BlueHeaderDefaultSub leftText={loc.transactions.details.title} rightComponent={null} />
|
<BlueHeaderDefaultSub leftText={loc.transactions.details.title} rightComponent={null} />
|
||||||
<ScrollView style={{ flex: 1 }}>
|
<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>
|
<BlueCard>
|
||||||
{(() => {
|
{(() => {
|
||||||
if (BlueApp.tx_metadata[this.state.tx.hash]) {
|
if (BlueApp.tx_metadata[this.state.tx.hash]) {
|
||||||
|
@ -176,21 +202,6 @@ export default class TransactionsDetails extends Component {
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
</BlueCard>
|
</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>
|
</ScrollView>
|
||||||
</SafeBlueArea>
|
</SafeBlueArea>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue