Browse Source

receive coin validate address option

v0.25
pbca26 7 years ago
parent
commit
cbaba15257
  1. 3
      react/src/actions/actionCreators.js
  2. 27
      react/src/actions/actions/addCoin.js
  3. 4
      react/src/actions/actions/cli.js
  4. 14
      react/src/actions/actions/coinList.js
  5. 40
      react/src/actions/actions/electrum.js
  6. 2
      react/src/actions/actions/getTxDetails.js
  7. 4
      react/src/actions/actions/interest.js
  8. 8
      react/src/actions/actions/jumblr.js
  9. 15
      react/src/actions/actions/nativeDashboardUpdate.js
  10. 4
      react/src/actions/actions/nativeNetwork.js
  11. 4
      react/src/actions/actions/nativeSend.js
  12. 8
      react/src/actions/actions/nativeSyncInfo.js
  13. 6
      react/src/actions/actions/pin.js
  14. 55
      react/src/actions/actions/settings.js
  15. 6
      react/src/actions/actions/update.js
  16. 25
      react/src/components/dashboard/receiveCoin/receiveCoin.js
  17. 5
      react/src/components/dashboard/receiveCoin/receiveCoin.render.js
  18. 9
      react/src/components/dashboard/sendCoin/sendCoin.js
  19. 5
      react/src/components/toaster/toaster-item.js
  20. 4
      react/src/components/toaster/toaster.scss

3
react/src/actions/actionCreators.js

@ -103,13 +103,14 @@ export function toggleSendReceiveCoinFormsState() {
}
}
export function triggerToaster(message, title, _type, autoClose = true) {
export function triggerToaster(message, title, _type, autoClose = true, className) {
return {
type: ADD_TOASTER_MESSAGE,
message,
title,
_type,
autoClose,
className,
}
}

27
react/src/actions/actions/addCoin.js

@ -78,13 +78,13 @@ export function shepherdElectrumAuth(seed) {
dispatch(activeHandle());
dispatch(shepherdElectrumCoins());
} else {
dispatch(
triggerToaster(
'Icorrect WIF key format',
'Error',
'error'
)
);
dispatch(
triggerToaster(
'Icorrect WIF key format',
'Error',
'error'
)
);
}
});
}
@ -106,7 +106,7 @@ export function shepherdElectrumAddCoin(coin) {
'Error',
'error'
)
)
);
})
.then(response => response.json())
.then(json => {
@ -150,7 +150,7 @@ export function shepherdHerd(coin, mode, path, startupParams) {
'-server',
`-ac_name=${coin}`,
'-addnode=78.47.196.146',
]
],
};
if (coin === 'ZEC') {
@ -159,7 +159,7 @@ export function shepherdHerd(coin, mode, path, startupParams) {
'ac_options': [
'-daemon=0',
'-server=1',
]
],
};
}
@ -169,7 +169,7 @@ export function shepherdHerd(coin, mode, path, startupParams) {
'ac_options': [
'-daemon=0',
'-addnode=78.47.196.146',
]
],
};
}
@ -278,10 +278,11 @@ export function addCoinResult(coin, mode) {
)
);
dispatch(toggleAddcoinModal(false, false));
if (Number(mode) === 0) {
dispatch(activeHandle());
dispatch(shepherdElectrumCoins());
dispatch(getDexCoins());
dispatch(getDexCoins());
setTimeout(() => {
dispatch(activeHandle());
@ -382,7 +383,7 @@ export function shepherdGetConfig(coin, mode, startupParams) {
startupParams
)
)
)
);
}
} else {
return dispatch => {

4
react/src/actions/actions/cli.js

@ -29,7 +29,7 @@ export function shepherdCliPromise(mode, chain, cmd) {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -59,7 +59,7 @@ export function shepherdCli(mode, chain, cmd) {
);
})
.then(response => response.json())
.then(json => dispatch(cliResponseState(json)))
.then(json => dispatch(cliResponseState(json)));
}
}

14
react/src/actions/actions/coinList.js

