From ef5cbdb61e2b4261ac53468406b3beed95a56ea7 Mon Sep 17 00:00:00 2001 From: OutCast3k Date: Tue, 23 Jun 2015 22:34:30 +0000 Subject: [PATCH] new changes to allow for the use of testnet and other altcoins --- index.html | 101 +++++++++++++++++++++++++++- js/coin.js | 4 +- js/coinbin.js | 179 ++++++++++++++++++++++++++++++++++++++++++++++++-- sha1sum | 8 +-- 4 files changed, 280 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 6afa6ba..7ef0005 100644 --- a/index.html +++ b/index.html @@ -64,6 +64,8 @@
  • Broadcast
  • Wallet
  • About
  • + + @@ -787,17 +789,110 @@

    About open source bitcoin wallet

    -

    Version 1.1 by OutCast3k

    +

    Version 1.2

    Compatible with bitcoin-qt

    Github https://github.com/OutCast3k/coinbin/

    TOR 4zpinp6gdkjfplhk.onion

    +

    What is bitcoin?

    +

    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 weusecoins.com for more information.

    Information

    Coinb.in is a free and open source project released under the MIT license, originally by OutCast3k in 2013. Discussion of the project can be found at bitcointalk.org during its early testing stages when its primary focus was to develop a proof of concept multisig solution in javascript.

    Coinb.in is run and funded by the generosity of others in terms of development and hosting.

    Privacy

    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.

    Donate

    -

    Please donate to 1CWHWkTWaq1K5hevimJia3cyinQsrgXUvg if you found this project useful or want to see more features!

    +

    Please donate to 1CWHWkTWaq1K5hevimJia3cyinQsrgXUvg if you found this project useful or want to see more features!

    +
    + +
    +

    Settings making coinb.in even better!

    +

    These simple settings below make coinb.in one of the most decentralized wallets in the world.

    + +
    +
    + Network:
    +

    Select which network you'd like to use for key pair generation.

    + +
    +
    + + + +
    + +
    +
    + Broadcast:
    +

    Select the network you wish to broadcast the transaction via

    + +
    +
    + +
    + +
    +
    + Unspent outputs:
    +

    Select the network you wish to retreive your unspent inputs from

    + +
    +
    + +
    + + + + +

    @@ -810,7 +905,7 @@ diff --git a/js/coin.js b/js/coin.js index 4ca2f7a..e83087b 100644 --- a/js/coin.js +++ b/js/coin.js @@ -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 = []; diff --git a/js/coinbin.js b/js/coinbin.js index 958f696..a460f18 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -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(''); + }, + 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(''); + } + }, + 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(''); + }, + 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(''); + } + }, + 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(" 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) diff --git a/sha1sum b/sha1sum index 9478514..b1566b4 100644 --- a/sha1sum +++ b/sha1sum @@ -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