Browse Source

REF: improved RBF

localNotifications
Overtorment 6 years ago
parent
commit
c88b6ee113
  1. 4
      class/abstract-wallet.js
  2. 4
      class/segwit-p2sh-wallet.js
  3. 19
      screen/transactions/RBF-create.js
  4. 18
      screen/transactions/RBF.js
  5. 41
      screen/transactions/details.js

4
class/abstract-wallet.js

@ -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

4
class/segwit-p2sh-wallet.js

@ -9,6 +9,10 @@ export class SegwitP2SHWallet extends LegacyWallet {
this.type = 'segwitP2SH';
}
allowRBF() {
return true;
}
getTypeReadable() {
return 'SegWit (P2SH)';
}

19
screen/transactions/RBF-create.js

@ -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');

18
screen/transactions/RBF.js

@ -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);

41
screen/transactions/details.js

@ -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…
Cancel
Save