diff --git a/index.html b/index.html index fb785bb..61aa67a 100644 --- a/index.html +++ b/index.html @@ -283,7 +283,7 @@
Use this page to create to create a raw transaction
+Use this page to create a raw transaction
Address, WIF key or Multisig Redeem Script:+ +
The locktime indicates the earliest time a transaction can be added to the block chain.
diff --git a/js/coin.js b/js/coin.js index a1a2c1a..a303f31 100644 --- a/js/coin.js +++ b/js/coin.js @@ -383,9 +383,25 @@ o.value = new BigInteger('' + Math.round((value*1) * 1e8), 10); var s = coinjs.script(); o.script = s.spendToScript(address); + return this.outs.push(o); } + /* add data to a transaction */ + r.adddata = function(data){ + var r = false; + if(((data.match(/^[a-f0-9]+$/gi)) && data.length<80) && (data.length%2)==0) { + var s = coinjs.script(); + s.writeOp(106); // OP_RETURN + s.writeBytes(Crypto.util.hexToBytes(data)); + o = {}; + o.value = 0; + o.script = s; + return this.outs.push(o); + } + return r; + } + /* list unspent transactions */ r.listUnspent = function(address, callback) { coinjs.ajax(coinjs.host+'?uid='+coinjs.uid+'&key='+coinjs.key+'&setmodule=addresses&request=unspent&address='+address+'&r='+Math.random(), callback, "GET"); diff --git a/js/coinbin.js b/js/coinbin.js index 6016fa3..a411b67 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -361,9 +361,16 @@ $(document).ready(function() { } }); + $("#recipients .row").removeClass('has-error'); + $.each($("#recipients .row"), function(i,o){ - if($(".address",o).val()!="" && $(".amount",o).val()!=""){ - tx.addoutput($(".address",o).val(), $(".amount",o).val()); + var a = ($(".address",o).val()).substr(0,80); + if(((a!="") && coinjs.addressDecode(a)) && $(".amount",o).val()!=""){ // address + tx.addoutput(a, $(".amount",o).val()); + } else if (((($("#opReturn").is(":checked")) && a.match(/^[a-f0-9]+$/ig)) && a.length<80) && (a.length%2)==0) { // data + tx.adddata(a); + } else { // neither address nor data + $(o).addClass('has-error'); } }); @@ -589,26 +596,44 @@ $(document).ready(function() { h += ''; h += ''; }); + $(h).appendTo("#verifyTransactionData .ins tbody"); h = ''; $.each(decode.outs, function(i,o){ - var addr = ''; - if(o.script.chunks.length==5){ - addr = coinjs.scripthash2address(Crypto.util.bytesToHex(o.script.chunks[2])); - } else { - var pub = coinjs.pub; - coinjs.pub = coinjs.multisig; - addr = coinjs.scripthash2address(Crypto.util.bytesToHex(o.script.chunks[1])); - coinjs.pub = pub; - } + if(o.script.chunks.length==2 && o.script.chunks[0]==106){ // OP_RETURN - h += '