<p>The reason is you are using version 2.2.0 and <code>payments</code>is a feature newly added in version 4</p>

CC BY-SA 4.0
2018-09-07T15:33:18.707Z
2018-09-11T02:56:43.250Z
2018-09-11T02:56:43.250Z
timqian
<p>For some reason the isntalled bitcoinjs-lib didn't include the whole payments folder. I pasted it and then I modify index.js to include and now it works.
I don't understand why the installation goes wrong.</p>

CC BY-SA 4.0
2018-07-13T15:55:20.033Z
2018-07-13T15:55:20.033Z
educob
<p>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.</p>

<p>This is the code I am running:</p>

<pre><code>  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);
</code></pre>

<p>Unfortunately bitcoin.payments is undefined. 
bitcoin.networks.bitcoin works ok.</p>

<p>Why is payments undefined?
Thanks.</p>

CC BY-SA 4.0
2018-07-13T15:00:07.477Z
I found this link but I don't really understand what it says: https://github.com/bitcoinjs/bitcoinjs-lib/pull/1096/files/62125fe853d63875b427b2af1d7e6467dcad030e
educob
<javascript>
Bitcoinja-lib. bitcoin.payments is null
educob
# Bitcoinja-lib. bitcoin.payments is null

(Asked by: username_0 on 2018-07-13)

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.

**Tags:** javascript

> **Comments:**
> **username_0**: I found this link but I don't really understand what it says: https://github.com/bitcoinjs/bitcoinjs-lib/pull/1096/files/62125fe853d63875b427b2af1d7e6467dcad030e  

---

## 2 answers

### Answer by username_1 on 2018-09-07. Score: 0

The reason is you are using version 2.2.0 and `payments`is a feature newly added in version 4


---

### Answer by username_0 on 2018-07-13. Score: 0

For some reason the isntalled bitcoinjs-lib didn't include the whole payments folder. I pasted it and then I modify index.js to include and now it works.
I don't understand why the installation goes wrong.


---

