Skip to content

Commit

Permalink
segwit signing bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
OutCast3k committed Jun 19, 2018
1 parent 9bede2a commit fd81faf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
25 changes: 17 additions & 8 deletions js/coin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1549,19 +1549,28 @@
if(!witness_used.includes(y)){
var sw = coinjs.segwitAddress(this.witness[y][1]);
var b32 = coinjs.bech32Address(this.witness[y][1]);
if(this.ins[i].script.chunks.length>0){
if((sw['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])) || (b32['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0]))){
witness_order.push(this.witness[y]);
witness_used.push(y);
if(b32['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])){
this.ins[index].script = coinjs.script();
}
break;
var rs = '';

if(this.ins[i].script.chunks.length>=1){
rs = Crypto.util.bytesToHex(this.ins[i].script.chunks[0]);
} else if (this.ins[i].script.chunks.length==0){
rs = b32['redeemscript'];
}

if((sw['redeemscript'] == rs) || (b32['redeemscript'] == rs)){
witness_order.push(this.witness[y]);
witness_used.push(y);

// bech32, empty redeemscript
if(b32['redeemscript'] == rs){
this.ins[index].script = coinjs.script();
}
break;
}
}
}
}

this.witness = witness_order;
}
}
Expand Down
4 changes: 2 additions & 2 deletions sha1sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---- Version 1.4 2018.06.17 ---
---- Version 1.4 2018.06.19 ---
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js
253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js
988f99187ab356bc5d12b61572f463e1785c15c2 ./js/coinbin.js
776a3e2ae1e5835cf0c290987ac5343d8f57ad73 ./js/coin.js
8b4163122d907f9c363b9afd8809490f5ba202c8 ./js/coin.js
988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
Expand Down

0 comments on commit fd81faf

Please sign in to comment.