javascript – Bitcoinja-lib. bitcoin.funds is null

0
88


I put in bitcoinjs-lib with command: meteor npm set up bitcoinjs-lib.
The set up command “flow-typed set up -f 0.27 bitcoinjs-lib@2.2.0” did not work. No concept what flow-typed is and the affect it has.

That is the code I’m operating:

  import bip39 from 'bip39';
  import bip32 from 'bip32';
  import crypto from 'crypto';
  import bitcoin from 'bitcoinjs-lib';
  let randomBytes = crypto.randomBytes(32);
  this.mnemonic = "reward you muffin lion allow neck grocery crumble tremendous 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 { handle } = bitcoin.funds.p2sh({
    redeem: bitcoin.funds.p2wpkh({ pubkey: little one.publicKey, community: bitcoinNetwork }),
    community: bitcoinNetwork
  })
  console.log("handle: ", handle);

Sadly bitcoin.funds is undefined.
bitcoin.networks.bitcoin works okay.

Why is funds undefined?
Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here