new changes to allow for the use of testnet and other altcoins

This commit is contained in:
OutCast3k 2015-06-23 22:34:30 +00:00
parent 7ef0046fe3
commit ef5cbdb61e
4 changed files with 280 additions and 12 deletions

View file

@ -64,6 +64,8 @@
<li><a href="#broadcast" data-toggle="tab"><span class="glyphicon glyphicon-globe"></span> Broadcast</a></li>
<li><a href="#wallet" data-toggle="tab"><span class="glyphicon glyphicon-briefcase"></span> Wallet</a></li>
<li><a href="#about" data-toggle="tab"><span class="glyphicon glyphicon-info-sign"></span> About</a></li>
<li class="hidden"><a href="#settings" data-toggle="tab"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
</ul>
</div>
</div>
@ -787,17 +789,110 @@
<div class="tab-pane tab-content" id="about">
<h2>About <small>open source bitcoin wallet</small></h2>
<p>Version 1.1 by <a href="https://bitcointalk.org/index.php?action=profile;u=34834" target="_blank">OutCast3k</a></p>
<p>Version 1.2</p>
<p>Compatible with bitcoin-qt</p>
<p>Github <a href="https://github.com/OutCast3k/coinbin/">https://github.com/OutCast3k/coinbin/</a></p>
<p>TOR <a href="http://4zpinp6gdkjfplhk.onion">4zpinp6gdkjfplhk.onion</a></p>
<h3>What is bitcoin?</h3>
<p>Bitcoin is a type of digital currency in which encryption techniques are used to regulate the generation of units of currency and verify the transfer of funds, operating independently of a central bank. See <a href="http://www.weusecoins.com/" target="_blank">weusecoins.com</a> for more information.</p>
<h3>Information</h3>
<p>Coinb.in is a free and open source project released under the MIT license, originally by <a href="https://bitcointalk.org/index.php?action=profile;u=34834" target="_blank">OutCast3k</a> in 2013. Discussion of the project can be found at <a href="https://bitcointalk.org/index.php?topic=390046" target="_blank">bitcointalk.org</a> during its early testing stages when its primary focus was to develop a proof of concept multisig solution in javascript.</p>
<p>Coinb.in is run and funded by the generosity of others in terms of <a href="https://github.com/OutCast3k/coinbin/graphs/contributors" target="_blank">development</a> and hosting.</p>
<h3>Privacy</h3>
<p>Coinb.in beleives strongly in privacy, not only do we support the use of TOR, the site does not collect and store IP or transaction data via our servers nor do we store your bitcoins private key. We do use google analytics to track hits and route traffic via cloudflare using an SSL certificate.</p>
<h3>Donate</h3>
<p>Please donate to 1CWHWkTWaq1K5hevimJia3cyinQsrgXUvg if you found this project useful or want to see more features!</p>
<p>Please donate to <a href="bitcoin:1CWHWkTWaq1K5hevimJia3cy">1CWHWkTWaq1K5hevimJia3cyinQsrgXUvg</a> if you found this project useful or want to see more features!</p>
</div>
<div class="tab-pane tab-content" id="settings">
<h2>Settings <small> making coinb.in even better!</small></h2>
<p>These simple settings below make coinb.in one of the most decentralized wallets in the world.</p>
<div class="row">
<div class="col-md-12">
<b>Network</b>: <br>
<p class="text-muted">Select which network you'd like to use for key pair generation.</p>
<select class="form-control" id="coinjs_coin">
<option value="bitcoin_mainnet" rel="0x00;0x80;0x05;0x488b21e;0x488ade4;coinb.in;coinb.in">Bitcoin (mainnet)</option>
<option value="bitcoin_testnet" rel="0x6f;0xc4;0xef;0x043587cf;0x04358394;blockr.io_bitcointestnet;false">Bitcoin (testnet)</option>
<option value="custom" rel="0x00;0x80;0x05;0x488b21e;0x488ade4;false;false">Custom</option>
</select>
</div>
</div>
<div id="settingsCustom" class="hidden">
<hr>
<div class="row">
<div class="col-md-4">
<b>Pub</b>: <br>
<input type="text" class="form-control coinjssetting" id="coinjs_pub">
</div>
<div class="col-md-4">
<b>Priv</b>: <br>
<input type="text" class="form-control coinjssetting" id="coinjs_priv">
</div>
<div class="col-md-4">
<b>Script Hash (multisig)</b>: <br>
<input type="text" class="form-control coinjssetting" id="coinjs_multisig">
</div>
</div>
<div class="row">
<div class="col-md-6">
<b>HD Pub</b>: <br>
<input type="text" class="form-control coinjssetting" id="coinjs_hdpub">
</div>
<div class="col-md-6">
<b>HD Priv</b>: <br>
<input type="text" class="form-control coinjssetting" id="coinjs_hdprv">
</div>
</div>
<br>
<div class="alert alert-info"> <span class="glyphicon glyphicon-info-sign"></span> You will not be able to automatically broadcast or retreive your unspent inputs from coinb.in when using this setting and will need to use your desktop client instead, however everything else will continue to function normally.</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<b>Broadcast</b>: <br>
<p class="text-muted">Select the network you wish to broadcast the transaction via</p>
<select class="form-control" id="coinjs_broadcast">
<option value="coinb.in">coinb.in (Bitcoin mainnet)</option>
<option value="blockr.io_bitcoinmainnet"> Blockr.io (Bitcoin mainnet)</option>
<option value="blockr.io_bitcointestnet"> Blockr.io (Bitcoin testnet)</option>
</select>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<b>Unspent outputs</b>: <br>
<p class="text-muted">Select the network you wish to retreive your unspent inputs from</p>
<select class="form-control" id="coinjs_utxo">
<option value="coinb.in">coinb.in (Bitcoin mainnet)</option>
</select>
</div>
</div>
<br>
<div id="statusSettings" class="hidden alert">
</div>
<input type="submit" class="btn btn-primary" id="settingsBtn">
</div>
<br>
@ -810,7 +905,7 @@
<div id="footer">
<div class="container text-right">
<p class="text-muted">Version 1.1</p>
<p class="text-muted">Version 1.2</p>
</div>
</div>

View file

@ -471,7 +471,7 @@
o.child_index = i;
if(this.type=='private'){
// derive xpub/xprv from a xprv key
// derive key pair from from a xprv key
k = il.add(new BigInteger([0].concat(Crypto.util.hexToBytes(this.keys.privkey)))).mod(ecparams.getN());
key = Crypto.util.bytesToHex(k.toByteArrayUnsigned());
@ -510,6 +510,7 @@
return o;
}
// make a master hd xprv/xpub
r.master = function(pass) {
var seed = (pass) ? Crypto.SHA256(pass) : coinjs.newPrivkey();
var hasher = new jsSHA(seed, 'HEX');
@ -527,6 +528,7 @@
'pubkey':coinjs.newPubkey(I.slice(0, 64))});
}
// encode data to a base58 string
r.make = function(data){ // { (int) depth, (array) parent_fingerprint, (int) child_index, (byte array) chain_code, (hex str) privkey, (hex str) pubkey}
var k = [];

View file

@ -412,8 +412,8 @@ $(document).ready(function() {
$.each($("#recipients .row"), function(i,o){
var a = ($(".address",o).val());
var ad = coinjs.addressDecode(a)
if(((a!="") && (ad.version === 0 || ad.version === 5)) && $(".amount",o).val()!=""){ // address
var ad = coinjs.addressDecode(a);
if(((a!="") && (ad.version == coinjs.pub || ad.version == coinjs.priv)) && $(".amount",o).val()!=""){ // address
tx.addoutput(a, $(".amount",o).val());
} else if (((a!="") && ad.version === 42) && $(".amount",o).val()!=""){ // stealth address
tx.addstealth(ad, $(".amount",o).val());
@ -627,7 +627,12 @@ $(document).ready(function() {
/* broadcast a transaction */
$("#rawSubmitBtn").click(function(){
var thisbtn = this;
rawSubmitDefault(this);
});
// broadcast transaction vai coinbin (default)
function rawSubmitDefault(btn){
var thisbtn = btn;
var tx = coinjs.transaction();
$(thisbtn).val('Please wait, loading...').attr('disabled',true);
tx.broadcast(function(data){
@ -641,7 +646,69 @@ $(document).ready(function() {
$("#rawTransactionStatus").fadeOut().fadeIn();
$(thisbtn).val('Submit').attr('disabled',false);
}, $("#rawTransaction").val());
});
}
// broadcast transaction via blockr.io (mainnet)
function rawSubmitBlockrio_BitcoinMainnet(thisbtn){
$(thisbtn).val('Please wait, loading...').attr('disabled',true);
$.ajax ({
type: "POST",
url: "https://btc.blockr.io/api/v1/tx/push",
data: {"hex":$("#rawTransaction").val()},
dataType: "json",
error: function(data) {
var obj = $.parseJSON(data.responseText);
var r = ' ';
r += (obj.data) ? obj.data : '';
r += (obj.message) ? ' '+obj.message : '';
r = (r!='') ? r : ' Failed to broadcast'; // build response
$("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>');
},
success: function(data) {
var obj = $.parseJSON(data.responseText);
if((obj.status && obj.data) && obj.status=='success'){
$("#rawTransactionStatus").addClass('alert-success').removeClass('alert-danger').removeClass("hidden").html(' Txid: '+obj.data);
} else {
$("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(' Unexpected error, please try again').prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>');
}
},
complete: function(data, status) {
$("#rawTransactionStatus").fadeOut().fadeIn();
$(thisbtn).val('Submit').attr('disabled',false);
}
});
}
// broadcast transaction via blockr.io (testnet)
function rawSubmitBlockrio_BitcoinTestnet(thisbtn){
$(thisbtn).val('Please wait, loading...').attr('disabled',true);
$.ajax ({
type: "POST",
url: "https://tbtc.blockr.io/api/v1/tx/push",
data: {"hex":$("#rawTransaction").val()},
dataType: "json",
error: function(data) {
var obj = $.parseJSON(data.responseText);
var r = ' ';
r += (obj.data) ? obj.data : '';
r += (obj.message) ? ' '+obj.message : '';
r = (r!='') ? r : ' Failed to broadcast'; // build response
$("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>');
},
success: function(data) {
var obj = $.parseJSON(data.responseText);
if((obj.status && obj.data) && obj.status=='success'){
$("#rawTransactionStatus").addClass('alert-success').removeClass('alert-danger').removeClass("hidden").html(' Txid: '+obj.data);
} else {
$("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(' Unexpected error, please try again').prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>');
}
},
complete: function(data, status) {
$("#rawTransactionStatus").fadeOut().fadeIn();
$(thisbtn).val('Submit').attr('disabled',false);
}
});
}
/* verify script code */
@ -988,6 +1055,110 @@ $(document).ready(function() {
validateOutputAmount();
/* settings page code */
$("#coinjs_pub").val('0x'+(coinjs.pub).toString(16));
$("#coinjs_priv").val('0x'+(coinjs.priv).toString(16));
$("#coinjs_multisig").val('0x'+(coinjs.multisig).toString(16));
$("#coinjs_hdpub").val('0x'+(coinjs.hdkey.pub).toString(16));
$("#coinjs_hdprv").val('0x'+(coinjs.hdkey.prv).toString(16));
$("#settingsBtn").click(function(){
$("#statusSettings").removeClass("alert-success").removeClass("alert-danger").addClass("hidden").html("");
$("#settings .has-error").removeClass("has-error");
$.each($(".coinjssetting"),function(i, o){
if(!$(o).val().match(/^0x[0-9a-f]+$/)){
$(o).parent().addClass("has-error");
}
});
if($("#settings .has-error").length==0){
coinjs.pub = $("#coinjs_pub").val()*1;
coinjs.priv = $("#coinjs_priv").val()*1;
coinjs.multisig = $("#coinjs_multisig").val()*1;
coinjs.hdkey.pub = $("#coinjs_hdpub").val()*1;
coinjs.hdkey.prv = $("#coinjs_hdprv").val()*1;
configureBroadcast();
configureGetUnspentTx();
$("#statusSettings").addClass("alert-success").removeClass("hidden").html("<span class=\"glyphicon glyphicon-ok\"></span> Settings updates successfully").fadeOut().fadeIn();
} else {
$("#statusSettings").addClass("alert-danger").removeClass("hidden").html("There is an error with one or more of your settings");
}
});
$("#coinjs_coin").change(function(){
// log out of openwallet
$("#walletLogout").click();
var o = ($("option:selected",this).attr("rel")).split(";");
// deal with broadcasting settings
if(o[5]=="false"){
$("#coinjs_broadcast, #rawTransaction, #rawSubmitBtn, #openBtn").attr('disabled',true);
$("#coinjs_broadcast").val("coinb.in");
} else {
$("#coinjs_broadcast").val(o[5]);
$("#coinjs_broadcast, #rawTransaction, #rawSubmitBtn, #openBtn").attr('disabled',false);
}
// deal with unspent output settings
if(o[6]=="false"){
$("#coinjs_utxo, #redeemFrom, #redeemFromBtn, #openBtn, .qrcodeScanner").attr('disabled',true);
$("#coinjs_utxo").val("coinb.in");
} else {
$("#coinjs_utxo").val(o[6]);
$("#coinjs_utxo, #redeemFrom, #redeemFromBtn, #openBtn, .qrcodeScanner").attr('disabled',false);
}
// deal with the reset
$("#coinjs_pub").val(o[0]);
$("#coinjs_prv").val(o[1]);
$("#coinjs_multisig").val(o[2]);
$("#coinjs_hdpub").val(o[3]);
$("#coinjs_hdprv").val(o[4]);
// hide/show custom screen
if($("option:selected",this).val()=="custom"){
$("#settingsCustom").removeClass("hidden");
} else {
$("#settingsCustom").addClass("hidden");
}
});
function configureBroadcast(){
var host = $("#coinjs_broadcast option:selected").val();
var tx = coinjs.transaction();
$("#rawSubmitBtn").unbind("");
if(host=="blockr.io_bitcointestnet"){
$("#rawSubmitBtn").click(function(){
rawSubmitBlockrio_BitcoinTestnet(this)
});
} else if(host=="blockr.io_bitcoinmainnet"){
$("#rawSubmitBtn").click(function(){
rawSubmitBlockrio_BitcoinMainnet(this);
});
} else {
$("#rawSubmitBtn").click(function(){
rawSubmitDefault(this); // revert to default
});
}
}
function configureGetUnspentTx(){
// function coming soon, which will allow you to retrieve unspent inputs
// from other block chain providers
return false;
}
/* capture mouse movement to add entropy */
var IE = document.all?true:false // Boolean, is browser IE?
if (!IE) document.captureEvents(Event.MOUSEMOVE)

View file

@ -1,4 +1,4 @@
---- Version 1.1 2015.05.17 ----
---- Version 1.2 2015.07.23 ----
e6810907c901e6bd34a28735a68850936f0823b8 ./js/ellipticcurve.js
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
@ -10,8 +10,8 @@ f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
ad038e1f39646b68ae666324ed4c2882a8c42474 ./js/qrcode.js
64eb4ea5c882f8bce3e1885bf00728455f1c2f4c ./js/ripemd160.js
114089ef2a3feb6d4db4f9cabcb186d7750d5884 ./js/sha512.js
782ecafc45b2e791451b9d43659c815c76d4816d ./js/coin.js
a979f7ac0f1f2d9e2edad7b3d10e13fedc2695ae ./js/coinbin.js
3ff26f7ca616b01742a25f9aa304bdb653ce4a4d ./js/coin.js
cb26a4ae2216754f3089daaf7605e3ac41410126 ./js/coinbin.js
ae49e56999d82802727455f0ba83b63acd90a22b ./js/jquery-1.9.1.min.js
5f570018ed044eafd464f7e0ab1783b966224055 ./LICENCE
ed29315e0ffb3f14382431f2724235bf67f44eb3 ./css/bootstrap.min.css
@ -25,4 +25,4 @@ de51a8494180a6db074af2dee2383f0a363c5b08 ./fonts/glyphicons-halflings-regular.s
278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff
44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf
fe8d57914bb036ab94e86ec35b2671eeb6d20d0d ./README.md
f96bf532933abcdf8fe48ba8a1d22ab003ec6426 ./index.html
f4803ce0396b7e65d2f9dd4a5ae232b32403ef19 ./index.html