Am trying to generate a litecoin hd wallet and i get "Invalid network version".
Here is my code...
const bip32 = require('bip32')
const network = {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4, // for segwit (start with 2)
wif: 0xef
}
var root = bip32.fromBase58("xxxxxxxxxxxx", network)
var account = root.derivePath("m/44'/2'/0'/0'")
return account
Please am i missing something??
"xxxxxxxxxxxx" needs to start with tprv or tpub but you probably are using xprv or xpub
tprv9s21ZrQH143K2wisZE8ncEu33T4WDRmiT7uK5XeXfb3R4YfRMQQiaT6p2YDjsX7zC4UzaUxTyyXpEZeTmtVsedjnxfPdsTPqEgPUGVwW1oT
This is not a valid tprv... how did you make it? The contents is garbage.
Here's an example of a valid tprv:
tprv8ZgxMBicQKsPeyNs2qAvUt3wqem4pBWrTVixFQoAhrb7fRDcbuJjbyLmQvMBscG2zjeJu8H6C7cp9oQXaSvceMNxxsMzqmGGfN34H6buhE6
tprv9s21ZrQH143K2wisZE8ncEu33T4WDRmiT7uK5XeXfb3R4YfRMQQiaT6p2YDjsX7zC4UzaUxTyyXpEZeTmtVsedjnxfPdsTPqEgPUGVwW1oT
This is not a valid tprv... how did you make it? The contents is garbage.
Here's an example of a valid tprv:
tprv8ZgxMBicQKsPeyNs2qAvUt3wqem4pBWrTVixFQoAhrb7fRDcbuJjbyLmQvMBscG2zjeJu8H6C7cp9oQXaSvceMNxxsMzqmGGfN34H6buhE6
I used https://bip39.net to generate xprv key..... Please what is the best way to generate a valid key for livenet and testnest?
That site only generates xprv keys...... where did you get your tprv key?
That site only generates xprv keys...... where did you get your tprv key?
I replaced xprv with tprv and that's what was giving me error... Your tprv key worked fine. Please how did you generate your key?
I replaced xprv with tprv
That's not how it works. You need to base58check decode the xprv, replace the first 4 bytes with the 4 byte header for tprv, then base58check encode again.
If you change the letters directly the checksum won't match.
Examples for bip32 as written in the README:
https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js
@junderw thanks for your answers...
One more question please! Is it the same procedure for Bitcoin Cash?
@Laccy-P BIP32 is coin-agnostic.
@Laccy-P BIP32 is coin-agnostic.
Yeah... Have already tried it but another issue is that i get
bash
Signature must use SIGHASH_FORKID
when i try broadcasting a bitcoin cash transaction i built with bitcoinjs. 馃槥
@Laccy-P
You're very close, just add | SIGHASH_FORKID after your use of SIGHASH_ALL, value 0x40
Ref:
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/f5f1555c14e75f65e09c55f78e099d116868568b/src/script/sighashtype.h#L18
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/2e0f1a07cb08dbf6266d49ecb3d0dcb5328c7013/src/bitcoin-tx.cpp#L497
I rebased a branch for BCH support here:
https://github.com/junderw/bitcoinjs-lib/tree/cash402
However, bitcoinjs-lib will not support BCH officially.
@ch4ot1c The sighash only signifies the method used to sign. BCH uses a different signature preimage generation logic that needs to be implemented.
I rebased a branch for BCH support here:
https://github.com/junderw/bitcoinjs-lib/tree/cash402
However, bitcoinjs-lib will not support BCH officially.
@ch4ot1c The sighash only signifies the method used to sign. BCH uses a different signature preimage generation logic that needs to be implemented.
@junderw Have installed your branch(cash402) and i still get
bash
'16: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation). Code:-26'
when i try broadcasting using https://test-bch-insight.bitpay.com/api/tx/send.
Here is my code, don't know where am getting it wrong please i really need help.
````js
var tx = new bitcoincashjs.TransactionBuilder(network)
tx.addInput(txid, vout)
tx.addOutput(bchaddrjs.toLegacyAddress(request.input('receiving_address')), sending_amount_sat)
tx.addOutput(bchaddrjs.toLegacyAddress(change_address), change_amount)
var account = root.derivePath("m/44/145'/1'/1")
tx.sign(0, account)
tx.build().toHex()
````
TransactionBuilder.prototype.enableBitcoinCashsign function.Please take time to learn how something works before asking a question.
This is getting off topic, so I am closing this thread.