Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
Add provider-engine provider supporting signing
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Apr 25, 2016
1 parent bc1f289 commit b27e211
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions provider-engine.js
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit b27e211

Please sign in to comment.