]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Add bitcoin regtest params
authorIan Coleman <ian@iancoleman.io>
Tue, 17 Dec 2019 22:51:00 +0000 (09:51 +1100)
committerIan Coleman <ian@iancoleman.io>
Tue, 17 Dec 2019 22:51:00 +0000 (09:51 +1100)
src/js/bitcoinjs-extensions.js
src/js/index.js
src/js/segwit-parameters.js
tests/spec/tests.js

index 4536783b877b903bff5e3639261d4727f33e771a..0d58bb9832003a28e28f8cabb510fac5729e37aa 100644 (file)
@@ -1738,3 +1738,16 @@ bitcoinjs.bitcoin.networks.elastos = {
     scriptHash: 0xc4, // TODO set this correctly, same as BTC for now
     wif: 0xef // TODO set this correctly, same as BTC for now
 };
+
+// https://github.com/bitcoinjs/bitcoinjs-lib/blob/3f6f5ef97a1ee1b8337865209282c0095e22b2e7/src/networks.js
+bitcoinjs.bitcoin.networks.regtest = {
+  messagePrefix: '\x18Bitcoin Signed Message:\n',
+  bech32: 'bcrt',
+  bip32: {
+    public: 0x043587cf,
+    private: 0x04358394,
+  },
+  pubKeyHash: 0x6f,
+  scriptHash: 0xc4,
+  wif: 0xef,
+};
index c9e7b44aa02a228cac4d5786ca5d0dad7a53f22b..d169ed28dc2ebcd808c2d1ec9edbb0b1455d3280 100644 (file)
                 setHdCoin(0);
             },
         },
+        {
+            name: "BTC - Bitcoin RegTest",
+            onSelect: function() {
+                network = bitcoinjs.bitcoin.networks.regtest;
+                // Using hd coin value 1 based on bip44_coin_type
+                // https://github.com/chaintope/bitcoinrb/blob/f1014406f6b8f9b4edcecedc18df70c80df06f11/lib/bitcoin/chainparams/regtest.yml
+                setHdCoin(1);
+            },
+        },
         {
             name: "BTC - Bitcoin Testnet",
             onSelect: function() {
index 83d49dad8b031e1e3e8bc8a33e101764261b0200..9641d7175fded79f7f7092e76f4c65ffbae8598f 100644 (file)
@@ -28,6 +28,19 @@ bitcoinjs.bitcoin.networks.testnet.p2wpkh = {
     wif: 0xef
 };
 
+bitcoinjs.bitcoin.networks.regtest.p2wpkh = {
+    baseNetwork: "regtest",
+    messagePrefix: '\x18Bitcoin Signed Message:\n',
+    bech32: 'bcrt',
+    bip32: {
+        public: 0x045f1cf6,
+        private: 0x045f18bc
+    },
+    pubKeyHash: 0x6f,
+    scriptHash: 0xc4,
+    wif: 0xef
+};
+
 // p2wpkh in p2sh
 
 bitcoinjs.bitcoin.networks.bitcoin.p2wpkhInP2sh = {
@@ -56,6 +69,19 @@ bitcoinjs.bitcoin.networks.testnet.p2wpkhInP2sh = {
     wif: 0xef
 };
 
+bitcoinjs.bitcoin.networks.regtest.p2wpkhInP2sh = {
+    baseNetwork: "regtest",
+    messagePrefix: '\x18Bitcoin Signed Message:\n',
+    bech32: 'bcrt',
+    bip32: {
+        public: 0x044a5262,
+        private: 0x044a4e28
+    },
+    pubKeyHash: 0x6f,
+    scriptHash: 0xc4,
+    wif: 0xef
+};
+
 // p2wsh
 
 bitcoinjs.bitcoin.networks.bitcoin.p2wsh = {
@@ -84,6 +110,19 @@ bitcoinjs.bitcoin.networks.testnet.p2wsh = {
     wif: 0xef
 };
 
+bitcoinjs.bitcoin.networks.regtest.p2wsh = {
+    baseNetwork: "regtest",
+    messagePrefix: '\x18Bitcoin Signed Message:\n',
+    bech32: 'bcrt',
+    bip32: {
+        public: 0x02575483,
+        private: 0x02575048
+    },
+    pubKeyHash: 0x6f,
+    scriptHash: 0xc4,
+    wif: 0xef
+};
+
 // p2wsh in p2sh
 
 bitcoinjs.bitcoin.networks.bitcoin.p2wshInP2sh = {
@@ -112,6 +151,19 @@ bitcoinjs.bitcoin.networks.testnet.p2wshInP2sh = {
     wif: 0xef
 };
 
+bitcoinjs.bitcoin.networks.regtest.p2wshInP2sh = {
+    baseNetwork: "regtest",
+    messagePrefix: '\x18Bitcoin Signed Message:\n',
+    bech32: 'bcrt',
+    bip32: {
+        public: 0x024289ef,
+        private: 0x024285b5
+    },
+    pubKeyHash: 0x6f,
+    scriptHash: 0xc4,
+    wif: 0xef
+};
+
 bitcoinjs.bitcoin.networks.litecoin.p2wpkh = {
     baseNetwork: "litecoin",
     messagePrefix: '\x19Litecoin Signed Message:\n',
index fefb8b75392ffd2149910d579b51abec907b3757..260ff2c73a72b9eadfb44e6047387de18784bf14 100644 (file)
@@ -412,6 +412,13 @@ it('Allows selection of bitcoin testnet', function(done) {
     };
     testNetwork(done, params);
 });
+it('Allows selection of bitcoin regtest', function(done) {
+    var params = {
+        selectText: "BTC - Bitcoin RegTest",
+        firstAddress: "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi",
+    };
+    testNetwork(done, params);
+});
 it('Allows selection of litecoin', function(done) {
     var params = {
         selectText: "LTC - Litecoin",