August 12, 2026

Bitcoinja-lib. bitcoin.payments is null

I installed bitcoinjs-lib with command: meteor npm install bitcoinjs-lib.
The installation command “flow-typed install -f 0.27 bitcoinjs-lib@2.2.0” didn’t work. No idea what flow-typed is and the influence it has.

This is the code I am running:

  import bip39 from 'bip39';
  import bip32 from 'bip32';
  import crypto from 'crypto';
  import Bitcoin from 'bitcoinjs-lib';
  let randomBytes = crypto.randomBytes(32);
  this.mnemonic = "praise you muffin lion enable neck grocery crumble super myself license ghost"; //bip39.entropyToMnemonic(randomBytes.toString('hex'))
  this.seed = bip39.mnemonicToSeed(this.mnemonic); 
  console.log("seed:", bip39.mnemonicToSeed(this.mnemonic));

  let bitcoinNetwork = bitcoin.networks.bitcoin;
  var hdMaster = bip32.fromSeed(this.seed, bitcoinNetwork);

  const path = "m/0'/0/0";
  const child1 = hdMaster.derivePath(path);
  const { address } = bitcoin.payments.p2sh({
    redeem: bitcoin.payments.p2wpkh({ pubkey: child.publicKey, network: bitcoinNetwork }),
    network: bitcoinNetwork
  })
  console.log("address: ", address);

Unfortunately bitcoin.payments is undefined.
bitcoin.networks.bitcoin works ok.

Why is payments undefined?
Thanks.

Previous Article

Bitcore-wallet-client “Server response could not be verified”

Next Article

How can I make Zap synchronize with the Bitcoin network?

You might be interested in …