diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 16bdeff..506f0fa 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -50,6 +50,7 @@ export * from './actions/getTxDetails'; export * from './actions/electrum'; export * from './actions/mm'; export * from './actions/nativeNetwork'; +export * from './actions/tools'; export function changeActiveAddress(address) { return { diff --git a/react/src/actions/actions/nativeSend.js b/react/src/actions/actions/nativeSend.js index c524567..6bbe843 100644 --- a/react/src/actions/actions/nativeSend.js +++ b/react/src/actions/actions/nativeSend.js @@ -27,7 +27,7 @@ export function sendNativeTx(coin, _payload) { token: Config.token, params: (_payload.addressType === 'public' && _payload.sendTo.length !== 95) || !_payload.sendFrom ? - (_payload.substractFee ? + (_payload.subtractFee ? [ _payload.sendTo, _payload.amount, diff --git a/react/src/actions/actions/tools.js b/react/src/actions/actions/tools.js new file mode 100644 index 0000000..17d1977 --- /dev/null +++ b/react/src/actions/actions/tools.js @@ -0,0 +1,225 @@ +import { translate } from '../../translate/translate'; +import Config from '../../config'; +import { + triggerToaster, +} from '../actionCreators'; +import Store from '../../store'; + +export function shepherdToolsSeedKeys(seed) { + return new Promise((resolve, reject) => { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/keys`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + seed, + active: true, + iguana: true, + token: Config.token, + }), + }) + .catch((error) => { + console.log(error); + Store.dispatch( + triggerToaster( + 'shepherdToolsSeedKeys', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(!json.result ? 'error' : json); + }); + }); +} + +export function shepherdToolsBalance(coin, address) { + return new Promise((resolve, reject) => { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/getbalance?coin=${coin}&address=${address}&token=${Config.token}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) + .catch((error) => { + console.log(error); + dispatch( + triggerToaster( + 'shepherdToolsBalance', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(!json.result ? 'error' : json); + }); + }); +} + +export function shepherdToolsTransactions(coin, address) { + return new Promise((resolve, reject) => { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/listtransactions?coin=${coin}&address=${address}&full=true&maxlength=20&token=${Config.token}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) + .catch((error) => { + console.log(error); + dispatch( + triggerToaster( + 'shepherdToolsTransactions', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(!json.result ? 'error' : json); + }); + }); +} + +export function shepherdToolsBuildUnsigned(coin, value, sendToAddress, changeAddress) { + value = Math.floor(value); + + return new Promise((resolve, reject) => { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/createrawtx?coin=${coin}&address=${sendToAddress}&value=${value}&change=${changeAddress}&verify=false&push=false&offline=true&token=${Config.token}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) + .catch((error) => { + console.log(error); + Store.dispatch( + triggerToaster( + 'shepherdToolsBuildUnsigned', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(json); + }); + }); +} + +export function shepherdToolsListunspent(coin, address) { + return new Promise((resolve, reject) => { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/listunspent?coin=${coin}&address=${address}&full=true&token=${Config.token}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) + .catch((error) => { + console.log(error); + Store.dispatch( + triggerToaster( + 'shepherdToolsListunspent', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(!json.result ? 'error' : json); + }); + }); +} + +export function shepherdToolsPushTx(network, rawtx) { + return new Promise((resolve, reject) => { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/pushtx`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + network, + rawtx, + token: Config.token, + }), + }) + .catch((error) => { + console.log(error); + Store.dispatch( + triggerToaster( + 'shepherdToolsPushTx', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(!json.result ? 'error' : json); + }); + }); +} + +export function shepherdToolsWifToKP(coin, wif) { + return new Promise((resolve, reject) => { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/wiftopub?coin=${coin}&wif=${wif}&token=${Config.token}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) + .catch((error) => { + console.log(error); + Store.dispatch( + triggerToaster( + 'shepherdToolsWifToKP', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(!json.result ? 'error' : json); + }); + }); +} + +export function shepherdToolsSeedToWif(seed, network, iguana) { + return new Promise((resolve, reject) => { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/seedtowif`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + seed, + network, + iguana, + token: Config.token, + }), + }) + .catch((error) => { + console.log(error); + Store.dispatch( + triggerToaster( + 'shepherdToolsSeedToWif', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(!json.result ? 'error' : json); + }); + }); +} \ No newline at end of file diff --git a/react/src/components/dashboard/main/dashboard.render.js b/react/src/components/dashboard/main/dashboard.render.js index 26849a6..71aa61b 100644 --- a/react/src/components/dashboard/main/dashboard.render.js +++ b/react/src/components/dashboard/main/dashboard.render.js @@ -13,6 +13,7 @@ import Settings from '../settings/settings'; import ReceiveCoin from '../receiveCoin/receiveCoin'; import About from '../about/about'; import Support from '../support/support'; +import Tools from '../tools/tools'; import WalletsMain from '../walletsMain/walletsMain'; import WalletsTxInfo from '../walletsTxInfo/walletsTxInfo'; import CoindDownModal from '../coindDownModal/coindDownModal'; @@ -56,6 +57,9 @@ const DashboardRender = function() { { this.isSectionActive('support') && } + { this.isSectionActive('tools') && + + } ); diff --git a/react/src/components/dashboard/navbar/navbar.render.js b/react/src/components/dashboard/navbar/navbar.render.js index 443144a..07d2ac9 100644 --- a/react/src/components/dashboard/navbar/navbar.render.js +++ b/react/src/components/dashboard/navbar/navbar.render.js @@ -2,6 +2,7 @@ import React from 'react'; import { translate } from '../../../translate/translate'; import mainWindow from '../../../util/mainWindow'; import ReactTooltip from 'react-tooltip'; +import Config from '../../../config'; const NavbarRender = function() { return ( @@ -81,6 +82,13 @@ const NavbarRender = function() { Explorer */ } + { Config.experimentalFeatures && +
  • + this.dashboardChangeSection('tools') }> + Tools + +
  • + } { !navigator.onLine &&
  • -
    +
    -

    { translate('INDEX.SCAN_QR_CODE') }

    +

    { this.props.title || translate('INDEX.SCAN_QR_CODE') }

    @@ -32,7 +32,7 @@ export const QRModalRender = function() { className="page-content vertical-align-middle text-center"> + size={ Number(this.props.qrSize) || 198 } />

    - { translate('INDEX.SCAN_QRCODE_WEBCAM') } + { translate('INDEX.SCAN_QR_CODE') }

    { + ) + .then((sendPreflight) => { if (sendPreflight && sendPreflight.msg === 'success') { this.setState(Object.assign({}, this.state, { diff --git a/react/src/components/dashboard/sendCoin/sendCoin.render.js b/react/src/components/dashboard/sendCoin/sendCoin.render.js index 010e98e..4895610 100644 --- a/react/src/components/dashboard/sendCoin/sendCoin.render.js +++ b/react/src/components/dashboard/sendCoin/sendCoin.render.js @@ -52,6 +52,13 @@ export const _SendFormRender = function() { }
    + { this.props.ActiveCoin.mode === 'spv' && + + } @@ -67,6 +74,13 @@ export const _SendFormRender = function() { required />
    + { this.props.ActiveCoin.mode === 'spv' && + + }