gpt4 book ai didi

node.js - 使用 bitcoinjs-lib 发送比特币

转载 作者:太空宇宙 更新时间:2023-11-04 00:38:11 33 4
gpt4 key购买 nike

我正在关注https://medium.com/@orweinberger/how-to-create-a-raw-transaction-using-bitcoinjs-lib-1347a502a3a#.wkf9g2lk0的bitcoinjs教程

我收到未定义的错误

var key = bitcoin.ECKey.fromWIF("L1Kzcyy88LyckShYdvoLFg1FYpB5ce1JmTYtieHrhkN65GhVoq73");

阅读https://github.com/bitcoinjs/bitcoinjs-lib/issues/487我用的是

var key = bitcoin.ECPair.fromWIF("L1Kzcyy88LyckShYdvoLFg1FYpB5ce1JmTYtieHrhkN65GhVoq73");

对于行:console.log(key.pub.getAddress().toString());(来自教程)

我收到类似的异常:

TypeError: Cannot read property 'getAddress' of undefined
at repl:1:20
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14)

“getAddress”方法也已弃用,可以使用什么代替?

还有其他发送比特币的教程吗?他们似乎很难找到?

最佳答案

这应该有效

var key = bitcoin.ECPair.fromWIF("L1Kzcyy88LyckShYdvoLFg1FYpB5ce1JmTYtieHrhkN65GhVoq73");
var address = key.getAddress().toString()

console.log(address) // 17hFoVScNKVDfDTT6vVhjYwvCu6iDEiXC4

关于node.js - 使用 bitcoinjs-lib 发送比特币,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38033338/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com