Browse Source

ismine:false receive address info; use utxo sum as t balance

v0.25
pbca26 7 years ago
parent
commit
cb9d5426fb
  1. 43
      react/src/actions/actions/nativeDashboardUpdate.js
  2. 14
      react/src/components/dashboard/receiveCoin/receiveCoin.render.js

43
react/src/actions/actions/nativeDashboardUpdate.js

@ -45,10 +45,10 @@ export function getDashboardUpdate(coin, activeCoinProps) {
export function getDashboardUpdateState(json, coin, fakeResponse) { export function getDashboardUpdateState(json, coin, fakeResponse) {
// rescan or similar resource heavy process // rescan or similar resource heavy process
if (fakeResponse || if (fakeResponse ||
((json.result['getinfo'].error && json.result['getinfo'].error === 'daemon is busy') && ((json.result.getinfo.error && json.result.getinfo.error === 'daemon is busy') &&
(json.result['z_getoperationstatus'].error && json.result['z_getoperationstatus'].error === 'daemon is busy') && (json.result.z_getoperationstatus.error && json.result.z_getoperationstatus.error === 'daemon is busy') &&
(json.result['listtransactions'].error && json.result['listtransactions'].error === 'daemon is busy') && (json.result.listtransactions.error && json.result.listtransactions.error === 'daemon is busy') &&
(json.result['listtransactions'].error && json.result['listtransactions'].error === 'daemon is busy'))) { (json.result.listtransactions.error && json.result.listtransactions.error === 'daemon is busy'))) {
return { return {
type: DASHBOARD_UPDATE, type: DASHBOARD_UPDATE,
progress: null, progress: null,
@ -60,7 +60,7 @@ export function getDashboardUpdateState(json, coin, fakeResponse) {
rescanInProgress: true, rescanInProgress: true,
}; };
} else { } else {
let _listtransactions = json.result['listtransactions']; let _listtransactions = json.result.listtransactions;
if (_listtransactions && if (_listtransactions &&
_listtransactions.error) { _listtransactions.error) {
@ -74,22 +74,41 @@ export function getDashboardUpdateState(json, coin, fakeResponse) {
if (coin === 'CHIPS') { if (coin === 'CHIPS') {
return { return {
type: DASHBOARD_UPDATE, type: DASHBOARD_UPDATE,
progress: json.result['getinfo'].result, progress: json.result.getinfo.result,
opids: null, opids: null,
txhistory: _listtransactions, txhistory: _listtransactions,
balance: { transparent: json.result['getbalance'].result, total: json.result['getbalance'].result }, balance: {
addresses: json.result['addresses'], transparent: json.result.getbalance.result,
total: json.result.getbalance.result
},
addresses: json.result.addresses,
coin: coin, coin: coin,
rescanInProgress: false, rescanInProgress: false,
}; };
} else { } else {
// calc transparent balance properly
let _tbalance = 0;
if (json.result.addresses &&
json.result.addresses.public &&
json.result.addresses.public.length) {
for (let i = 0; i < json.result.addresses.public.length; i++) {
_tbalance += json.result.addresses.public[i].spendable;
}
}
console.warn(_tbalance);
json.result.z_gettotalbalance.result.transparent = _tbalance.toFixed(8);
json.result.z_gettotalbalance.result.total = json.result.z_gettotalbalance.result.transparent + Number(json.result.z_gettotalbalance.result.interest) + Number(json.result.z_gettotalbalance.result.private);
return { return {
type: DASHBOARD_UPDATE, type: DASHBOARD_UPDATE,
progress: json.result['getinfo'].result, progress: json.result.getinfo.result,
opids: json.result['z_getoperationstatus'].result, opids: json.result.z_getoperationstatus.result,
txhistory: _listtransactions, txhistory: _listtransactions,
balance: json.result['z_gettotalbalance'].result, balance: json.result.z_gettotalbalance.result,
addresses: json.result['addresses'], addresses: json.result.addresses,
coin: coin, coin: coin,
rescanInProgress: false, rescanInProgress: false,
}; };

14
react/src/components/dashboard/receiveCoin/receiveCoin.render.js

@ -40,20 +40,24 @@ export const AddressActionsNonBasiliskModeRender = function(address, type) {
}; };
export const AddressItemRender = function(address, type) { export const AddressItemRender = function(address, type) {
const _isBarterDexAddress = address.address[0] === 'b' ? true : false;
//fa-ban
return ( return (
<tr key={ address.address }> <tr key={ address.address }>
{ this.renderAddressActions(address.address, type) } { this.renderAddressActions(address.address, type) }
<td> <td>
{ type === 'public' ? address.address : `${address.address.substring(0, 34)}...` } { type === 'public' ? address.address : `${address.address.substring(0, 34)}...` }
{ _isBarterDexAddress && { address.spendable === 0 &&
<i <i
title="BarterDex address, you don't own its priv key" title="You don't own priv keys for this address"
className="fa fa-ban margin-left-10"></i> className="fa fa-ban margin-left-10"></i>
} }
</td> </td>
<td>{ address.amount }</td> <td>
<span>{ address.amount }</span>
{ address.spendable === 0 &&
address.amount > 0 &&
<span title="Available amount to spend: 0"> (0)</span>
}
</td>
</tr> </tr>
); );
}; };

Loading…
Cancel
Save