mirror of
https://github.com/ok2/coinbin.git
synced 2026-05-09 18:15:23 +02:00
Compare commits
18 Commits
1.6
...
full_featured
| Author | SHA1 | Date | |
|---|---|---|---|
| cea94af32f | |||
| 3b1e44e4b4 | |||
| 06054a7000 | |||
| 6a6c2c6beb | |||
| 04609947e8 | |||
| 40a235eb04 | |||
| 20bf365d29 | |||
| 632572fc66 | |||
| 00519cb2ab | |||
| 2b6de3edef | |||
| f408c9b251 | |||
| bd82cfd76f | |||
| 27a2d4efb1 | |||
| 704f2c96a3 | |||
| 29baeff8c8 | |||
| 9a0175e18f | |||
| 507b44f719 | |||
| c868cf984e |
+43
-6
@@ -582,12 +582,27 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<label>Seed (WIF)</label>
|
||||
<div class="input-group">
|
||||
<input id="newHDseed" type="text" class="form-control" value="" readonly>
|
||||
<span class="input-group-btn">
|
||||
<button class="deriveHDbtn btn btn-default" type="button"><span title="Derive from key" class="glyphicon glyphicon-chevron-right"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h3>Address Options</h3>
|
||||
<p>You can use the advanced options below to generate different kinds of master addresses.</p>
|
||||
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="newHDBrainwallet" class="checkbox-inline"> Custom Seed or Brain Wallet</label>
|
||||
<input type="text" class="form-control hidden" id="HDBrainwallet">
|
||||
<div class="hidden" id="HDBrainwalletInput">
|
||||
<input type="text" class="form-control" id="HDBrainwallet">
|
||||
<span class="text-muted">
|
||||
Number of HMAC SHA-256 iterations for seed generation, higher value mean's also longer calculation
|
||||
(use value 0 to calculate just SHA-256, like in previous coinb.in versions):
|
||||
<input type="text" class="form-control" id="HDBrainwalletIters" value="50000" size="10">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="button" class="btn btn-primary" value="Generate" id="newHDKeysBtn">
|
||||
@@ -597,7 +612,7 @@
|
||||
<h2>Transaction <small>Create a new transaction</small></h2>
|
||||
<p>Use this page to create a raw transaction</p>
|
||||
|
||||
<b>Address, WIF key or Redeem Script</b>:
|
||||
<b>Address, WIF key, Redeem Script or Transaction ID</b>:
|
||||
<div class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-info qrcodeScanner" type="button" data-toggle="modal" data-target="#modalQrcodeScanner" forward-result="#redeemFrom"><span class="glyphicon glyphicon-camera"></span></button>
|
||||
@@ -1191,16 +1206,16 @@
|
||||
<p>The path of key derivation</p>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="col-md-6">
|
||||
<b>Path</b><br>
|
||||
<select class="form-control" id="hdpathtype"">
|
||||
<select class="form-control" id="hdpathtype">
|
||||
<option value="simple">Simple: m/i</option>
|
||||
<option value="custom">Custom</option>
|
||||
</select>
|
||||
|
||||
<div id="hdpath" class="hidden" style="margin-top:4px">
|
||||
<span class="input-group">
|
||||
<input type="text" class="form-control" value="m/0/1"> <br>
|
||||
<input type="text" class="form-control" value="m/0/1" title="WARNING: see #settings page when using hardened paths!"> <br>
|
||||
<span class="input-group-addon"> / </span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -1216,6 +1231,15 @@
|
||||
<input type="text" class="form-control derivation_index_end" value="1">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<b>Address format</b><br>
|
||||
<select class="form-control derivation_addr_format">
|
||||
<option value="bech32">Bech32</option>
|
||||
<option value="segwit">SegWit</option>
|
||||
<option value="legacy">Legacy</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
@@ -1226,7 +1250,7 @@
|
||||
<div class="derived_data">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr><td><b>Index</b></td><td><b>Address</b><td><b>Private Key (WIF)</b></td></td><td><b>Extended xPub</b></td><td><b>Extended xPrv</b></td></tr>
|
||||
<tr><td><b>Index</b></td><td><b>Address</b></td><td><b>Redeem script</b></td><td><b>Private Key (WIF)</b></td><td><b>Extended xPub</b></td><td><b>Extended xPrv</b></td></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
@@ -1456,6 +1480,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<b>HD wallet hardened path derivation</b>: <br>
|
||||
<p class="text-muted">The path derivation for hardened paths was calculated wrong in earlier versions of coinb.in. Please select the old path derivation to recover HD wallet keys generated with older version of coinb.in.</p>
|
||||
<select class="form-control" id="coinjs_derivation">
|
||||
<option value="bip32_derivation">BIP32 compliant derivation</option>
|
||||
<option value="coinbin_broken">Old (broken) coinb.in path derivation</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div id="statusSettings" class="hidden alert">
|
||||
|
||||
+80
-27
@@ -18,6 +18,8 @@
|
||||
|
||||
coinjs.compressed = false;
|
||||
|
||||
coinjs.hd_derivation = "bip32_derivation";
|
||||
|
||||
/* other vars */
|
||||
coinjs.developer = '33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G'; //bitcoin
|
||||
|
||||
@@ -608,6 +610,7 @@
|
||||
r.parent_fingerprint = bytes.slice(5, 9);
|
||||
r.child_index = coinjs.uint(bytes.slice(9, 13), 4);
|
||||
r.chain_code = bytes.slice(13, 45);
|
||||
r.seed_wif = '';
|
||||
r.key_bytes = bytes.slice(45, 78);
|
||||
|
||||
var c = coinjs.compressed; // get current default
|
||||
@@ -618,10 +621,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) {
|
||||
@@ -685,7 +698,11 @@
|
||||
r.derive = function(i){
|
||||
|
||||
i = (i)?i:0;
|
||||
var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse());
|
||||
if ((i >= 0x80000000) && (coinjs.hd_derivation == "bip32_derivation")) {
|
||||
var blob = (Crypto.util.hexToBytes("00").concat(Crypto.util.hexToBytes(this.keys.privkey)).concat(coinjs.numToBytes(i,4).reverse()));
|
||||
} else {
|
||||
var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse());
|
||||
}
|
||||
|
||||
var j = new jsSHA(Crypto.util.bytesToHex(blob), 'HEX');
|
||||
var hash = j.getHMAC(Crypto.util.bytesToHex(r.chain_code), "HEX", "SHA-512", "HEX");
|
||||
@@ -696,23 +713,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 +757,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
|
||||
}
|
||||
@@ -742,8 +772,23 @@
|
||||
}
|
||||
|
||||
// make a master hd xprv/xpub
|
||||
r.master = function(pass) {
|
||||
var seed = (pass) ? Crypto.SHA256(pass) : coinjs.newPrivkey();
|
||||
r.master = function(pass, iters) {
|
||||
if (pass) {
|
||||
var seed_iters = (iters) ? Math.abs(iters * 1) : 0;
|
||||
if (seed_iters == 0) {
|
||||
var seed = Crypto.SHA256(pass);
|
||||
} else {
|
||||
var seed = Crypto.util.hexToBytes("0000000000000000000000000000000000000000000000000000000000000000");
|
||||
for (var i = 0; i < seed_iters; i++) {
|
||||
seed = Crypto.HMAC(Crypto.SHA256, seed, pass, { asBytes: true });
|
||||
}
|
||||
seed = Crypto.util.bytesToHex(seed);
|
||||
}
|
||||
} else {
|
||||
var seed = coinjs.newPrivkey();
|
||||
}
|
||||
|
||||
var seed_wif = coinjs.privkey2wif(seed);
|
||||
var hasher = new jsSHA(seed, 'HEX');
|
||||
var I = hasher.getHMAC("Bitcoin seed", "TEXT", "SHA-512", "HEX");
|
||||
|
||||
@@ -755,6 +800,7 @@
|
||||
'parent_fingerprint':[0,0,0,0],
|
||||
'child_index':0,
|
||||
'chain_code':chain,
|
||||
'seed_wif':seed_wif,
|
||||
'privkey':I.slice(0, 64),
|
||||
'pubkey':coinjs.newPubkey(I.slice(0, 64))});
|
||||
}
|
||||
@@ -799,6 +845,8 @@
|
||||
var ret = pub.concat(checksum);
|
||||
o.pubkey = coinjs.base58encode(ret);
|
||||
}
|
||||
|
||||
o.seed_wif = data.seed_wif;
|
||||
return o;
|
||||
}
|
||||
|
||||
@@ -1092,32 +1140,37 @@
|
||||
|
||||
var unspent = xmlDoc.getElementsByTagName("unspent")[0];
|
||||
|
||||
for(i=1;i<=unspent.childElementCount;i++){
|
||||
var u = xmlDoc.getElementsByTagName("unspent_"+i)[0]
|
||||
var txhash = (u.getElementsByTagName("tx_hash")[0].childNodes[0].nodeValue).match(/.{1,2}/g).reverse().join("")+'';
|
||||
var n = u.getElementsByTagName("tx_output_n")[0].childNodes[0].nodeValue;
|
||||
var scr = script || u.getElementsByTagName("script")[0].childNodes[0].nodeValue;
|
||||
if(unspent){
|
||||
for(i=1;i<=unspent.childElementCount;i++){
|
||||
var u = xmlDoc.getElementsByTagName("unspent_"+i)[0]
|
||||
var txhash = (u.getElementsByTagName("tx_hash")[0].childNodes[0].nodeValue).match(/.{1,2}/g).reverse().join("")+'';
|
||||
var n = u.getElementsByTagName("tx_output_n")[0].childNodes[0].nodeValue;
|
||||
var scr = script || u.getElementsByTagName("script")[0].childNodes[0].nodeValue;
|
||||
|
||||
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. */
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
var seq = sequence || false;
|
||||
self.addinput(txhash, n, scr, seq);
|
||||
value += u.getElementsByTagName("value")[0].childNodes[0].nodeValue*1;
|
||||
total++;
|
||||
}
|
||||
|
||||
var seq = sequence || false;
|
||||
self.addinput(txhash, n, scr, seq);
|
||||
value += u.getElementsByTagName("value")[0].childNodes[0].nodeValue*1;
|
||||
total++;
|
||||
}
|
||||
|
||||
x.unspent = $(xmlDoc).find("unspent");
|
||||
x.result = xmlDoc.getElementsByTagName("result")[0].childNodes[0].nodeValue;
|
||||
x.unspent = unspent;
|
||||
x.value = value;
|
||||
x.total = total;
|
||||
x.response = xmlDoc.getElementsByTagName("response")[0].childNodes[0].nodeValue;
|
||||
|
||||
return callback(x);
|
||||
});
|
||||
}
|
||||
|
||||
+23
-9
@@ -570,18 +570,20 @@ $(document).ready(function() {
|
||||
$("#newHDKeysBtn").click(function(){
|
||||
coinjs.compressed = true;
|
||||
var s = ($("#newHDBrainwallet").is(":checked")) ? $("#HDBrainwallet").val() : null;
|
||||
var siters = ($("#newHDBrainwallet").is(":checked")) ? $("#HDBrainwalletIters").val()*1 : null;
|
||||
var hd = coinjs.hd();
|
||||
var pair = hd.master(s);
|
||||
var pair = hd.master(s, siters);
|
||||
$("#newHDxpub").val(pair.pubkey);
|
||||
$("#newHDxprv").val(pair.privkey);
|
||||
$("#newHDseed").val(pair.seed_wif);
|
||||
|
||||
});
|
||||
|
||||
$("#newHDBrainwallet").click(function(){
|
||||
if($(this).is(":checked")){
|
||||
$("#HDBrainwallet").removeClass("hidden");
|
||||
$("#HDBrainwalletInput").removeClass("hidden");
|
||||
} else {
|
||||
$("#HDBrainwallet").addClass("hidden");
|
||||
$("#HDBrainwalletInput").addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1076,9 +1078,7 @@ $(document).ready(function() {
|
||||
var n = $(o).find("output_no").text();
|
||||
var amount = (($(o).find("value").text()*1)).toFixed(8);
|
||||
|
||||
var script = coinjs.script();
|
||||
var s = script.spendToScript($(o).find("address").text());
|
||||
var scr = Crypto.util.bytesToHex(s.buffer);
|
||||
var scr = $(o).find("script").text();
|
||||
|
||||
addOutput(tx, n, scr, amount);
|
||||
|
||||
@@ -1683,6 +1683,7 @@ $(document).ready(function() {
|
||||
if(hex == hex_cmp_prv || hex == hex_cmp_pub){
|
||||
var hd = coinjs.hd(s);
|
||||
$("#verifyHDaddress .hdKey").html(s);
|
||||
$("#verifyHDaddress .seed_wif").val(hd.seed_wif);
|
||||
$("#verifyHDaddress .chain_code").val(Crypto.util.bytesToHex(hd.chain_code));
|
||||
$("#verifyHDaddress .depth").val(hd.depth);
|
||||
$("#verifyHDaddress .version").val('0x'+(hd.version).toString(16));
|
||||
@@ -1703,19 +1704,29 @@ $(document).ready(function() {
|
||||
|
||||
function deriveHDaddress() {
|
||||
var hd = coinjs.hd($("#verifyHDaddress .hdKey").html());
|
||||
var index_start = $("#verifyHDaddress .derivation_index_start").val()*1;
|
||||
var index_end = $("#verifyHDaddress .derivation_index_end").val()*1;
|
||||
var index_start = $("#verifyHDaddress .derivation_index_start").val();
|
||||
if ((index_start.length > 1) && (index_start[index_start.length - 1] == '\'')) {
|
||||
var use_private_index = '\'';
|
||||
index_start = index_start.replace(/[']/, "") * 1;
|
||||
} else {
|
||||
var use_private_index = '';
|
||||
index_start = index_start.replace(/[']/, "") * 1;
|
||||
}
|
||||
var index_end = $("#verifyHDaddress .derivation_index_end").val().replace(/[']/, "") * 1;
|
||||
$("#verifyHDaddress .derivation_index_end").val(index_end + use_private_index);
|
||||
var html = '';
|
||||
$("#verifyHDaddress .derived_data table tbody").html("");
|
||||
for(var i=index_start;i<=index_end;i++){
|
||||
if($("#hdpathtype option:selected").val()=='simple'){
|
||||
var derived = hd.derive(i);
|
||||
} else {
|
||||
var derived = hd.derive_path(($("#hdpath input").val().replace(/\/+$/, ""))+'/'+i);
|
||||
var derived = hd.derive_path(($("#hdpath input").val().replace(/\/+$/, ""))+'/'+i+use_private_index);
|
||||
$("#hdpath").removeClass(); // make it visible
|
||||
}
|
||||
html += '<tr>';
|
||||
html += '<td>'+i+'</td>';
|
||||
html += '<td><input type="text" class="form-control" value="'+derived.keys.address+'" readonly></td>';
|
||||
html += '<td><input type="text" class="form-control" value="'+derived.keys.script+'" readonly></td>';
|
||||
html += '<td><input type="text" class="form-control" value="'+((derived.keys.wif)?derived.keys.wif:'')+'" readonly></td>';
|
||||
html += '<td><input type="text" class="form-control" value="'+derived.keys_extended.pubkey+'" readonly></td>';
|
||||
html += '<td><input type="text" class="form-control" value="'+((derived.keys_extended.privkey)?derived.keys_extended.privkey:'')+'" readonly></td>';
|
||||
@@ -1916,6 +1927,8 @@ $(document).ready(function() {
|
||||
coinjs.hdkey.pub = $("#coinjs_hdpub").val()*1;
|
||||
coinjs.hdkey.prv = $("#coinjs_hdprv").val()*1;
|
||||
|
||||
coinjs.hd_derivation = $("#coinjs_derivation").val();
|
||||
|
||||
configureBroadcast();
|
||||
configureGetUnspentTx();
|
||||
|
||||
@@ -1961,6 +1974,7 @@ $(document).ready(function() {
|
||||
$("#coinjs_multisig").val(o[2]);
|
||||
$("#coinjs_hdpub").val(o[3]);
|
||||
$("#coinjs_hdprv").val(o[4]);
|
||||
$("#coinjs_derivation").val(o[7]);
|
||||
|
||||
// hide/show custom screen
|
||||
if($("option:selected",this).val()=="custom"){
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---- Version 1.6 2020.07.06 ----
|
||||
---- Version 1.6 2020.10.02 ----
|
||||
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
|
||||
3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js
|
||||
253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js
|
||||
7dd75e07389808d57261bca630a5bab55ce9faef ./js/coinbin.js
|
||||
228cdcf29d33a5eadd360e85a6220e4853ee4590 ./js/coin.js
|
||||
cb5717166bf1c99abbd75a06013067c4a5897d5a ./js/coinbin.js
|
||||
911fb7bdba24269029f27659e4040cd991b2307c ./js/coin.js
|
||||
988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js
|
||||
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
|
||||
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
|
||||
@@ -31,5 +31,5 @@ de51a8494180a6db074af2dee2383f0a363c5b08 ./fonts/glyphicons-halflings-regular.s
|
||||
278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff
|
||||
44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf
|
||||
ee481606d8d48f402d152fa632ba9e5f9da7f169 ./README.md
|
||||
5054e03cff2cfcd1ce5296fe2659ca2d46d64fe4 ./index.html
|
||||
a706e95f6436ee4a31dc26b17a9ac8ab1f0d3750 ./index.html
|
||||
7130b64e3ef4cf6f2f1550e902f081c58dc053de ./test.html
|
||||
|
||||
Reference in New Issue
Block a user