@ -23,7 +23,7 @@ export function shepherdElectrumLock() {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -47,7 +47,7 @@ export function shepherdElectrumLogout() {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -71,7 +71,7 @@ export function shepherdStopCoind(coin) {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -111,7 +111,7 @@ export function shepherdRemoveCoin(coin, mode) {
)
);
}
})
});
});
}
@ -134,7 +134,7 @@ export function shepherdGetCoinList() {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -158,7 +158,7 @@ export function shepherdPostCoinList(data) {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -181,6 +181,6 @@ export function shepherdClearCoindFolder(coin, keepWalletDat) {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}

40
react/src/actions/actions/electrum.js

@ -17,7 +17,7 @@ export function shepherdElectrumSetServer(coin, address, port) {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -42,7 +42,7 @@ export function shepherdElectrumCheckServerConnection(address, port) {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -56,11 +56,7 @@ export function shepherdElectrumCheckServerConnection(address, port) {
})
.then(response => response.json())
.then(json => {
if (!json.result) {
resolve('error');
} else {
resolve(json);
}
resolve(!json.result ? 'error' : json);
});
});
}
@ -90,11 +86,7 @@ export function shepherdElectrumKeys(seed) {
})
.then(response => response.json())
.then(json => {
if (!json.result) {
resolve('error');
} else {
resolve(json);
}
resolve(!json.result ? 'error' : json);
});
});
}
@ -105,7 +97,7 @@ export function shepherdElectrumBalance(coin, address) {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -137,7 +129,7 @@ export function shepherdElectrumTransactions(coin, address) {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -178,7 +170,7 @@ export function shepherdElectrumCoins() {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -211,7 +203,7 @@ export function shepherdElectrumSend(coin, value, sendToAddress, changeAddress)
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -225,11 +217,7 @@ export function shepherdElectrumSend(coin, value, sendToAddress, changeAddress)
})
.then(response => response.json())
.then(json => {
if (json.msg === 'error') {
dispatch(sendToAddressState(json));
} else {
dispatch(sendToAddressState(json.result));
}
dispatch(sendToAddressState(json.msg === 'error' ? json : json.result));
});
}
}
@ -240,7 +228,7 @@ export function shepherdElectrumSendPromise(coin, value, sendToAddress, changeAd
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -265,7 +253,7 @@ export function shepherdElectrumSendPreflight(coin, value, sendToAddress, change
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
},
})
.catch((error) => {
console.log(error);
@ -304,11 +292,7 @@ export function shepherdElectrumListunspent(coin, address) {
})
.then(response => response.json())
.then(json => {
if (!json.result) {
resolve('error');
} else {
resolve(json);
}
resolve(!json.result ? 'error' : json);
});
});
}

2
react/src/actions/actions/getTxDetails.js

@ -49,6 +49,6 @@ export function getTxDetails(coin, txid, type) {
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
})
});
});
}

4
react/src/actions/actions/interest.js

@ -50,7 +50,7 @@ export function getListUnspent(coin) {
}
resolve(json.result ? json.result : json);
})
});
});
}
@ -92,6 +92,6 @@ export function getRawTransaction(coin, txid) {
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
})
});
});
}

8
react/src/actions/actions/jumblr.js

@ -5,7 +5,7 @@ import {
import Config from '../../config';
import Store from '../../store';
function getNewAddress(coin) { // TODO: remove(?)
function getNewAddress(coin) {
return new Promise((resolve, reject) => {
const payload = {
mode: null,
@ -39,7 +39,7 @@ function getNewAddress(coin) { // TODO: remove(?)
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
})
});
});
}
@ -195,7 +195,7 @@ function dumpPrivkey(coin, key) {
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
})
});
});
}
@ -238,6 +238,6 @@ export function importPrivkey(coin, key, rescan = false) {
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
})
});
});
}

15
react/src/actions/actions/nativeDashboardUpdate.js

@ -41,7 +41,7 @@ export function getDashboardUpdate(coin, activeCoinProps) {
dispatch(getDashboardUpdateState(json, coin));
}, 100);
}
})
});
}
}
@ -83,7 +83,7 @@ export function getDashboardUpdateState(json, coin, fakeResponse) {
txhistory: _listtransactions,
balance: {
transparent: json.result.getbalance.result,
total: json.result.getbalance.result
total: json.result.getbalance.result,
},
addresses: json.result.addresses,
coin: coin,
@ -92,13 +92,14 @@ export function getDashboardUpdateState(json, coin, fakeResponse) {
};
} else {
// calc transparent balance properly
const _addresses = json.result.addresses;
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;
if (_addresses &&
_addresses.public &&
_addresses.public.length) {
for (let i = 0; i < _addresses.public.length; i++) {
_tbalance += _addresses.public[i].spendable;
}
}

4
react/src/actions/actions/nativeNetwork.js

@ -41,7 +41,7 @@ export function getNativePeers(coin) {
.then(json => {
json = json.result;
dispatch(getNativePeersState(json));
})
});
};
}
@ -80,7 +80,7 @@ export function getNativeNettotals(coin) {
.then(json => {
json = json.result;
dispatch(getNativeNettotalsState(json));
})
});
};
}

