mirror of
https://github.com/ok2/coinbin.git
synced 2026-05-09 18:15:23 +02:00
code was missing for the segwit feature from the #wallet section
This commit is contained in:
+12
-2
@@ -876,7 +876,7 @@
|
||||
}
|
||||
|
||||
/* add unspent to transaction */
|
||||
r.addUnspent = function(address, callback, script){
|
||||
r.addUnspent = function(address, callback, script, segwit){
|
||||
var self = this;
|
||||
this.listUnspent(address, function(data){
|
||||
var s = coinjs.script();
|
||||
@@ -902,8 +902,18 @@
|
||||
var n = u.getElementsByTagName("tx_output_n")[0].childNodes[0].nodeValue;
|
||||
var scr = script || u.getElementsByTagName("script")[0].childNodes[0].nodeValue;
|
||||
|
||||
self.addinput(txhash, n, scr);
|
||||
if(segwit){
|
||||
/* this is a small hack to include the value with the redeemscript to make the signing procedure smoother.
|
||||
It is not standard and removed during the signing procedure. */
|
||||
|
||||
s = coinjs.script();
|
||||
s.writeBytes(Crypto.util.hexToBytes(script));
|
||||
s.writeOp(0);
|
||||
s.writeBytes(coinjs.numToBytes(u.getElementsByTagName("value")[0].childNodes[0].nodeValue*1, 8));
|
||||
scr = Crypto.util.bytesToHex(s.buffer);
|
||||
}
|
||||
|
||||
self.addinput(txhash, n, scr);
|
||||
value += u.getElementsByTagName("value")[0].childNodes[0].nodeValue*1;
|
||||
total++;
|
||||
}
|
||||
|
||||
+3
-4
@@ -124,7 +124,7 @@ $(document).ready(function() {
|
||||
var script = false;
|
||||
if($("#walletSegwit").is(":checked")){
|
||||
var sw = coinjs.segwitAddress($("#walletKeys .pubkey").val());
|
||||
scrip = sw.redeemscript;
|
||||
script = sw.redeemscript;
|
||||
}
|
||||
|
||||
tx.addUnspent($("#walletAddress").html(), function(data){
|
||||
@@ -148,7 +148,7 @@ $(document).ready(function() {
|
||||
// and finally broadcast!
|
||||
tx2.broadcast(function(data){
|
||||
if($(data).find("result").text()=="1"){
|
||||
$("#walletSendConfirmStatus").removeClass('hidden').addClass('alert-success').html("txid: "+$(data).find("txid").text());
|
||||
$("#walletSendConfirmStatus").removeClass('hidden').addClass('alert-success').html('txid: <a href="https://coinb.in/tx/'+$(data).find("txid").text()+'" target="_blank">'+$(data).find("txid").text()+'</a>');
|
||||
} else {
|
||||
$("#walletSendConfirmStatus").removeClass('hidden').addClass('alert-danger').html(unescape($(data).find("response").text()).replace(/\+/g,' '));
|
||||
$("#walletSendFailTransaction").removeClass('hidden');
|
||||
@@ -167,7 +167,7 @@ $(document).ready(function() {
|
||||
|
||||
$("#walletLoader").addClass("hidden");
|
||||
|
||||
}, script);
|
||||
}, script, script);
|
||||
});
|
||||
|
||||
$("#walletSendBtn").click(function(){
|
||||
@@ -1262,7 +1262,6 @@ $(document).ready(function() {
|
||||
var tx = coinjs.transaction();
|
||||
try {
|
||||
var decode = tx.deserialize($("#verifyScript").val());
|
||||
// console.log(decode);
|
||||
$("#verifyTransactionData .transactionVersion").html(decode['version']);
|
||||
$("#verifyTransactionData .transactionSize").html(decode.size()+' <i>bytes</i>');
|
||||
$("#verifyTransactionData .transactionLockTime").html(decode['lock_time']);
|
||||
|
||||
Reference in New Issue
Block a user