Bitcoinjs-lib getAddress not a function error

0 votes

This is the code i am using

const bitcoin = require('bitcoinjs-lib'); let testnet = bitcoin.networks.testnet;
let keypair = bitcoin.ECPair.makeRandom({network: testnet});

let addr = keypair.getAddress();
let  pk = keypair.toWIF();

Aug 27, 2018 in Blockchain by digger
• 26,740 points
1,606 views

1 answer to this question.

0 votes

You need to pass network parameter to ECPair.makeRandom directly without wrapper object and you wont get this error anymore

const bitcoin = require('bitcoinjs-lib');

let testnet = bitcoin.networks.testnet;
let keypair = bitcoin.ECPair.makeRandom(testnet);

let addr = keypair.getAddress();
let pk = keypair.toWIF();
answered Aug 27, 2018 by slayer
• 29,350 points
still got:

let addr = keypair.getAddress();
                   ^

TypeError: keypair.getAddress is not a function

Hey, @There,

Try this:

const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey })

I hope this will omit your error.

Related Questions In Blockchain

0 votes
1 answer

Error using EtherJS: this.provider.getTransactionCount is not a function

With this line it should work fine: wallet.provider ...READ MORE

answered Sep 26, 2018 in Blockchain by digger
• 26,740 points
2,253 views
0 votes
1 answer

Solidity mocha : address is not a contract error

Try the following: // Initialize contract variable with ...READ MORE

answered Oct 1, 2018 in Blockchain by digger
• 26,740 points
808 views
0 votes
1 answer
0 votes
1 answer

TypeError: XMLHttpRequest is not a function when using web3 on meteor server side

I had the same problem. Instead ethereum:web3 Meteor package ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 69,210 points
854 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,146 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,704 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,237 views
0 votes
1 answer

Truffle tutorials "Error:recipient address is not a contract address"

It appears like you have already migrated ...READ MORE

answered Aug 8, 2018 in Blockchain by slayer
• 29,350 points
880 views
+1 vote
5 answers

How to solve "truffle: command not found" error in blockchain?

First try restarting the system and then ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,350 points
11,340 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP