Created
December 31, 2014 18:14
-
-
Save eordano/9d311fda42299f153830 to your computer and use it in GitHub Desktop.
Bitcore Stealth testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Stealth = require('../'); | |
var bitcore = require('bitcore') ; | |
var spends = [ | |
new bitcore.PrivateKey(), | |
new bitcore.PrivateKey(), | |
new bitcore.PrivateKey() | |
]; | |
var scanKey = new bitcore.PrivateKey(); | |
var address = new Stealth.Address(scanKey, spends, 2); | |
console.log(spends); | |
console.log(scanKey); | |
console.log(address); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bitcore = require('bitcore'); | |
var Stealth = require('../index'); | |
var Tx = Stealth.Transaction; | |
var priv1 = new bitcore.PrivateKey('L3y1PAXfjayeB3w6NP7qfNxPbuPpQFA6hd6gj4BUKa2xSdLwoVSZ'); | |
var priv2 = new bitcore.PrivateKey('L3a57fiNjqfbXBdYvvGYPQ1HiDX463mwA2xFGTYVkXYdooaz9Z2u'); | |
var pubs = ["03411e021210a933c247ea9c8dad4bbead281597d508ad84e899de13e4ce98b4ba", "03bda2c3cc11a391b36e3d695b03ab42b96fe04086b2349056108d858983e60dab", "03c16e6ecf4e02bf9db23d3247ab92db8881f0866133ffb530c3470f6d8dea7330"]; | |
var tx = new Tx(); | |
var utxo = {"address":"38nw4sTs3fCH1YiBjYeQAX1t9eWMxpek8Z","txid":"04eaa79e7371e7283c330c320b8953aad82c7dd33a44ee9d295d0dfbd1791963","vout":1,"ts":1418878498,"scriptPubKey":"a9144de752833233fe69a20064f29b2ca0f6399c8af387","amount":0.0016,"confirmations":1911,"confirmationsFromCache":false}; | |
var stealth = '2aeHHmd5S8rSEKN4fVGhEjvdnc5jPw7CSLNDXMXeBvxqd8N9nKKFxoPVzHnWeu5LC4KqaqZhguwaf4h8tSh3DkHFgFHoNHFwYXoTPC5guhcRbEpPxErRnqwGevFrJmK62ECWUT4WqZZ9umPGRrnbMqSEHKLydXVx2vMNgVqvWGMs2u3FR5f7Jo25Mts4eYcNg'; | |
console.log( | |
'curl https://insight.bitpay.com/api/tx/send -d rawtx='+ | |
( | |
tx | |
.from(utxo, pubs, 2) | |
.to(stealth, 150000) | |
.change('38nw4sTs3fCH1YiBjYeQAX1t9eWMxpek8Z') | |
.sign(priv1) | |
.sign(priv2) | |
.serialize() | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bitcore = require('bitcore'); | |
var Stealth = require('../'); | |
var prevRaw = '0100000001631979d1fb0d5d299dee443ad37d2cd8aa53890b320c333c28e771739ea7ea0401000000fdfd0000483045022100af561597d964ee13dc66f4dff38c7c17ac88ddeeb3a979c614930c9e48a0a14002206a93050ca262fe4e7c6dd6e1359ceb020da2d44869e745e2cc36aed240ed0f040147304402201b413c50a5b8aeed5725aa1d00a8caa56043fdf62b5c9e76d147cdb9025af8a202201ca972c35a0ce1f7cf7420d01ebae3d650f9a6ade41f0ebd96f0bc633caacd7a014c69522103411e021210a933c247ea9c8dad4bbead281597d508ad84e899de13e4ce98b4ba2103bda2c3cc11a391b36e3d695b03ab42b96fe04086b2349056108d858983e60dab2103c16e6ecf4e02bf9db23d3247ab92db8881f0866133ffb530c3470f6d8dea733053aeffffffff020000000000000000286a26060000000003d08a21eb9188ddd21f11eba64b30c8a638de24d89697fe6afb9d98a480574ea7f04902000000000017a91427c8eb0ba6565df77e48263fa3d46ac6a0280e7f8700000000'; | |
var address = '35KNy4bALNuffVPiAbRuhwLHcEnt7HHzpj'; | |
var utxo = {"address":"35KNy4bALNuffVPiAbRuhwLHcEnt7HHzpj","txid":"d54a8076da21ca98192131b20dff1589b2e6f245d6c956190679c16614d8f6a0","vout":1,"ts":1419980873,"scriptPubKey":"a91427c8eb0ba6565df77e48263fa3d46ac6a0280e7f87","amount":0.0015,"confirmationsFromCache":false}; | |
var prevTx = new bitcore.Transaction(prevRaw); | |
var ephemeral = Stealth.Transaction.getEphemeral(prevTx.outputs[0]); | |
var logEphemeral = new bitcore.PrivateKey('Kxdfiy8rtLk3zCt8FUD9zBZcT9sHBQev4ioJdKDP24E4vkSYDy4L'); | |
logEphemeral = new bitcore.PrivateKey(logEphemeral.bn, bitcore.Networks.testnet); | |
console.log(ephemeral); | |
console.log(logEphemeral.publicKey); | |
var scan = new bitcore.PrivateKey('KyurZZDt14YYeuD98eSQZiN86ZEMv5jFxeM5mn3ntjJjfUWQVSA2'); | |
var spend = [ | |
new bitcore.PrivateKey('Kz3EJ5zkyxwzU121aQvuB88FEtpSJVaCLTJMinGksmDcTdh3oyQd'), | |
new bitcore.PrivateKey('L1kn4HqtvvQJv4rTEJKJwCtPM2BZzVSYJCFqeTGM2si39SHTPvg7'), | |
new bitcore.PrivateKey('L271yFCQWYdASHuFnxsBzKpjvFCjUVhqGBTmqATqdnXjg7ri3KBn'), | |
]; | |
var deducedKey1 = Stealth.Address.getStealthPrivateKey(ephemeral, scan, spend[0]); | |
var deducedKey2 = Stealth.Address.getStealthPrivateKey(ephemeral, scan, spend[1]); | |
var deducedKey3 = Stealth.Address.getStealthPrivateKey(ephemeral, scan, spend[2]); | |
var deduced = [deducedKey1, deducedKey2, deducedKey3]; | |
var deducedPublic = [deducedKey1, deducedKey2, deducedKey3].map(bitcore.PublicKey); | |
console.log(new bitcore.Address(deducedPublic, 2)); | |
console.log(address); | |
var tx = new bitcore.Transaction(); | |
console.log( | |
'curl https://insight.bitpay.com/api/tx/send -d rawtx=' + | |
tx.from(utxo, deducedPublic, 2) | |
.to('38nw4sTs3fCH1YiBjYeQAX1t9eWMxpek8Z', 140000) | |
.sign(deducedKey1) | |
.sign(deducedKey2) | |
.serialize() | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ <PrivateKey: Kz3EJ5zkyxwzU121aQvuB88FEtpSJVaCLTJMinGksmDcTdh3oyQd, network: livenet>, | |
<PrivateKey: L1kn4HqtvvQJv4rTEJKJwCtPM2BZzVSYJCFqeTGM2si39SHTPvg7, network: livenet>, | |
<PrivateKey: L271yFCQWYdASHuFnxsBzKpjvFCjUVhqGBTmqATqdnXjg7ri3KBn, network: livenet> ] | |
<PrivateKey: KyurZZDt14YYeuD98eSQZiN86ZEMv5jFxeM5mn3ntjJjfUWQVSA2, network: livenet> | |
<Stealth Address: 2aeHHmd5S8rSEKN4fVGhEjvdnc5jPw7CSLNDXMXeBvxqd8N9nKKFxoPVzHnWeu5LC4KqaqZhguwaf4h8tSh3DkHFgFHoNHFwYXoTPC5guhcRbEpPxErRnqwGevFrJmK62ECWUT4WqZZ9umPGRrnbMqSEHKLydXVx2vMNgVqvWGMs2u3FR5f7Jo25Mts4eYcNg, network: livenet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using ephemeral: <PrivateKey: Kxdfiy8rtLk3zCt8FUD9zBZcT9sHBQev4ioJdKDP24E4vkSYDy4L, network: livenet> | |
curl https://insight.bitpay.com/api/tx/send -d rawtx=0100000001631979d1fb0d5d299dee443ad37d2cd8aa53890b320c333c28e771739ea7ea0401000000fdfd0000483045022100af561597d964ee13dc66f4dff38c7c17ac88ddeeb3a979c614930c9e48a0a14002206a93050ca262fe4e7c6dd6e1359ceb020da2d44869e745e2cc36aed240ed0f040147304402201b413c50a5b8aeed5725aa1d00a8caa56043fdf62b5c9e76d147cdb9025af8a202201ca972c35a0ce1f7cf7420d01ebae3d650f9a6ade41f0ebd96f0bc633caacd7a014c69522103411e021210a933c247ea9c8dad4bbead281597d508ad84e899de13e4ce98b4ba2103bda2c3cc11a391b36e3d695b03ab42b96fe04086b2349056108d858983e60dab2103c16e6ecf4e02bf9db23d3247ab92db8881f0866133ffb530c3470f6d8dea733053aeffffffff020000000000000000286a26060000000003d08a21eb9188ddd21f11eba64b30c8a638de24d89697fe6afb9d98a480574ea7f04902000000000017a91427c8eb0ba6565df77e48263fa3d46ac6a0280e7f8700000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment