From 5020ef877390cec03e1c787f0f0bb652bc2ab5b5 Mon Sep 17 00:00:00 2001 From: Gabriel Cardona Date: Sun, 25 Feb 2018 07:06:28 -0800 Subject: [PATCH] hex encoded pubkeys. --- src/App.js | 4 ++++ src/utilities/Server.js | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index d346709..16fba1d 100644 --- a/src/App.js +++ b/src/App.js @@ -56,6 +56,7 @@ class App extends Component { usePassword: false, displayTestnet: false }); + store.set('wallet', this.wallet); this.blockchain = new Blockchain(); @@ -120,6 +121,7 @@ class App extends Component { this.miner = new Miner(this.blockchain, this.utxoSet, this.wallet.network); let [mnemonic, path, addresses] = BitcoinCash.createHDWallet(this.wallet); + store.set('addresses', addresses); this.setState({ mnemonic: mnemonic, path: path, @@ -163,6 +165,7 @@ class App extends Component { } else if (id === 'totalAccounts') { this.wallet.totalAccounts = value; } + store.set('wallet', this.wallet); } handleConfigToggle(value, id) { @@ -186,6 +189,7 @@ class App extends Component { this.wallet.usePassword = value; } + store.set('wallet', this.wallet); } createBlock() { diff --git a/src/utilities/Server.js b/src/utilities/Server.js index bc600c2..0cb55bb 100644 --- a/src/utilities/Server.js +++ b/src/utilities/Server.js @@ -33,17 +33,23 @@ class Server { let nrequired = params[0]; let keys = params[1]; let addresses = store.get('addresses'); + let wallet = store.get('wallet'); let keyPairs = []; + let pubKeys = []; keys.forEach((key, index) => { - keyPairs.push(BitcoinCash.fromWIF(BitcoinCash.returnPrivateKeyWIF(key, addresses), 'bitcoin')) + if(key.toString('hex').length === 66) { + pubKeys.push(key); + } else { + let privkeyWIF = BitcoinCash.returnPrivateKeyWIF(key, addresses); + keyPairs.push(BitcoinCash.fromWIF(privkeyWIF, wallet.network)) + } }) - let pubKeys = []; keyPairs.forEach((key, index) => { pubKeys.push(key.getPublicKeyBuffer()); }) - pubKeys.map(function (hex) { return Buffer.from(hex, 'hex') }) + pubKeys.map((hex) => { return Buffer.from(hex, 'hex') }) let redeemScript = Bitcoin.script.multisig.output.encode(nrequired, pubKeys) // 2 of 3 let scriptPubKey = Bitcoin.script.scriptHash.output.encode(Bitcoin.crypto.hash160(redeemScript))