mirror of
https://github.com/ok2/coinbin.git
synced 2026-05-09 18:15:23 +02:00
custom data can now be added to the block chain using OP_RETURN when building a transaction
This commit is contained in:
+16
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user