我正在使用ethereumjs-wallet
,并且在我的开发节点环境中,调用Wallet.fromV3
没有问题。在我的生产安装中,发生错误
TypeError: Wallet.fromV3 is not a function
at extractPrivateKey (/usr/src/app/dist/blockchain/library.js:83:23)
at sendTransaction (/usr/src/app/dist/blockchain/library.js:113:3)
at Object.callback (/usr/src/app/dist/blockchain/library.js:1052:5)
at sendTxCallback (/usr/src/app/node_modules/web3/node_modules/web3-core-method/lib/index.js:533:29)
at /usr/src/app/node_modules/web3/node_modules/web3-core-requestmanager/lib/index.js:293:9
at XMLHttpRequest.request.onreadystatechange (/usr/src/app/node_modules/web3/node_modules/web3-providers-http/lib/index.js:98:13)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/src/app/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
at XMLHttpRequest._setReadyState (/usr/src/app/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
at XMLHttpRequest._onHttpResponseEnd (/usr/src/app/node_modules/xhr2-cookies/xml-http-request.ts:345:8)
at IncomingMessage.<anonymous> (/usr/src/app/node_modules/xhr2-cookies/xml-http-request.ts:311:39)
at IncomingMessage.emit (events.js:198:15)
console.log
在我的开发环境中:
Wallet function Wallet(priv, pub) {
if (priv && pub) {
throw new Error('Cannot supply both a private and a public key to the constructor');
}
if (priv && !ethUtil.isValidPrivate(priv)) {
throw new Error('Private key does not satisfy the curve requirements (ie. it is invalid)');
}
if (pub && !ethUtil.isValidPublic(pub)) {
throw new Error('Invalid public key');
}
this._privKey = priv;
this._pubKey = pub;
}
console.log
在生产中
Wallet { hdkey: [Getter],
thirdparty: [Getter],
default:
{ [Function: Wallet]
generate: [Function],
generateVanityAddress: [Function],
fromPublicKey: [Function],
fromExtendedPublicKey: [Function],
fromPrivateKey: [Function],
fromExtendedPrivateKey: [Function],
fromV1: [Function],
fromV3: [Function],
fromEthSale: [Function] } }
这与Wallet
从 导出的方式有关node_modules/ethereumjs-wallet/dist/index.js
吗?
exports.default = Wallet;
尽管建议Wallet
通过:加载const { Wallet } = require('ethereumjs-wallet')
,但它是以这种方式加载的: const Wallet = require('ethereumjs-wallet')
,因为它在使用前一种语法的开发中无法正常工作。
ethereumjs-wallet
和的版本truffle-hdwallet-provider
在两种环境中都是一致的。
-- ethereumjs-wallet@1.0.0
-- truffle-hdwallet-provider@1.0.17
知道我的生产系统上发生了什么吗?