4
react/src/actions/actions/nativeSend.js

@ -123,7 +123,7 @@ export function sendNativeTx(coin, _payload) {
)
);
}
})
});
}
}
@ -170,7 +170,7 @@ export function getKMDOPID(opid, coin) {
.then(json => {
json = json.result;
dispatch(getKMDOPIDState(json));
})
});
};
}

8
react/src/actions/actions/nativeSyncInfo.js

@ -1,6 +1,6 @@
import {
SYNCING_NATIVE_MODE,
DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE
DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE,
} from '../storeType';
import {
triggerToaster,
@ -198,7 +198,7 @@ export function getSyncInfoNative(coin, skipDebug, skipRemote, suppressErrors) {
);
}
}
})
});
}
}
@ -264,7 +264,7 @@ export function getBlockTemplate(_json, coin) {
);
}
}
})
});
}
}
@ -340,6 +340,6 @@ export function getDebugLogProgress(_json, coin) {
)
);
}
})
});
}
}

6
react/src/actions/actions/pin.js

@ -40,7 +40,7 @@ export function encryptPassphrase(passphrase, key, pubKey) {
'success'
)
);
})
});
}
}
@ -71,7 +71,7 @@ export function loginWithPin(key, pubKey) {
.then(response => response.json())
.then(json => {
dispatch(iguanaWalletPassphrase(json.result));
})
});
}
}
@ -105,6 +105,6 @@ export function loadPinList() {
dispatch(
getPinList(json.result)
);
})
});
}
}

55
react/src/actions/actions/settings.js

@ -36,7 +36,7 @@ export function getAppInfo() {
);
})
.then(response => response.json())
.then(json => dispatch(getAppInfoState(json)))
.then(json => dispatch(getAppInfoState(json)));
}
}
@ -125,7 +125,7 @@ export function importPrivKey(wifKey) {
error: 'privkey already in wallet',
}, dispatch));
console.log('parsing failed', ex);
})
});
}
}
@ -167,7 +167,7 @@ export function getDebugLog(target, linesCount, acName) {
);
})
.then(response => response.json())
.then(json => dispatch(getDebugLogState(json)))
.then(json => dispatch(getDebugLogState(json)));
}
}
@ -197,7 +197,7 @@ export function getPeersList(coin) {
.then(response => response.json())
.then(json => {
dispatch(getPeersListState(json, dispatch));
})
});
}
}
@ -290,7 +290,7 @@ export function addPeerNode(coin, ip) {
.then(response => response.json())
.then(json => {
dispatch(addPeerNodeState(json, dispatch));
})
});
}
}
@ -323,7 +323,7 @@ export function saveAppConfig(_payload) {
'success'
)
);
})
});
}
}
@ -353,7 +353,7 @@ export function getAppConfig() {
);
})
.then(response => response.json())
.then(json => dispatch(getAppConfigState(json)))
.then(json => dispatch(getAppConfigState(json)));
}
}
@ -385,7 +385,7 @@ export function resetAppConfig() {
'success'
)
);
})
});
}
}
@ -478,6 +478,45 @@ export function dumpPrivKey(coin, address, isZaddr) {
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
});
});
}
export function validateAddress(coin, address, isZaddr) {
return new Promise((resolve, reject) => {
const payload = {
mode: null,
chain: coin,
cmd: isZaddr ? 'z_validateaddress' : 'validateaddress',
params: [ address ],
rpc2cli: Config.rpc2cli,
};
const _fetchConfig = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': payload }),
};
fetch(
`http://127.0.0.1:${Config.agamaPort}/shepherd/cli`,
_fetchConfig
)
.catch(function(error) {
console.log(error);
Store.dispatch(
triggerToaster(
'validateAddress',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
});
});
}

6
react/src/actions/actions/update.js

@ -21,7 +21,7 @@ export function checkForUpdateUIPromise() {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -44,7 +44,7 @@ export function updateUIPromise() {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}
@ -67,6 +67,6 @@ export function downloadZCashParamsPromise(dloption) {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => resolve(json));
});
}

