diff --git a/index.html b/index.html
index 691dbd5b..9dd7a914 100644
--- a/index.html
+++ b/index.html
@@ -1191,7 +1191,7 @@
Key Derivation
The path of key derivation
-
+
Path
+
+ Address format
+
+
+
@@ -1226,7 +1235,7 @@
Keys
- Index | Address | Private Key (WIF) | Extended xPub | Extended xPrv |
+ Index | Address | Redeem script | Private Key (WIF) | Extended xPub | Extended xPrv |
diff --git a/js/coin.js b/js/coin.js
index d8f5388f..82159d39 100644
--- a/js/coin.js
+++ b/js/coin.js
@@ -618,10 +618,20 @@
var privkey = (r.key_bytes).slice(1, 33);
var privkeyHex = Crypto.util.bytesToHex(privkey);
var pubkey = coinjs.newPubkey(privkeyHex);
+ var addr_format = $("#verifyHDaddress .derivation_addr_format").val();
+ if (addr_format == "bech32") {
+ var address = coinjs.bech32Address(pubkey);
+ } else if (addr_format == "segwit") {
+ var address = coinjs.segwitAddress(pubkey);
+ } else {
+ var address = {'address': coinjs.pubkey2address(pubkey),
+ 'redeemscript': ''};
+ }
r.keys = {'privkey':privkeyHex,
'pubkey':pubkey,
- 'address':coinjs.pubkey2address(pubkey),
+ 'address':address.address,
+ 'script':address.redeemscript,
'wif':coinjs.privkey2wif(privkeyHex)};
} else if(r.key_bytes[0] == 0x02 || r.key_bytes[0] == 0x03) {
@@ -696,23 +706,34 @@
var ecparams = EllipticCurve.getSECCurveByName("secp256k1");
var curve = ecparams.getCurve();
- var k, key, pubkey, o;
+ var k, key, pubkey, o, addr_format, address_fun, address;
o = coinjs.clone(this);
o.chain_code = ir;
o.child_index = i;
+ addr_format = $("#verifyHDaddress .derivation_addr_format").val();
+ if (addr_format == "bech32") {
+ address_fun = function(pk) { return coinjs.bech32Address(pk); };
+ } else if (addr_format == "segwit") {
+ address_fun = function(pk) { return coinjs.segwitAddress(pk); };
+ } else {
+ address_fun = function(pk) {
+ return {'address': coinjs.pubkey2address(pk), 'redeemscript': ''};
+ };
+ }
if(this.type=='private'){
// derive key pair from from a xprv key
k = il.add(new BigInteger([0].concat(Crypto.util.hexToBytes(this.keys.privkey)))).mod(ecparams.getN());
key = Crypto.util.bytesToHex(k.toByteArrayUnsigned());
pubkey = coinjs.newPubkey(key);
-
+ address = address_fun(pubkey);
o.keys = {'privkey':key,
'pubkey':pubkey,
'wif':coinjs.privkey2wif(key),
- 'address':coinjs.pubkey2address(pubkey)};
+ 'address':address.address,
+ 'script':address.redeemscript};
} else if (this.type=='public'){
// derive xpub key from an xpub key
@@ -729,9 +750,11 @@
publicKeyBytesCompressed.unshift(0x03)
}
pubkey = Crypto.util.bytesToHex(publicKeyBytesCompressed);
+ address = address_fun(pubkey);
o.keys = {'pubkey':pubkey,
- 'address':coinjs.pubkey2address(pubkey)}
+ 'address':address.address,
+ 'script':address.redeemscript}
} else {
// fail
}
diff --git a/js/coinbin.js b/js/coinbin.js
index afc98f17..5b167a7e 100644
--- a/js/coinbin.js
+++ b/js/coinbin.js
@@ -1714,6 +1714,7 @@ $(document).ready(function() {
html += '';
html += ''+i+' | ';
html += ' | ';
+ html += ' | ';
html += ' | ';
html += ' | ';
html += ' | ';