Add provider-engine provider supporting signing

This commit is contained in:
Alex Beregszaszi 2016-03-25 00:18:01 +00:00
parent bc1f2891c6
commit b27e211760
1 changed files with 24 additions and 0 deletions

24
provider-engine.js Normal file
View File

@ -0,0 +1,24 @@
'use strict'
const inherits = require('util').inherits
const HookedWalletEthTxSubprovider = require('web3-provider-engine/subproviders/hooked-wallet-ethtx')
module.exports = WalletSubprovider
inherits(WalletSubprovider, HookedWalletEthTxSubprovider)
function WalletSubprovider (wallet, opts) {
opts.getAccounts = function (cb) {
cb(null, [ wallet.getAddressesString() ])
}
opts.getPrivateKey = function (address, cb) {
if (address !== wallet.getAddressString()) {
return cb('Account not found')
}
cb(null, wallet.getPrivateKey())
}
WalletSubprovider.super_.call(this, opts)
}