From b4fd55aebe643efb167d2069daf55203465ba918 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 6 Jul 2020 21:33:57 +0000 Subject: [PATCH] added feature to rebuild a transaction from the txid, useful for RBF and double spending :o. Changed donation address. Released as version 1.6 --- README.md | 17 ++++++------ index.html | 8 +++--- js/coin.js | 7 ++++- js/coinbin.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++----- sha1sum | 10 ++++---- 5 files changed, 88 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 26c825d..5ccd99c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ coinbin ======= -A Open Source Browser Based Bitcoin Wallet. Version 1.5 beta by OutCast3k +A Open Source Browser Based Bitcoin Wallet. Version 1.6 beta by OutCast3k Live version available at http://coinb.in/ or http://4zpinp6gdkjfplhk.onion @@ -24,12 +24,13 @@ Coinb.in supports a number of key features such as: - Brain wallet support. - Compatible with bitcoin-qt - An offical .onion address for tor users. -- Offline qrcode creator and scanning tool -- HD (bip32) support -- Supports altcoins such as litecoin -- Replace by fee (RBF) Support -- Segwit Support -- Bech32 address support +- Offline qrcode creator and scanning tool. +- HD (bip32) support. +- Supports altcoins such as litecoin. +- Replace by fee (RBF) Support. +- Segwit Support. +- Bech32 address support. - Fee calculator - https://coinb.in/#fees +- Transaction rebuild support for RBF and double spending. -Donate to 3K1oFZMks41C7qDYBsr72SYjapLqDuSYuN to see more development! +Donate to 33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G to see more development! diff --git a/index.html b/index.html index e99d8ae..4997798 100644 --- a/index.html +++ b/index.html @@ -643,7 +643,7 @@

- +


@@ -1333,7 +1333,7 @@

About open source bitcoin wallet

-

Version 1.5

+

Version 1.6

Compatible with bitcoin core

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

TOR 4zpinp6gdkjfplhk.onion

@@ -1349,7 +1349,7 @@

Support

We recommend that you first check our service status page and then blog page which has multiple guides. However if the problem persists you can contact us by emailing support{at}coinb.in.

Donate

-

Please donate to 3K1oFZMks41C7qDYBsr72SYjapLqDuSYuN if you found this project useful or want to see more features!

+

Please donate to 33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G if you found this project useful or want to see more features!

