节点js的入口脚本中是否有所有函数?

时间:2017-10-19 15:01:50

标签: node.js npm

我看的代码非常简单。它需要一个库并使用以下功能之一:

const bitcoin = require('bcashjs-lib');
.
.
.
const hdPath = bitcoin.hdPath(keychain);

以下是其他地方使用的一个例子:

https://github.com/BitGo/BitGoJS/blob/30f7b0850e65a0cec91ad911e76a935e07c363a5/src/v2/coins/bch.js#L40

以下是他们使用的版本:

https://github.com/BitGo/BitGoJS/blob/30f7b0850e65a0cec91ad911e76a935e07c363a5/package.json#L74

但是,当我在自己的脚本上执行相同操作时,函数未定义。当然,图书馆在条目文件中没有它:

https://github.com/BitGo/bcashjs-lib/blob/master/src/index.js

任何提示都会很棒。

1 个答案:

答案 0 :(得分:2)

BitGo模块可以使用hdPath(),因为它们自己定义并将其附加到比特币对象。它不属于bcashjs-lib

here where they define it :(第129行)

bitcoin.hdPath = function(rootKey) {
   const cache = {};
   //etc...
}