#= require ../js/jquery-1.8.2.min.js #= require ../js/bootstrap.min.js g = exports ? this g.proceed = false $(-> $('[data-toggle=popover]').popover() $('#title').focus() user = $('#username').val() $.getJSON("/#{user}.json", (data) -> $('#username').val(data.title) $('#email').val(data.logo) $('#profile').fadeIn() ) units = ['BTC', 'mBTC', 'µBTC', 'satoshis'] $.each(units, (i, v) -> $('#unit').append("") ) $('#title').blur(-> if $(this).val() == '' and $('#logo').val() == '' $(this).parent().addClass('has-error') else $(this).parent().removeClass('has-error') ) $('#bip32').blur(-> try new BIP32($(this).val()) $(this).parent().removeClass('has-error') catch $(this).parent().addClass('has-error') ) $('#generate').click(-> rng = new SecureRandom() bytes = new Array(256) rng.nextBytes(bytes) hasher = new jsSHA(bytes.toString(), 'TEXT') rng.nextBytes(bytes) I = hasher.getHMAC(bytes.toString(), "TEXT", "SHA-512", "HEX") il = Crypto.util.hexToBytes(I.slice(0, 64)) ir = Crypto.util.hexToBytes(I.slice(64, 128)) key = new BIP32() key.eckey = new Bitcoin.ECKey(il) key.eckey.pub = key.eckey.getPubPoint() key.eckey.setCompressed(true) key.eckey.pubKeyHash = Bitcoin.Util.sha256ripe160(key.eckey.pub.getEncoded(true)) key.has_private_key = true key.chain_code = ir key.child_index = 0 key.parent_fingerprint = Bitcoin.Util.hexToBytes("00000000") key.version = BITCOIN_MAINNET_PRIVATE key.depth = 0 key.build_extended_public_key() key.build_extended_private_key() g.pubkey = key.extended_public_key_string() g.privkey = key.extended_private_key_string() $('#modal').modal() $('#privkey').html(g.privkey) $('#qr').html('') new QRCode('qr', text: g.privkey, width: 260, height: 260) ) $('#encryption-password').keyup((e) -> return if e.keyCode is 9 or e.keyCode is 16 enc_privkey = CryptoJS.AES.encrypt(g.privkey, $(this).val()).toString() enc_privkey = g.privkey if $(this).val() == '' $('#privkey').html(enc_privkey) $('#qr').html('') new QRCode('qr', text: enc_privkey, width: 260, height: 260) if $(this).val() $('#status').html('(Encrypted)') else $('#status').html('(Unencrypted Plaintext)') ) $('#confirm').blur(-> $('#confirm_error').remove() if $('#password').val() != $('#confirm').val() $('#password, #confirm').parent().addClass('has-error') $('#confirm').parent().after('