25
react/src/components/dashboard/receiveCoin/receiveCoin.js

@ -5,6 +5,8 @@ import {
getNewKMDAddresses,
dumpPrivKey,
copyString,
triggerToaster,
validateAddress,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import {
@ -33,6 +35,7 @@ class ReceiveCoin extends React.Component {
this.ReceiveCoinTableRender = _ReceiveCoinTableRender.bind(this);
this.toggleAddressMenu = this.toggleAddressMenu.bind(this);
this.toggleIsMine = this.toggleIsMine.bind(this);
this.validateCoinAddress = this.validateCoinAddress.bind(this);
}
toggleAddressMenu(address) {
@ -61,6 +64,28 @@ class ReceiveCoin extends React.Component {
);
}
validateCoinAddress(address, isZaddr) {
this.toggleAddressMenu(address);
validateAddress(this.props.coin, address, isZaddr)
.then((json) => {
let _items = [];
for (let key in json) {
_items.push(`${key}: ${json[key]}`);
}
Store.dispatch(
triggerToaster(
_items,
translate('TOASTR.COIN_NOTIFICATION'),
json && json.ismine ? 'info' : 'warning',
false,
'toastr--validate-address'
)
);
});
}
dumpPrivKey(address, isZaddr) {
this.toggleAddressMenu(address);
dumpPrivKey(this.props.coin, address, isZaddr)

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

@ -30,6 +30,11 @@ export const AddressActionsNonBasiliskModeRender = function(address, type) {
<i className="icon fa-key margin-right-5"></i> { translate('INDEX.COPY') + ' priv key (WIF)' }
</li>
}
{ this.props.mode !== 'spv' &&
<li onClick={ () => this.validateCoinAddress(address, type !== 'public' ? true : null) }>
<i className="icon fa-check margin-right-5"></i> validate address
</li>
}
<li className="receive-address-context-menu-get-qr">
<QRModal content={ address } />
</li>

9
react/src/components/dashboard/sendCoin/sendCoin.js

@ -211,11 +211,12 @@ class SendCoin extends React.Component {
renderAddressByType(type) {
let _items = [];
const _coinAddresses = this.props.ActiveCoin.addresses;
if (this.props.ActiveCoin.addresses &&
this.props.ActiveCoin.addresses[type] &&
this.props.ActiveCoin.addresses[type].length) {
this.props.ActiveCoin.addresses[type].map((address) => {
if (_coinAddresses &&
_coinAddresses[type] &&
_coinAddresses[type].length) {
_coinAddresses[type].map((address) => {
if (address.amount > 0 &&
(type !== 'public' || (address.canspend && type === 'public'))) {
_items.push(

5
react/src/components/toaster/toaster-item.js

@ -19,6 +19,7 @@ class ToasterItem extends React.Component {
title: props.title,
autoClose: props.autoClose,
toastId: props.toastId,
className: props.className,
};
this.dismissToast = this.dismissToast.bind(this);
@ -35,6 +36,7 @@ class ToasterItem extends React.Component {
title: props.title,
autoClose: props.autoClose,
toastId: props.toastId,
className: props.className,
});
} else {
this.setState({
@ -43,6 +45,7 @@ class ToasterItem extends React.Component {
title: null,
autoClose: true,
toastId: null,
className: null,
});
}
}
@ -86,7 +89,7 @@ class ToasterItem extends React.Component {
}
return (
<div className={ `toast toast-${this.state.type}` }>
<div className={ `toast toast-${this.state.type}${this.state.className ? ' ' + this.state.className : ''}` }>
<button
className="toast-close-button"
onClick={ () => this.dismissToast(this.state.toastId) }>×

4
react/src/components/toaster/toaster.scss

@ -4,4 +4,8 @@
width: 310px;
opacity: 1;
}
.toastr--validate-address {
width: 430px;
}
}
Loading…
Cancel
Save