Bitcoinjs-lib: TypeError: x.getPublicKeyBuffer is not a function

Created on 5 Aug 2018  路  1Comment  路  Source: bitcoinjs/bitcoinjs-lib

I am trying to use the code below :

var bitcoin = require("bitcoinjs-lib");
var keyPairs = [ 
     '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgwmaKkrx', 
     '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgww7vXtT', 
     '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgx3cTMqe', 
     '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgx9rcrL7' 
   ].map(function (wif) { return bitcoin.ECPair.fromWIF(wif, bitcoin.networks.testnet) }) 
   var pubKeys = keyPairs.map(function (x) { return x.getPublicKeyBuffer() }) 

   var redeemScript = bitcoin.script.multisig.output.encode(2, pubKeys) 
   var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript)) 
   var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest) 

but i get the error:

   var pubKeys = keyPairs.map(function (x) { return x.getPublicKeyBuffer() }) 
                                                      ^
TypeError: x.getPublicKeyBuffer is not a function

how to / question / docs

Most helpful comment

change x.getPublicKeyBuffer()
to x.publicKey

>All comments

change x.getPublicKeyBuffer()
to x.publicKey

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Beardcoding picture Beardcoding  路  3Comments

zhaozhiming picture zhaozhiming  路  3Comments

LeonYanghaha picture LeonYanghaha  路  3Comments

ishwarchandratiwari picture ishwarchandratiwari  路  3Comments

namnv04 picture namnv04  路  3Comments