From 4958ea8009e3c950a680bded814994428630b645 Mon Sep 17 00:00:00 2001 From: Jang Chongchan Date: Fri, 24 Apr 2020 10:20:50 +0900 Subject: Add Sugarchain support --- src/js/bitcoinjs-extensions.js | 11 +++++++++++ src/js/index.js | 7 +++++++ src/js/segwit-parameters.js | 26 ++++++++++++++++++++++++++ tests/spec/tests.js | 10 ++++++++++ 4 files changed, 54 insertions(+) diff --git a/src/js/bitcoinjs-extensions.js b/src/js/bitcoinjs-extensions.js index 17475b1..7446bd7 100644 --- a/src/js/bitcoinjs-extensions.js +++ b/src/js/bitcoinjs-extensions.js @@ -1739,6 +1739,17 @@ libs.bitcoin.networks.elastos = { wif: 0xef // TODO set this correctly, same as BTC for now }; +libs.bitcoin.networks.sugarchain = { + messagePrefix: '\x18Sugarchain Signed Message:\n', + bip32: { + public: 0x0488B21E, + private: 0x0488ADE4, + }, + pubKeyHash: 0x3f, + scriptHash: 0x7d, + wif: 0x80 +}; + // https://github.com/libs.bitcoinjs-lib/blob/3f6f5ef97a1ee1b8337865209282c0095e22b2e7/src/networks.js libs.bitcoin.networks.regtest = { messagePrefix: '\x18Bitcoin Signed Message:\n', diff --git a/src/js/index.js b/src/js/index.js index c2d34a7..841a27f 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -3091,6 +3091,13 @@ setHdCoin(105); }, }, + { + name: "SUGAR - Sugarchain", + onSelect: function() { + network = libs.bitcoin.networks.sugarchain; + setHdCoin(408); + }, + }, { name: "SWTC - Jingtum", onSelect: function() { diff --git a/src/js/segwit-parameters.js b/src/js/segwit-parameters.js index d5ea419..0c41bf7 100644 --- a/src/js/segwit-parameters.js +++ b/src/js/segwit-parameters.js @@ -683,4 +683,30 @@ libs.bitcoin.networks.deeponion.p2wpkhInP2sh = { wif: 0x9f }; +libs.bitcoin.networks.sugarchain.p2wpkh = { + baseNetwork: "sugarchain", + messagePrefix: '\x1DSugarchain Signed Message:\n', + bech32: 'sugar', + bip32: { + public: 0x04b24746, + private: 0x04b2430c + }, + pubKeyHash: 0x3f, + scriptHash: 0x7d, + wif: 0x80 +}; + +libs.bitcoin.networks.sugarchain.p2wpkhInP2sh = { + baseNetwork: "sugarchain", + messagePrefix: '\x1DSugarchain Signed Message:\n', + bech32: 'sugar', + bip32: { + public: 0x049d7cb2, + private: 0x049d7878 + }, + pubKeyHash: 0x3f, + scriptHash: 0x7d, + wif: 0x80 +}; + })(); diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 31fa043..d9a1843 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js @@ -1675,6 +1675,16 @@ it('Allows selection of Stratis Test', function(done) { }; testNetwork(done, params); }); +it('Allows selection of Sugarchain', function(done) { + var params = { + selectText: "SUGAR - Sugarchain", + phrase: "abandon abandon ability", + firstAddress: "SYnd31fYr39VgKju87Vz1sYBmEeHg5cudk", + firstPubKey: "035bc9fa22eff2246ec07bb09c9e32f5f9fee517b4f49a8f117508f8fb41905b25", + firstPrivKey: "L2G3axGdZv5EV8osAsBPMese74i4dTHaGvxDh7DsRF5Ky6hKkPDY", + }; + testNetwork(done, params); +}); it('Allows selection of Syscoin', function(done) { var params = { selectText: "SYS - Syscoin", -- cgit v1.2.3