L
ling-wallet
↓ 0 downloadsLing Wallet: a post-quantum privacy-coin wallet, full node and HyperTorus miner for LNG
Keywords wallet, cryptocurrency, lng, node, miner, ling
lingfu install ling-walletCode / Files (116)
ling/ui/receive.ling
# receive.ling — RECEIVE: short address, identicon, fingerprint, QR, and the
# full lngkey1 bundle export.
fn receive_draw(ax, ay, aw, ah) {
bind s = d_summary()
if s == () { return () }
bind top_h = ah - 232
bind qr_w = min(top_h, 380)
bind lw = aw - qr_w - 24
bind inn = panel(ax, ay, lw, top_h, "YOUR ADDRESS", C_BLUE)
bind x = list_get(inn, 0)
bind y = list_get(inn, 1)
bind iw = list_get(inn, 2)
identicon(x, y + 8, 128, s.address_hash)
bind tx = x + 152
label(tx, y + 20, "Short address", C_TEXT_DIM)
# As many 4-char groups per line as fit; shrink the face rather than run
# past four lines, and push the fingerprint below whichever ends lower.
bind avail = x + iw - tx
bind fsz = 34
bind lines = addr_lines(s.short_address, avail, fsz)
while len(lines) > 4 && fsz > 22 {
bind fsz = fsz - 4
bind lines = addr_lines(s.short_address, avail, fsz)
}
bind lh = round(fsz * 0.94)
bind i = 0
while i < len(lines) {
t_text(F_MONO, fsz, tx, y + 56 + i * lh, list_get(lines, i), C_TEXT_STRONG)
bind i = i + 1
}
bind fy = max(y + 8 + 128 + 40, y + 56 + (len(lines) - 1) * lh + 32)
label(x, fy, "Fingerprint", C_TEXT_DIM)
draw_fingerprint(x + 112, fy + 2, 30, fingerprint(s.address_hash), C_TEXT_STRONG)
bind by = fy + 32
if copy_btn(x, by, "Copy address", C_BLUE) { clip_copy(s.short_address, "Address") }
t_para(F_UI, 15, x, by + 56, iw, 19, "When someone pays you, their wallet shows this identicon and fingerprint. Read the fingerprint to them so they can confirm it's really you.", C_TEXT_FAINT)
bind qx = ax + lw + 24
bind inq = panel(qx, ay, qr_w, top_h, "SCAN", C_BLUE)
bind qix = list_get(inq, 0)
bind qiy = list_get(inq, 1)
bind qiw = list_get(inq, 2)
bind qih = list_get(inq, 3)
qr_draw(qix + 4, qiy + 4, qiw - 8, qih - 30, s.short_address)
t_center(F_UI, 15, qix, qiy + qih - 14, qiw, 20, "QR of the short address", C_TEXT_FAINT)
bind byy = ay + top_h + 32
bind inb = panel(ax, byy, aw, ah - top_h - 32, "SHORT ADDRESS VS KEY BUNDLE", C_BLUE)
bind bx = list_get(inb, 0)
bind bty = list_get(inb, 1)
bind bw = list_get(inb, 2)
bind bh = list_get(inb, 3)
bind cw = floor((bw - 40) / 2)
bind bundle = st_get("d_bundle", "")
bind k = 0
while k < 2 {
bind cx = bx + k * (cw + 40)
bind title = sel(k == 0, "Short address", "Key bundle")
bind size = sel(k == 0, num_str(str_len(s.short_address)) + " characters", num_str(round(str_len(bundle) / 100) / 10) + " KB")
bind body = sel(k == 0, "What you share. The payer's wallet fetches your key bundle from the network and only accepts it if it matches this address.", "Your full set of public keys. Send it directly when the payer can't reach the network; it is checked the same way.")
bind tw = round(t_text(F_UI, 19, cx, bty + 14, title, C_TEXT_STRONG))
t_text(F_MONO, 20, cx + tw + 12, bty + 15, size, C_TEXT_DIM)
t_para(F_UI, 15, cx, bty + 28, cw, 19, body, C_TEXT_DIM)
bind rowy = bty + bh - 28
if k == 1 {
bind cbw = copy_btn_w("Copy bundle")
if copy_btn(cx, rowy, "Copy bundle", C_BLUE) && bundle != "" { clip_copy(bundle, "Key bundle") }
t_text(F_MONO, 20, cx + cbw + 16, rowy + 24, t_fit(F_MONO, 20, cw - cbw - 16, bundle), C_TEXT_FAINT)
} else {
icon_draw("shield", cx, rowy + 18, C_GREEN)
t_text(F_UI, 15, cx + 24, rowy + 23, "Safe to post publicly; it only lets people pay you.", C_TEXT_FAINT)
}
bind k = k + 1
}
vline(bx + floor(bw / 2), bty, bh, C_LINE_FAINT, 1)
}
# The short address in 4-char groups, as many per line as fit in maxw.
fn addr_lines(addr, maxw, size) {
bind gw = t_w(F_MONO, size, "0000 ")
bind per = max(2, floor((maxw + t_w(F_MONO, size, " ")) / gw))
return grouped(addr, per)
}