aboutsummaryrefslogtreecommitdiffstats
path: root/static/punks-sm/4.webp
blob: 10e88e96b0af70060675b679e140225d85d444d7 (plain)
ofshex dumpascii
0000 52 49 46 46 3a 0b 00 00 57 45 42 50 56 50 38 20 2e 0b 00 00 70 33 00 9d 01 2a 80 00 80 00 3e 71 RIFF:...WEBPVP8.....p3...*....>q
0020 2e 91 46 24 a2 a1 a1 34 f5 be 28 90 0e 09 6c 00 c4 5e 26 d6 fe 46 fe 37 cd 2a b5 fe 13 f1 c7 0b ..F$...4..(...l..^&..F.7.*......
0040 51 ad b1 d7 aa cf d1 be c0 9f ab 5d 3b bc dd 7e d9 fe d2 7b c5 fa 71 ff 13 ea 15 fd 3f fd cf 5b Q..........];..~...{..q.....?..[
0060 7f a1 17 97 67 b3 87 ee af a5 56 0b 13 67 f6 0e 63 97 9c 3a 31 0a 5f 1f e2 1e a0 76 ac 52 8e 43 ....g.....V..g..c..:1._....v.R.C
0080 92 db c3 38 6d d9 d2 ce 80 96 03 ca 6d 02 b7 20 a0 05 ce ad f9 19 bc 26 7c 22 f9 4c 8b d4 56 2e ...8m.......m..........&|".L..V.
00a0 7e 48 b7 04 24 69 0c 7e ab 04 b6 19 92 a7 4c 3c 4f 9d 1b ee e3 43 b3 c1 e3 eb 01 3a 65 2c b4 be ~H..$i.~......L<O....C.....:e,..
00c0 17 6b 38 2b 72 d8 64 44 33 ae cd 9e a5 43 91 34 1e dd fd 07 2f 28 8a ab fa 5a e9 1a 7e b6 94 55 .k8+r.dD3....C.4..../(...Z..~..U
00e0 65 da 47 ac 48 29 fe 3c 9d 05 f1 f3 af 69 73 2e 67 27 b0 70 29 3f 54 b8 01 f7 c2 c2 53 9c 83 89 e.G.H).<.....is.g'.p)?T.....S...
0100 b2 f9 e5 ef c1 94 f7 36 0e 82 35 c5 6c 85 89 14 d3 7d a7 61 22 e3 7d c1 c8 a4 b0 8e d2 51 7c 2f .......6..5.l....}.a".}......Q|/
0120 8f 3d e9 0c 43 a5 7f bd 64 f5 3c fa c1 86 5a c2 8a 59 11 47 e7 39 45 50 2e 51 3b b9 f2 9f f6 7f .=..C...d.<...Z..Y.G.9EP.Q;.....
0140 26 6c 11 88 9a cc 1f dc 48 b8 c6 6b 78 0a 60 68 d0 d8 d1 07 07 4d 5b 84 52 00 62 c0 f1 74 9e 1e &l......H..kx.`h.....M[.R.b..t..
0160 f4 c8 53 1b bb 04 70 63 17 44 11 45 80 8f 2c 6f 07 e2 10 57 d3 37 00 16 3e 77 af 37 fc ed 3a 48 ..S...pc.D.E..,o...W.7..>w.7..:H
0180 03 7e 21 76 8f fc 7e 1b 6d 56 c0 3a dc 94 54 e1 4e 31 9c 91 20 49 6a 43 f8 9f 50 50 00 e8 fc 97 .~!v..~.mV.:..T.N1...IjC..PP....
01a0 f5 81 8a ec 23 ff d4 b3 70 70 5e 43 2a 96 a1 65 d7 78 9b 0e 64 62 f1 00 00 fe f0 f1 ab ff 28 c7 ....#...pp^C*..e.x..db........(.
01c0 fe 5d c7 fc bb 8f 94 63 ff ad 87 ff 36 1f fc d8 7a af 21 29 84 81 db 31 5c 30 2f aa 88 f0 64 fc .].....c....6...z.!)...1\0/...d.
01e0 4f 77 88 9d 04 b3 58 27 be fd 9e b1 59 a2 10 bc 97 60 03 5f 40 c1 ea 04 f6 21 ac c9 b8 fd 2f c5 Ow....X'....Y....`._@....!..../.
0200 09 04 f1 12 af e4 b0 9c ff 5f 1a d4 d4 7c 74 ea 22 e9 5c 55 d7 2f e1 d8 a6 1b f3 ff f3 10 f7 9a ........._...|t.".\U./..........
0220 44 e5 4f 52 4a 54 4f 7e d3 29 76 3f 18 25 8a e1 81 d6 6c d2 91 8b 3e d6 05 86 07 7b 40 e0 00 01 D.ORJTO~.)v?.%....l...>....{@...
0240 4b 4b 8c c2 60 f4 71 6f 94 e4 45 d8 ec ed 61 1b 25 fd f3 98 4a af cd 45 4d 99 38 f3 fe 5c 36 2a KK..`.qo..E...a.%...J..EM.8..\6*
0260 27 53 85 84 fb fc 6f c9 4f 17 9b 40 49 c4 f2 b4 10 d9 60 96 d7 7c ea f2 83 39 fc 85 ea 08 ae 56 'S....o.O..@I.....`..|...9.....V
0280 18 12 74 56 27 5c b7 98 83 59 4a 6f e9 4c 60 75 1c b3 1c 2d 59 69 2b 23 0f 0c 56 51 d3 9a a9 4d ..tV'\...YJo.L`u...-Yi+#..VQ...M
02a
const authenticator = require("otplib").authenticator;
const axios = require("axios");
const bcrypt = require("bcrypt");

register = async (user, ip, requireChallenge) => {
  if (!(user && user.username)) throw new Error("Username required");

  let exists = await db.User.count({ where: { username: user.username } });
  if (exists) throw new Error(`Username ${user.username} taken`);

  if (user.password && user.password === user.confirm) {
    user.password = await bcrypt.hash(user.password, 1);
  }

  if (config.bitcoin) {
    if (config.bitcoin.walletpass)
      await bc.walletPassphrase(config.bitcoin.walletpass, 300);

    user.address = await bc.getNewAddress("", "bech32");
    addresses[user.address] = user.username;
  }

  if (config.liquid) {
    if (config.liquid.walletpass)
      await lq.walletPassphrase(config.liquid.walletpass, 300);

    user.confidential = await lq.getNewAddress();
    user.liquid = (await lq.getAddressInfo(user.confidential)).unconfidential;
    addresses[user.liquid] = user.username;
  }

  if (
    requireChallenge &&
    (!challenge[ip] ||
      user.response.toLowerCase() !== challenge[ip].toLowerCase())
  ) {
    l.info("failed challenge", ip, user.response, challenge[ip]);
    throw new Error("Failed challenge");
  }

  delete challenge[ip];

  let countries = {
    CA: "CAD",
    US: "USD",
    JP: "JPY",
    CN: "CNY",
    AU: "AUD",
    GB: "GBP",
  };

  if (!config.ipstack || ip.startsWith("127") || ip.startsWith("192"))
    user.currency = "CAD";
  else {
    let info = await axios.get(
      `http://api.ipstack.com/${ip}?access_key=${config.ipstack}`
    );
    user.currency = countries[info.data.country_code] || "USD";
  }

  user.currencies = [...new Set([user.currency, "CAD", "USD"])];
  user.fiat = false;
  user.otpsecret = authenticator.generateSecret();

  user = await db.User.create(user);

  let account = await db.Account.create({
    user_id: user.id,
    asset: config.liquid.btcasset,
    balance: 0,
    pending: 0,
    name: "Bitcoin",
    ticker: "BTC",
    precision: 8,
  });

  user.accounts = [account];

  const d = ip.split(".");
  const numericIp = ((+d[0] * 256 + +d[1]) * 256 + +d[2]) * 256 + +d[3];
  if (Number.isInteger(numericIp)) {
    user.ip = numericIp;
    const ipExists = await db.User.findOne({ where: { ip: numericIp } });
  }

  user.account_id = account.id;
  await user.save();
  l.info("new user", user.username, ip);
  return user;
};