diff --git a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.html b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.html index ae2ad92b8..3442cfb6d 100644 --- a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.html +++ b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.html @@ -7,12 +7,14 @@
- Each bitcoin wallet can generate billions of addresses from your 12-word backup. - A new address is automatically generated and shown each time you receive a payment. - Why? + Each bitcoin wallet can generate billions of addresses from your 12-word backup. A new address is automatically generated + and shown each time you receive a payment. + + Why?
- It's a good idea to avoid reusing addresses - this both protects your privacy and keeps your bitcoins secure against hypothetical attacks by quantum computers. + It's a good idea to avoid reusing addresses - this both protects your privacy and keeps your bitcoins secure against + hypothetical attacks by quantum computers. Hide
@@ -41,10 +43,14 @@
Unused addresses limit
-

The maximum number of consecutive unused addresses (20) has been reached. When one of your unused addresses receives a payment, a new address will be generated and shown in your Receive tab.  +

+ The maximum number of consecutive unused addresses (20) has been reached. When one of your unused addresses receives + a payment, a new address will be generated and shown in your Receive tab.  Read more

-

The restore process will stop when 20 addresses are generated in a row which contain no funds. To safely generate more addresses, make a payment to one of the unused addresses which has already been generated.  +

+ The restore process will stop when 20 addresses are generated in a row which contain no funds. To safely generate + more addresses, make a payment to one of the unused addresses which has already been generated.  Read less

