bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.6k stars 2.08k forks source link

bitcoinjs-lib在5.1.6版本中无法生成地址 #1528

Closed DingGeng-GitHub closed 4 years ago

DingGeng-GitHub commented 4 years ago

const bitcoin = require("./node_modules/bitcoinjs-lib"); const TestNet = bitcoin.networks.testnet; let keyPair = bitcoin.ECPair.makeRandom({ network: TestNet }); let address = keyPair.getAddress();

报错: let address = keyPair.getAddress(); ^

TypeError: keyPair.getAddress is not a function at Object. (E:\phpStudy\PHPTutorial\WWW\npm\bit.js:11:23) ?[90m at Module._compile (internal/modules/cjs/loader.js:959:30)?[39m

请问这个是什么原因导致的?怎么解决?

longhoangwkm commented 4 years ago

getAddress has already been removed at version 4, use payments.p2pkh instead. Please check examples for more information https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts#L14