Merge pull request #95 from maraoz/feature/browser-example
Feature/browser example
This commit is contained in:
commit
c0e6c87705
|
@ -269,6 +269,8 @@ npm install -g grunt-cli
|
||||||
grunt browserify
|
grunt browserify
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can check a usage example at examples/example.html
|
||||||
|
|
||||||
|
|
||||||
#License
|
#License
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Bitcore browser examples</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id='content'></div>
|
||||||
|
<script src="../browser/bundle.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
console.log = function(s){
|
||||||
|
var div = document.getElementById('content');
|
||||||
|
div.innerHTML += s + '<br />';
|
||||||
|
};
|
||||||
|
|
||||||
|
var Address = bitcore.Address.class();
|
||||||
|
|
||||||
|
var addrStrings = [
|
||||||
|
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
||||||
|
"1A1zP1eP5QGefi2DMPTfTL5SLmv7Dixxxx",
|
||||||
|
"A1zP1eP5QGefi2DMPTfTL5SLmv7Dixxxx",
|
||||||
|
"1600 Pennsylvania Ave NW",
|
||||||
|
].map(function(addr) {
|
||||||
|
return new Address(addr);
|
||||||
|
});
|
||||||
|
|
||||||
|
addrStrings.forEach(function(addr) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
addr.validate();
|
||||||
|
console.log(addr.data + ": is a valid address");
|
||||||
|
} catch(e) {
|
||||||
|
console.log(addr.data + ": is not a valid address.");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -9,7 +9,7 @@ var PrivateKey = bitcore.PrivateKey.class();
|
||||||
var networks = bitcore.networks;
|
var networks = bitcore.networks;
|
||||||
var KeyModule = bitcore.KeyModule;
|
var KeyModule = bitcore.KeyModule;
|
||||||
|
|
||||||
var test_data = require('../browser/testdata');
|
var test_data = require('./testdata');
|
||||||
|
|
||||||
|
|
||||||
function test_encode_priv(b58, payload, isTestnet, isCompressed) {
|
function test_encode_priv(b58, payload, isTestnet, isCompressed) {
|
||||||
|
|
Loading…
Reference in New Issue