diff --git a/index.html b/index.html index d0df43e..37cdc13 100644 --- a/index.html +++ b/index.html @@ -1193,18 +1193,26 @@
Version 1.4
+Version 1.5
Compatible with bitcoin core
Github https://github.com/OutCast3k/coinbin/
@@ -1466,7 +1474,7 @@ diff --git a/js/coin.js b/js/coin.js index 9f46bcb..2c03e14 100644 --- a/js/coin.js +++ b/js/coin.js @@ -638,6 +638,8 @@ coinjs.compressed = c; // reset to default } + + return r; } // extend prv/pub key @@ -651,8 +653,37 @@ 'pubkey':this.keys.pubkey}); } + // derive from path + r.derive_path = function(path) { + + if( path == 'm' || path == 'M' || path == 'm\'' || path == 'M\'' ) return this; + + var p = path.split('/'); + var hdp = coinjs.clone(this); // clone hd path + + for( var i in p ) { + + if((( i == 0 ) && c != 'm') || i == 'remove'){ + continue; + } + + var c = p[i]; + + var use_private = (c.length > 1) && (c[c.length-1] == '\''); + var child_index = parseInt(use_private ? c.slice(0, c.length - 1) : c) & 0x7fffffff; + if(use_private) + child_index += 0x80000000; + + hdp = hdp.derive(child_index); + var key = ((hdp.keys_extended.privkey) && hdp.keys_extended.privkey!='') ? hdp.keys_extended.privkey : hdp.keys_extended.pubkey; + hdp = coinjs.hd(key); + } + return hdp; + } + // derive key from index r.derive = function(i){ + i = (i)?i:0; var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse()); @@ -707,7 +738,6 @@ o.parent_fingerprint = (ripemd160(Crypto.SHA256(Crypto.util.hexToBytes(r.keys.pubkey),{asBytes:true}),{asBytes:true})).slice(0,4); o.keys_extended = o.extend(); - return o; } @@ -772,8 +802,7 @@ return o; } - r.parse(); - return r; + return r.parse(); } diff --git a/js/coinbin.js b/js/coinbin.js index 7571ddb..ede2769 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -1660,7 +1660,11 @@ $(document).ready(function() { var html = ''; $("#verifyHDaddress .derived_data table tbody").html(""); for(var i=index_start;i<=index_end;i++){ - var derived = hd.derive(i); + if($("#hdpathtype option:selected").val()=='simple'){ + var derived = hd.derive(i); + } else { + var derived = hd.derive_path(($("#hdpath input").val().replace(/\/+$/, ""))+'/'+i); + } html += '