@@ -65,7 +71,7 @@
- {{'Wallet Inputs' | translate}} + {{'Wallet Inputs' | translate}} Total wallet inputs diff --git a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.ts b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.ts index e91bc8320..d07681994 100644 --- a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.ts +++ b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-addresses/wallet-addresses.ts @@ -8,6 +8,7 @@ import { WalletProvider } from '../../../../../providers/wallet/wallet'; import { BwcErrorProvider } from '../../../../../providers/bwc-error/bwc-error'; import { PopupProvider } from '../../../../../providers/popup/popup'; import { OnGoingProcessProvider } from '../../../../../providers/on-going-process/on-going-process'; +import { TxFormatProvider } from '../../../../../providers/tx-format/tx-format'; //pages import { AllAddressesPage } from './all-addresses/all-addresses'; @@ -28,6 +29,13 @@ export class WalletAddressesPage { public latestWithBalance: any; public viewAll: boolean; public gapReached: boolean; + public lowUtxosNb: number; + public allUtxosNb: number; + public lowUtxosSum: string; + public allUtxosSum: string; + public minFee: string; + public minFeePer: string; + private UNUSED_ADDRESS_LIMIT: number; private BALANCE_ADDRESS_LIMIT: number; private withBalance: any; @@ -43,6 +51,7 @@ export class WalletAddressesPage { private popupProvider: PopupProvider, private onGoingProcessProvider: OnGoingProcessProvider, private modalCtrl: ModalController, + private txFormatProvider: TxFormatProvider ) { this.UNUSED_ADDRESS_LIMIT = 5; this.BALANCE_ADDRESS_LIMIT = 5; @@ -79,6 +88,26 @@ export class WalletAddressesPage { this.loading = false; this.popupProvider.ionicAlert(this.bwcErrorProvider.msg(err, 'Could not update wallet')); //TODO gettextcatalog }); + + this.walletProvider.getLowUtxos(this.wallet).then((resp) => { + + if (resp && resp.allUtxos && resp.allUtxos.length) { + + let allSum = _.sumBy(resp.allUtxos || 0, 'satoshis'); + let per = (resp.minFee / allSum) * 100; + + this.lowUtxosNb = resp.lowUtxos.length; + this.allUtxosNb = resp.allUtxos.length; + this.lowUtxosSum = this.txFormatProvider.formatAmountStr(this.wallet.coin, _.sumBy(resp.lowUtxos || 0, 'satoshis')); + this.allUtxosSum = this.txFormatProvider.formatAmountStr(this.wallet.coin, allSum); + this.minFee = this.txFormatProvider.formatAmountStr(this.wallet.coin, resp.minFee || 0); + this.minFeePer = per.toFixed(2) + '%'; + + } + }).catch((err) => { + this.logger.warn(err); + }); + } private processPaths(list: any): void { diff --git a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.html b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.html index b2486d882..671325041 100644 --- a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.html +++ b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.html @@ -10,11 +10,13 @@ Wallet Service URL -
- {{appName}} depends on Bitcore Wallet Service (BWS) for blockchain information, networking and Copayer synchronization. The - default configuration points to https://bws.bitpay.com (BitPay's public BWS instance). +
+ {{appName}} depends on Bitcore Wallet Service (BWS) for blockchain information, networking and Copayer synchronization. + The default configuration points to https://bws.bitpay.com (BitPay's public BWS instance). + + Use default url +
- \ No newline at end of file diff --git a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.scss b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.scss index e69de29bb..f11c8af5f 100644 --- a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.scss +++ b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.scss @@ -0,0 +1,5 @@ +page-wallet-service-url { + .comment { + padding: 20px; + } +} \ No newline at end of file diff --git a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.html b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.html index 1eed982d0..235ee6e65 100644 --- a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.html +++ b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.html @@ -5,7 +5,7 @@ - + - -
+ +
The transaction history and every new incoming transaction are cached in the app. This feature clean this up and synchronizes again from the server
diff --git a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.scss b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.scss index 205d3e76a..9b4b03d62 100644 --- a/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.scss +++ b/src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-transaction-history/wallet-transaction-history.scss @@ -3,5 +3,8 @@ page-wallet-transaction-history { &.item { color: color($colors, primary) !important; } - } + } + .comment { + padding: 20px; + } } \ No newline at end of file diff --git a/src/providers/fee/fee.ts b/src/providers/fee/fee.ts index fb54dd333..bbb434904 100644 --- a/src/providers/fee/fee.ts +++ b/src/providers/fee/fee.ts @@ -24,6 +24,7 @@ export class FeeProvider { updateTs: 0, coin: '' } + constructor( private configProvider: ConfigProvider, private logger: Logger, @@ -106,5 +107,4 @@ export class FeeProvider { }); } - } diff --git a/src/providers/profile/profile.ts b/src/providers/profile/profile.ts index 7fc11dd5f..3ee1ebc79 100644 --- a/src/providers/profile/profile.ts +++ b/src/providers/profile/profile.ts @@ -55,8 +55,6 @@ export class ProfileProvider { public setWalletOrder(walletId: string, index: number): void { this.persistenceProvider.setWalletOrder(walletId, index); this.logger.debug('Wallet new order stored'); - console.log(this.wallet); - console.log(walletId); this.wallet[walletId].order = index; } diff --git a/src/providers/wallet/wallet.ts b/src/providers/wallet/wallet.ts index daa290412..af29d81cb 100644 --- a/src/providers/wallet/wallet.ts +++ b/src/providers/wallet/wallet.ts @@ -14,6 +14,7 @@ import { OnGoingProcessProvider } from '../on-going-process/on-going-process'; import { TouchIdProvider } from '../touchid/touchid'; import * as lodash from 'lodash'; +import { FeeProvider } from '../fee/fee'; /* TODO LIST: @@ -55,7 +56,8 @@ export class WalletProvider { private popupProvider: PopupProvider, private ongoingProcess: OnGoingProcessProvider, private touchidProvider: TouchIdProvider, - private events: Events + private events: Events, + private feeProvider: FeeProvider ) { this.logger.info('WalletService initialized.'); } @@ -426,7 +428,7 @@ export class WalletProvider { }); } - private updateLocalTxHistory(wallet: any, opts: any) { + private updateLocalTxHistory(wallet: any, opts: any): Promise { return new Promise((resolve, reject) => { opts = opts ? opts : {}; let FIRST_LIMIT = 5; @@ -436,10 +438,6 @@ export class WalletProvider { this.progressFn[walletId] = opts.progressFn || (() => { }); let foundLimitTx = []; - if (opts.feeLevels) { - opts.lowAmount = this.getLowAmount(wallet, opts.feeLevels); - }; - let fixTxsUnit = (txs: any): void => { if (!txs || !txs[0] || !txs[0].amountStr) return; @@ -570,7 +568,11 @@ export class WalletProvider { }); }; - updateLowAmount(txs); + this.getLowAmount(wallet).then((fee) => { + opts.lowAmount = fee; + updateLowAmount(txs); + }); + updateNotes().then(() => { @@ -661,21 +663,31 @@ export class WalletProvider { } // Approx utxo amount, from which the uxto is economically redeemable - public getLowAmount(wallet: any, feeLevels?: any, nbOutputs?: number) { - let minFee: number = this.getMinFee(wallet, feeLevels, nbOutputs); - return (minFee / this.LOW_AMOUNT_RATIO); + public getLowAmount(wallet: any): Promise { + return new Promise((resolve, reject) => { + this.getMinFee(wallet).then((fee) => { + let minFee: number = fee; + return resolve(minFee / this.LOW_AMOUNT_RATIO); + }).catch((err) => { + return reject(err); + }); + }); } // Approx utxo amount, from which the uxto is economically redeemable - private getMinFee(wallet: any, feeLevels: any, nbOutputs?: number): number { - let level: any = lodash.find(feeLevels[wallet.network], (o) => { - return o.level == 'normal'; - }); - let lowLevelRate = parseInt((level.feePerKb / 1000).toFixed(0)); - - var size = this.getEstimatedTxSize(wallet, nbOutputs); - return size * lowLevelRate; - } + public getMinFee(wallet: any, nbOutputs?: number): Promise { + return new Promise((resolve, reject) => { + this.feeProvider.getFeeLevels(wallet.coin).then((data) => { + let lowLevelRate = (lodash.find(data.levels[wallet.network], { + level: 'normal', + }).feePerKb / 1000).toFixed(0); + let size = this.getEstimatedTxSize(wallet, nbOutputs); + return resolve(size * parseInt(lowLevelRate)); + }).catch((err) => { + return reject(err); + }); + }) + }; // These 2 functions were taken from // https://github.com/bitpay/bitcore-wallet-service/blob/master/lib/model/txproposal.js#L243 @@ -1007,30 +1019,33 @@ export class WalletProvider { }); } - public getLowUtxos(wallet: any, levels: any): Promise { + public getLowUtxos(wallet: any): Promise { return new Promise((resolve, reject) => { wallet.getUtxos({ coin: wallet.coin }, (err, resp) => { if (err || !resp || !resp.length) return reject(err); - let minFee = this.getMinFee(wallet, levels, resp.length); + this.getMinFee(wallet, resp.length).then((fee) => { + let minFee = fee; + let balance = lodash.sumBy(resp, 'satoshis'); - let balance = lodash.sumBy(resp, 'satoshis'); + // for 2 outputs + this.getLowAmount(wallet).then((fee) => { + let lowAmount = fee; + let lowUtxos = lodash.filter(resp, (x: any) => { + return x.satoshis < lowAmount; + }); - // for 2 outputs - let lowAmount = this.getLowAmount(wallet, levels); - let lowUtxos = lodash.filter(resp, (x: any) => { - return x.satoshis < lowAmount; - }); - - let totalLow = lodash.sumBy(lowUtxos, 'satoshis'); - return resolve({ - allUtxos: resp || [], - lowUtxos: lowUtxos || [], - totalLow: totalLow, - warning: minFee / balance > this.TOTAL_LOW_WARNING_RATIO, - minFee: minFee, + let totalLow = lodash.sumBy(lowUtxos, 'satoshis'); + return resolve({ + allUtxos: resp || [], + lowUtxos: lowUtxos || [], + totalLow: totalLow, + warning: minFee / balance > this.TOTAL_LOW_WARNING_RATIO, + minFee: minFee, + }); + }); }); }); });