Browse Source

prevent requiring bitcoinjs-lib each time

patch-2
Matias Alejo Garcia 11 years ago
parent
commit
be4a228aee
  1. 8
      examples/example.html
  2. 8
      util/util.js

8
examples/example.html

@ -7,6 +7,7 @@
</head>
<body>
<div id='content'></div>
<script src="./jquery.js"></script>
<script src="../browser/bundle.js"></script>
<script type="text/javascript">
@ -38,6 +39,13 @@
});
$.ajax("./config.json", {
async: !1,
complete: function(resp) {
var config = resp.responseJSON;
}
});
</script>
</body>
</html>

8
util/util.js

@ -4,6 +4,12 @@ var bignum = require('bignum');
var Binary = require('binary');
var Put = require('bufferput');
var buffertools = require('buffertools');
var bjs;
if (!process.versions) {
// browser version
bjs = require('../browser/bitcoinjs-lib.js');
}
var sha256 = exports.sha256 = function (data) {
return new Buffer(crypto.createHash('sha256').update(data).digest('binary'), 'binary');
@ -11,8 +17,6 @@ var sha256 = exports.sha256 = function (data) {
var ripe160 = exports.ripe160 = function (data) {
if (!process.versions) {
// browser version
var bjs = require('../browser/bitcoinjs-lib.js');
var RIPEMD160 = bjs.RIPEMD160;
var WordArray = bjs.WordArray;
data = data.toString();

Loading…
Cancel
Save