support sending funds to external wallet
This commit is contained in:
parent
dd04b9bb91
commit
be53de7326
5 changed files with 2446 additions and 1718 deletions
|
|
@ -4,6 +4,7 @@ const Web3 = require('web3')
|
|||
const web3 = new Web3()
|
||||
const hdkey = require('ethereumjs-wallet/hdkey')
|
||||
const Tx = require('ethereumjs-tx')
|
||||
const util = require('ethereumjs-util')
|
||||
const pify = require('pify')
|
||||
|
||||
const coinUtils = require('../../../coin-utils')
|
||||
|
|
@ -27,7 +28,8 @@ module.exports = {
|
|||
defaultAddress,
|
||||
supportsHd: true,
|
||||
newFunding,
|
||||
privateKey
|
||||
privateKey,
|
||||
isStrictAddress
|
||||
}
|
||||
|
||||
if (!web3.isConnected()) {
|
||||
|
|
@ -40,6 +42,10 @@ function privateKey (account) {
|
|||
return defaultWallet(account).getPrivateKey()
|
||||
}
|
||||
|
||||
function isStrictAddress (cryptoCode, toAddress) {
|
||||
return cryptoCode === 'ETH' && util.isValidChecksumAddress(toAddress)
|
||||
}
|
||||
|
||||
function sendCoins (account, toAddress, cryptoAtoms, cryptoCode) {
|
||||
return generateTx(toAddress, defaultWallet(account), cryptoAtoms, false)
|
||||
.then(pify(web3.eth.sendRawTransaction))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue