-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 52b5a0f
Showing
16 changed files
with
1,867 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
demo.js: ../ecc/javascript/*.js | ||
cd ../ecc/javascript && browserify --s segwit_addr_ecc segwit_addr_ecc.js | uglifyjs -c -m >../../demo/demo.js |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- Required meta tags --> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<title>Segwit address decoder demo</title> | ||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="style.css"> | ||
<style> | ||
.monospace { font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace; } | ||
</style> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
function toHexString(byteArray) { | ||
return byteArray.map(function(byte) { | ||
return ('0' + (byte & 0xFF).toString(16)).slice(-2); | ||
}).join('') | ||
} | ||
|
||
function update_status() { | ||
var address = document.getElementById("address").value; | ||
var res = segwit_addr_ecc.check(address, ["bc", "tb"]); | ||
var cp = ""; | ||
if (res.error === null) { | ||
document.getElementById("result").innerHTML = "<a style=\"color:green\">Ok, witness version " + res.version + ", program " + toHexString(res.program) + "</a>"; | ||
cp = "<br/>"; | ||
} else { | ||
document.getElementById("result").innerHTML = res.error; | ||
if (res.pos !== null) { | ||
for (var p = 0; p < address.length; ++p) { | ||
if (res.pos.indexOf(p) != -1) { | ||
cp += "<a style=\"color:red\">" + address.charAt(p) + "</a>"; | ||
} else { | ||
cp += address.charAt(p); | ||
} | ||
} | ||
} | ||
} | ||
if(!address.length) document.getElementById("result").innerHTML = ""; | ||
document.getElementById("copy").innerHTML = cp; | ||
} | ||
</script> | ||
<div class="container" style="margin-top:50px"> | ||
<div class="card text-left"> | ||
<h3 class="card-header">SegWit address decoder demo</h3> | ||
<div class="card-block"> | ||
<div class="form-group row"> | ||
<label for="lgFormGroupInput" class="col-sm-2 col-form-label col-form-label-lg">Address</label> | ||
<div class="col-sm-10"> | ||
<input type="text" class="form-control form-control-lg monospace" id="address" placeholder="SegWit address" size="74" oninput="update_status();" /> | ||
</div> | ||
</div> | ||
<p><a id="result"><br/></a></p> | ||
<p><span class="monospace"><a id="copy"><br/></a></span></p> | ||
Fill field with: | ||
<ul> | ||
<li> <a style="text-decoration:underline;" onclick='document.getElementById("address").value = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4";update_status();'>P2WPKH example</a> | ||
<li> <a style="text-decoration:underline;" onclick='document.getElementById("address").value = "BC1QW508D6QEJXTDG4Y5R3ZARVAYR0C5XW7KV8F3T4";update_status();'>P2WPKH example with errors</a> | ||
<li> <a style="text-decoration:underline;" onclick='document.getElementById("address").value = "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3";update_status();'>P2WSH example</a> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<footer class="footer"> | ||
<div class="container text-center"> | ||
<img height="80px" src="SegWit.png" width="288px"> | ||
</div> | ||
</footer> | ||
</body> | ||
</html> | ||
|
||
<script src="demo.js" type="text/javascript"></script> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.footer { | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
padding: 4rem; | ||
text-align: center; | ||
} |
Oops, something went wrong.