bitcoin-net icon indicating copy to clipboard operation
bitcoin-net copied to clipboard

TypeError: block.header.getHash is not a function

Open 7flash opened this issue 5 years ago • 0 comments

block argument is object with data fields, but without any specific methods

https://github.com/mappum/bitcoin-net/blob/c842a23821a01b5d2d7e4d8ae8726537e28d9320/src/peer.js#L189

example.js

let { Peer } = require('bitcoin-net')
const net = require("net")

const socket = net.connect({ port: 8333, host: 'vilha.info' }, () => {
  const peer = new Peer({ magic: 0xd9b4bef9, defaultPort: 8333 }, { socket })

  peer.once('ready', () => {
    peer.getBlocks([Buffer.from('0000000000000000002b0fcdc0bdedcc71fcce092633885628c3b50d43200002', 'hex').reverse()],
      (err, headers) => {
        console.log(headers)
      })
  })
})

package.json

  "dependencies": {
    "bitcoin-inventory": "^1.0.2",
    "bitcoin-merkle-proof": "0.0.6",
    "bitcoin-net": "^5.0.0",
    "bitcoin-protocol": "^3.0.1",
    "blockchain-spv": "^3.1.6",
    "crypto": "^1.0.1",
    "debug": "^2.2.0",
    "event-cleanup": "^1.0.3",
    "object-assign": "^4.1.0",
    "through2": "^2.0.1",
    "webcoin-bitcoin": "^3.1.4"
  }

7flash avatar Aug 16 '18 15:08 7flash