Skip to content

Commit

Permalink
hex encoded pubkeys.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloneearth committed Feb 25, 2018
1 parent 7bde7fc commit 5020ef8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class App extends Component {
usePassword: false,
displayTestnet: false
});
store.set('wallet', this.wallet);

this.blockchain = new Blockchain();

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -163,6 +165,7 @@ class App extends Component {
} else if (id === 'totalAccounts') {
this.wallet.totalAccounts = value;
}
store.set('wallet', this.wallet);
}

handleConfigToggle(value, id) {
Expand All @@ -186,6 +189,7 @@ class App extends Component {

this.wallet.usePassword = value;
}
store.set('wallet', this.wallet);
}

createBlock() {
Expand Down
12 changes: 9 additions & 3 deletions src/utilities/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 5020ef8

Please sign in to comment.