@@ -1475,7 +1475,7 @@ diff --git a/js/coin.js b/js/coin.js index 8dd718d..a53fb0c 100644 --- a/js/coin.js +++ b/js/coin.js @@ -19,7 +19,7 @@ coinjs.compressed = false; /* other vars */ - coinjs.developer = '3K1oFZMks41C7qDYBsr72SYjapLqDuSYuN'; //bitcoin + coinjs.developer = '33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G'; //bitcoin /* bit(coinb.in) api vars */ coinjs.hostname = ((document.location.hostname.split(".")[(document.location.hostname.split(".")).length-1]) == 'onion') ? '4zpinp6gdkjfplhk.onion' : 'coinb.in'; @@ -1067,6 +1067,11 @@ coinjs.ajax(coinjs.host+'?uid='+coinjs.uid+'&key='+coinjs.key+'&setmodule=addresses&request=unspent&address='+address+'&r='+Math.random(), callback, "GET"); } + /* list transaction data */ + r.getTransaction = function(txid, callback) { + coinjs.ajax(coinjs.host+'?uid='+coinjs.uid+'&key='+coinjs.key+'&setmodule=bitcoin&request=gettransaction&txid='+txid+'&r='+Math.random(), callback, "GET"); + } + /* add unspent to transaction */ r.addUnspent = function(address, callback, script, segwit, sequence){ var self = this; diff --git a/js/coinbin.js b/js/coinbin.js index 91ac600..9b3e97b 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -881,7 +881,7 @@ $(document).ready(function() { $("#redeemFromStatus, #redeemFromAddress").addClass('hidden'); if(redeem.from=='multisigAddress'){ - $("#redeemFromStatus").removeClass('hidden').html(' You should use the redeem script, not the multisig address!'); + $("#redeemFromStatus").removeClass('hidden').html(' You should use the redeem script, not its address!'); return false; } @@ -973,9 +973,15 @@ $(document).ready(function() { r.redeemscript = true; r.decodescript = decodeRs; } else { // something else - r.addr = ''; - r.from = 'other'; - r.redeemscript = false; + if(string.match(/^[a-f0-9]{64}$/i)){ + r.addr = string; + r.from = 'txid'; + r.redeemscript = false; + } else { + r.addr = ''; + r.from = 'other'; + r.redeemscript = false; + } } } return r; @@ -1042,9 +1048,61 @@ $(document).ready(function() { } } + /* global function to add inputs to page */ + function addInput(address, amount) { + if($("#recipients .recipient:last .address:last").val() != ""){ + $("#recipients .addressAddTo:first").click(); + }; + + $("#recipients .address:last").val(address); + $("#recipients .amount:last").val(amount); + } + + /* default function to retreive unspent outputs*/ function listUnspentDefault(redeem){ + var tx = coinjs.transaction(); + + // unspent from transaction; double spend and RBF. + + if(redeem.from == 'txid'){ + tx.getTransaction(redeem.addr, function(data){ + + $("#redeemFromAddress").removeClass('hidden').html(' Attempted to rebuild transaction id '+redeem.addr+''); + + $.each($(data).find("inputs").children(), function(i,o){ + var tx = $(o).find("txid").text(); + var n = $(o).find("output_no").text(); + var amount = (($(o).find("value").text()*1)).toFixed(8); + + var script = coinjs.script(); + var s = script.spendToScript($(o).find("address").text()); + var scr = Crypto.util.bytesToHex(s.buffer); + + addOutput(tx, n, scr, amount); + + }); + + $("#recipients .addressRemoveTo").click(); + $("#recipients .address").val(""); + $("#recipients .amount").val(""); + + $.each($(data).find("outputs").children(), function(i,o){ + addInput($(o).find("address").text(), $(o).find("value").text()); + }); + + $("#redeemFromBtn").html("Load").attr('disabled',false); + totalInputAmount(); + validateOutputAmount(); + + }); + + return; + } + + // unspent from address + tx.listUnspent(redeem.addr, function(data){ if(redeem.addr) { $("#redeemFromAddress").removeClass('hidden').html(' Retrieved unspent inputs from address '+redeem.addr+''); @@ -1078,10 +1136,9 @@ $(document).ready(function() { }, success: function(data) { if (data.address) { // address field will always be present, txrefs is only present if there are UTXOs - $("#redeemFromAddress").removeClass('hidden').html( - ' Retrieved unspent inputs from address '+redeem.addr+''); + $("#redeemFromAddress").removeClass('hidden').html(' Retrieved unspent inputs from address '+redeem.addr+''); for(var i in data.txrefs){ - var o = data.txrefs[i] + var o = data.txrefs[i]; var tx = ((""+o.tx_hash).match(/.{1,2}/g).reverse()).join("")+''; if(tx.match(/^[a-f0-9]+$/)){ var n = o.tx_output_n; diff --git a/sha1sum b/sha1sum index 78cdf63..3512479 100644 --- a/sha1sum +++ b/sha1sum @@ -1,9 +1,9 @@ ----- Version 1.5 2020.07.05 ---- +---- Version 1.6 2020.07.06 ---- 77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js 3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js 253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js -7708a3771dd2749807f2bfc41af407b68888ae5d ./js/coinbin.js -e8a374661d3e0636b9948d34adcd81f6d69684cc ./js/coin.js +7dd75e07389808d57261bca630a5bab55ce9faef ./js/coinbin.js +228cdcf29d33a5eadd360e85a6220e4853ee4590 ./js/coin.js 988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js 9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js @@ -30,6 +30,6 @@ ca35b697d99cae4d1b60f2d60fcd37771987eb07 ./fonts/glyphicons-halflings-regular.w de51a8494180a6db074af2dee2383f0a363c5b08 ./fonts/glyphicons-halflings-regular.svg 278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff 44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf -4665ee4d8ca96db25954f6f3587ac367386eb9e8 ./README.md -e02815b3c834379e883b1e8b8bc6409654582695 ./index.html +ee481606d8d48f402d152fa632ba9e5f9da7f169 ./README.md +5054e03cff2cfcd1ce5296fe2659ca2d46d64fe4 ./index.html 7130b64e3ef4cf6f2f1550e902f081c58dc053de ./test.html