Monday, December 23, 2024

javascript – Bitcoinja-lib. bitcoin.funds is null

I put in bitcoinjs-lib with command: meteor npm set up bitcoinjs-lib.
The set up command “flow-typed set up -f 0.27 [email protected]” 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 { tackle } = bitcoin.funds.p2sh({
    redeem: bitcoin.funds.p2wpkh({ pubkey: baby.publicKey, community: bitcoinNetwork }),
    community: bitcoinNetwork
  })
  console.log("tackle: ", tackle);

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

Why is funds undefined?
Thanks.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles