Skip to content

Commit fd81faf

Browse files
committed
segwit signing bug fix
1 parent 9bede2a commit fd81faf

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

js/coin.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,19 +1549,28 @@
15491549
if(!witness_used.includes(y)){
15501550
var sw = coinjs.segwitAddress(this.witness[y][1]);
15511551
var b32 = coinjs.bech32Address(this.witness[y][1]);
1552-
if(this.ins[i].script.chunks.length>0){
1553-
if((sw['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])) || (b32['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0]))){
1554-
witness_order.push(this.witness[y]);
1555-
witness_used.push(y);
1556-
if(b32['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])){
1557-
this.ins[index].script = coinjs.script();
1558-
}
1559-
break;
1552+
var rs = '';
1553+
1554+
if(this.ins[i].script.chunks.length>=1){
1555+
rs = Crypto.util.bytesToHex(this.ins[i].script.chunks[0]);
1556+
} else if (this.ins[i].script.chunks.length==0){
1557+
rs = b32['redeemscript'];
1558+
}
1559+
1560+
if((sw['redeemscript'] == rs) || (b32['redeemscript'] == rs)){
1561+
witness_order.push(this.witness[y]);
1562+
witness_used.push(y);
1563+
1564+
// bech32, empty redeemscript
1565+
if(b32['redeemscript'] == rs){
1566+
this.ins[index].script = coinjs.script();
15601567
}
1568+
break;
15611569
}
15621570
}
15631571
}
15641572
}
1573+
15651574
this.witness = witness_order;
15661575
}
15671576
}

sha1sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
---- Version 1.4 2018.06.17 ---
1+
---- Version 1.4 2018.06.19 ---
22
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
33
3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js
44
253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js
55
988f99187ab356bc5d12b61572f463e1785c15c2 ./js/coinbin.js
6-
776a3e2ae1e5835cf0c290987ac5343d8f57ad73 ./js/coin.js
6+
8b4163122d907f9c363b9afd8809490f5ba202c8 ./js/coin.js
77
988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js
88
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
99
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js

0 commit comments

Comments
 (0)