sPhone-Store/apps/3d6/kristwallet.spk
2016-11-17 21:00:49 +01:00

1761 lines
70 KiB
Text

--
-- sPhone Application Package
-- Built with SPK builder 1.2
--
{
files = "{\
[ \"krist.lua\" ] = \"--[[-----------------------------------------------\\r\\\
| KristWallet by 3d6 |\\r\\\
---------------------------------------------------\\r\\\
| This is the reference wallet for Krist. |\\r\\\
| It is the basic definition of a functional |\\r\\\
| Krist program, although it is not as old as the |\\r\\\
| network (we used to just use raw API calls). |\\r\\\
---------------------------------------------------\\r\\\
/\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\ /\\\\\\r\\\
/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/ \\\\/\\r\\\
---------------------------------------------------\\r\\\
| Do whatever you want with this, but if you make |\\r\\\
| it interact with a currency or network other |\\r\\\
| than Krist, please give me credit. Thanks <3 |\\r\\\
---------------------------------------------------\\r\\\
| This wallet will NEVER save passwords anywhere. |]]local\\r\\\
-----------------------------------------------]]--\\r\\\
version = 14\\r\\\
local latest = 0\\r\\\
local balance = 0\\r\\\
local balance2 = 0\\r\\\
local balance3 = 0\\r\\\
local MOD = 2^32\\r\\\
local MODM = MOD-1\\r\\\
local gui = 0\\r\\\
local page = 0\\r\\\
local lastpage = 0\\r\\\
local scroll = 0\\r\\\
local masterkey = \\\"\\\"\\r\\\
local doublekey = \\\"\\\"\\r\\\
local address = \\\"\\\"\\r\\\
local addressv1 = \\\"\\\"\\r\\\
local addressdv = \\\"\\\"\\r\\\
local addresslv = \\\"\\\"\\r\\\
local subject = \\\"\\\"\\r\\\
local name = \\\"\\\"\\r\\\
local subbal = 0\\r\\\
local subtxs = \\\"\\\"\\r\\\
local stdate = {}\\r\\\
local stpeer = {}\\r\\\
local stval = {}\\r\\\
local blkpeer = {}\\r\\\
local pagespace = \\\"\\\"\\r\\\
local maxspace = \\\"\\\"\\r\\\
local ar = 0\\r\\\
local amt = 0\\r\\\
local availability = 0\\r\\\
local wallet, hud, update, settle, log, readconfig, checkdir, openwallet, makev2address\\r\\\
\\r\\\
local function split(inputstr, sep)\\r\\\
if sep == nil then\\r\\\
sep = \\\"%s\\\"\\r\\\
end\\r\\\
local t={} ; i=1\\r\\\
for str in string.gmatch(inputstr, \\\"([^\\\"..sep..\\\"]+)\\\") do\\r\\\
t[i] = str\\r\\\
i = i + 1\\r\\\
end\\r\\\
return t\\r\\\
end\\r\\\
\\r\\\
local function readURL(url)\\r\\\
local resp = http.get(url)\\r\\\
if not resp then\\r\\\
log(\\\"Could not reach \\\"..url)\\r\\\
error(\\\"Error connecting to server\\\")\\r\\\
panic()\\r\\\
end\\r\\\
local content = resp.readAll():gsub(\\\"\\\\n+$\\\", \\\"\\\")\\r\\\
resp.close()\\r\\\
return content\\r\\\
end\\r\\\
\\r\\\
local function boot()\\r\\\
for i=1,2 do checkdir() end\\r\\\
print(\\\"Starting KristWallet v\\\"..tostring(version))\\r\\\
log(\\\"Started KristWallet v\\\"..tostring(version))\\r\\\
update()\\r\\\
if readconfig(\\\"enabled\\\") and latest <= version then\\r\\\
settle()\\r\\\
openwallet()\\r\\\
while page ~= 0 do\\r\\\
wallet()\\r\\\
end\\r\\\
term.setBackgroundColor(32768)\\r\\\
term.setTextColor(16)\\r\\\
term.clear()\\r\\\
term.setCursorPos(1,1)\\r\\\
log(\\\"KristWallet closed safely\\\")\\r\\\
else\\r\\\
if not readconfig(\\\"enabled\\\") then print(\\\"KristWallet is disabled on this computer.\\\") log(\\\"Disabled, shutting down\\\") end\\r\\\
end\\r\\\
if readconfig(\\\"rebootonexit\\\") then\\r\\\
log(\\\"Rebooted computer\\\")\\r\\\
os.reboot()\\r\\\
end\\r\\\
end\\r\\\
function update()\\r\\\
latest = tonumber(readURL(readconfig(\\\"versionserver\\\")))\\r\\\
if latest > version then\\r\\\
print(\\\"An update is available!\\\")\\r\\\
log(\\\"Discovered update\\\")\\r\\\
if readconfig(\\\"autoupdate\\\") and not bench then\\r\\\
local me = fs.open(fs.getName(shell.getRunningProgram()),\\\"w\\\")\\r\\\
local nextversion = readURL(readconfig(\\\"updateserver\\\"))\\r\\\
print(\\\"Installed update. Run this program again to start v\\\"..latest..\\\".\\\")\\r\\\
me.write(nextversion)\\r\\\
me.close()\\r\\\
log(\\\"Installed update\\\")\\r\\\
else\\r\\\
log(\\\"Ignored update\\\")\\r\\\
latest = -2\\r\\\
end\\r\\\
else\\r\\\
log(\\\"No updates found\\\")\\r\\\
end\\r\\\
end\\r\\\
function log(text)\\r\\\
local logfile = spk.open(\\\"log_wallet\\\",\\\"a\\\")\\r\\\
logfile.writeLine(tostring(os.day())..\\\"-\\\"..tostring(os.time())..\\\"/\\\"..text)\\r\\\
logfile.close()\\r\\\
end\\r\\\
local function checkfile(path,default)\\r\\\
if not fs.exists(spk.getDataPath()..\\\"/\\\"..path) or path == \\\"syncnode\\\" then\\r\\\
local file = spk.open(path,\\\"w\\\")\\r\\\
file.writeLine(default)\\r\\\
file.close()\\r\\\
log(\\\"Created file \\\"..path)\\r\\\
return false\\r\\\
else\\r\\\
return true\\r\\\
end\\r\\\
end\\r\\\
function readconfig(path)\\r\\\
if fs.exists(spk.getDataPath()..\\\"/\\\"..path) then\\r\\\
local file = spk.open(path,\\\"r\\\")\\r\\\
local context = file.readAll():gsub(\\\"\\\\n+$\\\", \\\"\\\")\\r\\\
file.close()\\r\\\
if context == \\\"true\\\" then return true end\\r\\\
if context == \\\"false\\\" then return false end\\r\\\
return context\\r\\\
else\\r\\\
print(\\\"An unknown error happened\\\")\\r\\\
end\\r\\\
end\\r\\\
function settle()\\r\\\
if term.isColor() then gui = 1 end\\r\\\
if term.isColor() and pocket then gui = 2 end\\r\\\
end\\r\\\
local function drawKrist()\\r\\\
local posx, posy = term.getCursorPos()\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setTextColor(32)\\r\\\
term.write(\\\"/\\\")\\r\\\
term.setBackgroundColor(32)\\r\\\
term.setTextColor(8192)\\r\\\
term.write(\\\"\\\\\\\\\\\")\\r\\\
term.setCursorPos(posx,posy+1)\\r\\\
term.setBackgroundColor(32)\\r\\\
term.setTextColor(8192)\\r\\\
term.write(\\\"\\\\\\\\\\\")\\r\\\
term.setBackgroundColor(8192)\\r\\\
term.setTextColor(32)\\r\\\
term.write(\\\"/\\\")\\r\\\
term.setCursorPos(posx+2,posy)\\r\\\
end\\r\\\
local function memoize(f)\\r\\\
local mt = {}\\r\\\
local t = setmetatable({}, mt)\\r\\\
function mt:__index(k)\\r\\\
local v = f(k)\\r\\\
t[k] = v\\r\\\
return v\\r\\\
end\\r\\\
return t\\r\\\
end\\r\\\
local function make_bitop_uncached(t, m)\\r\\\
local function bitop(a, b)\\r\\\
local res,p = 0,1\\r\\\
while a ~= 0 and b ~= 0 do\\r\\\
local am, bm = a % m, b % m\\r\\\
res = res + t[am][bm] * p\\r\\\
a = (a - am) / m\\r\\\
b = (b - bm) / m\\r\\\
p = p*m\\r\\\
end\\r\\\
res = res + (a + b) * p\\r\\\
return res\\r\\\
end\\r\\\
return bitop\\r\\\
end\\r\\\
local function make_bitop(t)\\r\\\
local op1 = make_bitop_uncached(t,2^1)\\r\\\
local op2 = memoize(function(a) return memoize(function(b) return op1(a, b) end) end)\\r\\\
return make_bitop_uncached(op2, 2 ^ (t.n or 1))\\r\\\
end\\r\\\
local bxor1 = make_bitop({[0] = {[0] = 0,[1] = 1}, [1] = {[0] = 1, [1] = 0}, n = 4})\\r\\\
local function bxor(a, b, c, ...)\\r\\\
local z = nil\\r\\\
if b then\\r\\\
a = a % MOD\\r\\\
b = b % MOD\\r\\\
z = bxor1(a, b)\\r\\\
if c then z = bxor(z, c, ...) end\\r\\\
return z\\r\\\
elseif a then return a % MOD\\r\\\
else return 0 end\\r\\\
end\\r\\\
local function band(a, b, c, ...)\\r\\\
local z\\r\\\
if b then\\r\\\
a = a % MOD\\r\\\
b = b % MOD\\r\\\
z = ((a + b) - bxor1(a,b)) / 2\\r\\\
if c then z = bit32_band(z, c, ...) end\\r\\\
return z\\r\\\
elseif a then return a % MOD\\r\\\
else return MODM end\\r\\\
end\\r\\\
local function bnot(x) return (-1 - x) % MOD end\\r\\\
local function rshift1(a, disp)\\r\\\
if disp < 0 then return lshift(a,-disp) end\\r\\\
return math.floor(a % 2 ^ 32 / 2 ^ disp)\\r\\\
end\\r\\\
local function rshift(x, disp)\\r\\\
if disp > 31 or disp < -31 then return 0 end\\r\\\
return rshift1(x % MOD, disp)\\r\\\
end\\r\\\
local function lshift(a, disp)\\r\\\
if disp < 0 then return rshift(a,-disp) end\\r\\\
return (a * 2 ^ disp) % 2 ^ 32\\r\\\
end\\r\\\
local function rrotate(x, disp)\\r\\\
x = x % MOD\\r\\\
disp = disp % 32\\r\\\
local low = band(x, 2 ^ disp - 1)\\r\\\
return rshift(x, disp) + lshift(low, 32 - disp)\\r\\\
end\\r\\\
local k = {\\r\\\
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,\\r\\\
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\\r\\\
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\\r\\\
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\\r\\\
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,\\r\\\
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\\r\\\
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\\r\\\
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\\r\\\
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\\r\\\
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\\r\\\
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\\r\\\
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\\r\\\
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\\r\\\
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\\r\\\
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\\r\\\
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\\r\\\
}\\r\\\
local function str2hexa(s)\\r\\\
return (string.gsub(s, \\\".\\\", function(c) return string.format(\\\"%02x\\\", string.byte(c)) end))\\r\\\
end\\r\\\
local function num2s(l, n)\\r\\\
local s = \\\"\\\"\\r\\\
for i = 1, n do\\r\\\
local rem = l % 256\\r\\\
s = string.char(rem) .. s\\r\\\
l = (l - rem) / 256\\r\\\
end\\r\\\
return s\\r\\\
end\\r\\\
local function s232num(s, i)\\r\\\
local n = 0\\r\\\
for i = i, i + 3 do n = n*256 + string.byte(s, i) end\\r\\\
return n\\r\\\
end\\r\\\
local function preproc(msg, len)\\r\\\
local extra = 64 - ((len + 9) % 64)\\r\\\
len = num2s(8 * len, 8)\\r\\\
msg = msg .. \\\"\\\\128\\\" .. string.rep(\\\"\\\\0\\\", extra) .. len\\r\\\
assert(#msg % 64 == 0)\\r\\\
return msg\\r\\\
end\\r\\\
local function initH256(H)\\r\\\
H[1] = 0x6a09e667\\r\\\
H[2] = 0xbb67ae85\\r\\\
H[3] = 0x3c6ef372\\r\\\
H[4] = 0xa54ff53a\\r\\\
H[5] = 0x510e527f\\r\\\
H[6] = 0x9b05688c\\r\\\
H[7] = 0x1f83d9ab\\r\\\
H[8] = 0x5be0cd19\\r\\\
return H\\r\\\
end\\r\\\
local function digestblock(msg, i, H)\\r\\\
local w = {}\\r\\\
for j = 1, 16 do w[j] = s232num(msg, i + (j - 1)*4) end\\r\\\
for j = 17, 64 do\\r\\\
local v = w[j - 15]\\r\\\
local s0 = bxor(rrotate(v, 7), rrotate(v, 18), rshift(v, 3))\\r\\\
v = w[j - 2]\\r\\\
w[j] = w[j - 16] + s0 + w[j - 7] + bxor(rrotate(v, 17), rrotate(v, 19), rshift(v, 10))\\r\\\
end\\r\\\
\\r\\\
local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6], H[7], H[8]\\r\\\
for i = 1, 64 do\\r\\\
local s0 = bxor(rrotate(a, 2), rrotate(a, 13), rrotate(a, 22))\\r\\\
local maj = bxor(band(a, b), band(a, c), band(b, c))\\r\\\
local t2 = s0 + maj\\r\\\
local s1 = bxor(rrotate(e, 6), rrotate(e, 11), rrotate(e, 25))\\r\\\
local ch = bxor (band(e, f), band(bnot(e), g))\\r\\\
local t1 = h + s1 + ch + k[i] + w[i]\\r\\\
h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2\\r\\\
end\\r\\\
\\r\\\
H[1] = band(H[1] + a)\\r\\\
H[2] = band(H[2] + b)\\r\\\
H[3] = band(H[3] + c)\\r\\\
H[4] = band(H[4] + d)\\r\\\
H[5] = band(H[5] + e)\\r\\\
H[6] = band(H[6] + f)\\r\\\
H[7] = band(H[7] + g)\\r\\\
H[8] = band(H[8] + h)\\r\\\
end\\r\\\
local function sha256(msg)\\r\\\
msg = preproc(msg, #msg)\\r\\\
local H = initH256({})\\r\\\
for i = 1, #msg, 64 do digestblock(msg, i, H) end\\r\\\
return str2hexa(num2s(H[1], 4) .. num2s(H[2], 4) .. num2s(H[3], 4) .. num2s(H[4], 4) ..\\r\\\
num2s(H[5], 4) .. num2s(H[6], 4) .. num2s(H[7], 4) .. num2s(H[8], 4))\\r\\\
end\\r\\\
local function panic()\\r\\\
page = 0\\r\\\
log(\\\"Panicking! Shutting down KristWallet.\\\")\\r\\\
end\\r\\\
local function makeaddressbyte(j)\\r\\\
if j <= 6 then return \\\"0\\\"\\r\\\
elseif j <= 13 then return \\\"1\\\"\\r\\\
elseif j <= 20 then return \\\"2\\\"\\r\\\
elseif j <= 27 then return \\\"3\\\"\\r\\\
elseif j <= 34 then return \\\"4\\\"\\r\\\
elseif j <= 41 then return \\\"5\\\"\\r\\\
elseif j <= 48 then return \\\"6\\\"\\r\\\
elseif j <= 55 then return \\\"7\\\"\\r\\\
elseif j <= 62 then return \\\"8\\\"\\r\\\
elseif j <= 69 then return \\\"9\\\"\\r\\\
elseif j <= 76 then return \\\"a\\\"\\r\\\
elseif j <= 83 then return \\\"b\\\"\\r\\\
elseif j <= 90 then return \\\"c\\\"\\r\\\
elseif j <= 97 then return \\\"d\\\"\\r\\\
elseif j <= 104 then return \\\"e\\\"\\r\\\
elseif j <= 111 then return \\\"f\\\"\\r\\\
elseif j <= 118 then return \\\"g\\\"\\r\\\
elseif j <= 125 then return \\\"h\\\"\\r\\\
elseif j <= 132 then return \\\"i\\\"\\r\\\
elseif j <= 139 then return \\\"j\\\"\\r\\\
elseif j <= 146 then return \\\"k\\\"\\r\\\
elseif j <= 153 then return \\\"l\\\"\\r\\\
elseif j <= 160 then return \\\"m\\\"\\r\\\
elseif j <= 167 then return \\\"n\\\"\\r\\\
elseif j <= 174 then return \\\"o\\\"\\r\\\
elseif j <= 181 then return \\\"p\\\"\\r\\\
elseif j <= 188 then return \\\"q\\\"\\r\\\
elseif j <= 195 then return \\\"r\\\"\\r\\\
elseif j <= 202 then return \\\"s\\\"\\r\\\
elseif j <= 209 then return \\\"t\\\"\\r\\\
elseif j <= 216 then return \\\"u\\\"\\r\\\
elseif j <= 223 then return \\\"v\\\"\\r\\\
elseif j <= 230 then return \\\"w\\\"\\r\\\
elseif j <= 237 then return \\\"x\\\"\\r\\\
elseif j <= 244 then return \\\"y\\\"\\r\\\
elseif j <= 251 then return \\\"z\\\"\\r\\\
else return \\\"e\\\"\\r\\\
end\\r\\\
end\\r\\\
function checkdir()\\r\\\
if fs.isDir(spk.getDataPath()) then\\r\\\
math.randomseed(os.time()) \\r\\\
checkfile(\\\"log_wallet\\\",\\\"-----KRISTWALLET LOG FILE-----\\\")\\r\\\
checkfile(\\\"enabled\\\",\\\"true\\\") --Disabling this just makes KristWallet refuse to start.\\r\\\
checkfile(\\\"sweepv1\\\",\\\"true\\\")\\r\\\
checkfile(\\\"appendhashes\\\",\\\"true\\\") --Disabling this makes it possible to use KristWallet with extremely old addresses.\\r\\\
checkfile(\\\"autoupdate\\\",\\\"true\\\")\\r\\\
checkfile(\\\"whitelisted\\\",\\\"false\\\")\\r\\\
checkfile(\\\"rebootonexit\\\",\\\"false\\\")\\r\\\
checkfile(\\\"autologin\\\",\\\"false\\\")\\r\\\
checkfile(\\\"keyAL\\\",sha256(\\\"\\\"))\\r\\\
checkfile(\\\"keyLV\\\",sha256(math.random(1000000)..os.time())) --This is where the local vault's krist is stored. DO NOT DESTROY!\\r\\\
checkfile(\\\"versionserver\\\",\\\"https://raw.githubusercontent.com/BTCTaras/kristwallet/master/staticapi/version\\\")\\r\\\
checkfile(\\\"updateserver\\\",\\\"https://raw.githubusercontent.com/BTCTaras/kristwallet/master/kristwallet\\\")\\r\\\
checkfile(\\\"syncnode\\\",\\\"http://krist.ceriat.net/\\\")\\r\\\
checkfile(\\\"whitelist\\\",\\\"\\\")\\r\\\
checkfile(\\\"blacklist\\\",\\\"\\\")\\r\\\
end\\r\\\
end\\r\\\
function openwallet()\\r\\\
term.setBackgroundColor(8)\\r\\\
term.clear()\\r\\\
local krists = 0\\r\\\
repeat\\r\\\
term.setCursorPos(3+(3*krists),3)\\r\\\
drawKrist()\\r\\\
krists = krists + 1\\r\\\
until krists == 16\\r\\\
krists = 0\\r\\\
repeat\\r\\\
term.setCursorPos(3+(3*krists),16)\\r\\\
drawKrist()\\r\\\
krists = krists + 1\\r\\\
until krists == 16\\r\\\
term.setBackgroundColor(8)\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(6,6)\\r\\\
term.write(\\\"Password:\\\")\\r\\\
term.setCursorPos(6,8)\\r\\\
-----|---+---------+---------+---------+-----|---+-\\r\\\
term.write(\\\"Please enter your secret password to\\\")\\r\\\
term.setCursorPos(6,9)\\r\\\
term.write(\\\"use Krist. If this is your first time\\\")\\r\\\
term.setCursorPos(6,10)\\r\\\
term.write(\\\"using Krist, type your desired password.\\\")\\r\\\
term.setCursorPos(6,11)\\r\\\
term.write(\\\"You will be able to access your Krist\\\")\\r\\\
term.setCursorPos(6,12)\\r\\\
term.write(\\\"on any computer on any server as long\\\")\\r\\\
term.setCursorPos(6,13)\\r\\\
term.write(\\\"as you type in the same password! It will\\\")\\r\\\
term.setCursorPos(6,14)\\r\\\
term.write(\\\"not be saved or shared with anyone.\\\")\\r\\\
term.setCursorPos(16,6)\\r\\\
local password = \\\"\\\"\\r\\\
if readconfig(\\\"autologin\\\") then\\r\\\
password = readconfig(\\\"keyAL\\\")\\r\\\
else\\r\\\
password = read(\\\"*\\\")\\r\\\
if password == \\\"\\\" then term.setCursorPos(16,6) password = read(\\\"*\\\") end\\r\\\
if readconfig(\\\"appendhashes\\\") then password = sha256(\\\"KRISTWALLET\\\"..password) end\\r\\\
end\\r\\\
term.clear()\\r\\\
term.setCursorPos(1,1)\\r\\\
page = 1+gui*(10*(gui-1))\\r\\\
if readconfig(\\\"appendhashes\\\") then masterkey = password..\\\"-000\\\" else masterkey = password end\\r\\\
log(\\\"Read password\\\")\\r\\\
addressv1 = string.sub(sha256(masterkey),0,10)\\r\\\
log(\\\"Derived address: \\\"..addressv1)\\r\\\
address = makev2address(masterkey)\\r\\\
log(\\\"Derived address: \\\"..address)\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..addressv1))\\r\\\
if balance > 0 and readconfig(\\\"sweepv1\\\") then local transaction = readURL(readconfig(\\\"syncnode\\\")..\\\"?pushtx&q=\\\"..address..\\\"&pkey=\\\"..masterkey..\\\"&amt=\\\"..balance); log(\\\"Swept hex address\\\") end\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
if balance >= 100000 then log(\\\"Woah! There's a small fortune here!\\\") elseif balance > 0 then log(\\\"There is some krist here!\\\") end\\r\\\
if readconfig(\\\"whitelisted\\\") then\\r\\\
local whitelist = readconfig(\\\"whitelist\\\")\\r\\\
if string.find(whitelist, address) == nil then\\r\\\
log(address..\\\" is not on the whitelist!\\\")\\r\\\
print(\\\"Sorry, this wallet is not on the whitelist for this computer!\\\")\\r\\\
page = 0\\r\\\
os.sleep(3)\\r\\\
end\\r\\\
else\\r\\\
local blacklist = readconfig(\\\"blacklist\\\")\\r\\\
if string.find(blacklist, addressv1) ~= nil then\\r\\\
log(addressv1..\\\" is on the blacklist!\\\")\\r\\\
print(\\\"Your wallet is blocked from this computer!\\\")\\r\\\
page = 0\\r\\\
os.sleep(3)\\r\\\
elseif string.find(blacklist, address) ~= nil then\\r\\\
log(address..\\\" is on the blacklist!\\\")\\r\\\
print(\\\"Your wallet is blocked from this computer!\\\")\\r\\\
page = 0\\r\\\
os.sleep(3)\\r\\\
end\\r\\\
end\\r\\\
addresslv = makev2address(readconfig(\\\"keyLV\\\"))\\r\\\
log(\\\"Loaded local vault\\\")\\r\\\
end\\r\\\
function makev2address(key)\\r\\\
local protein = {}\\r\\\
local stick = sha256(sha256(key))\\r\\\
local n = 0\\r\\\
local link = 0\\r\\\
local v2 = \\\"k\\\"\\r\\\
repeat\\r\\\
if n < 9 then protein[n] = string.sub(stick,0,2)\\r\\\
stick = sha256(sha256(stick)) end\\r\\\
n = n + 1\\r\\\
until n == 9\\r\\\
n = 0\\r\\\
repeat\\r\\\
link = tonumber(string.sub(stick,1+(2*n),2+(2*n)),16) % 9\\r\\\
if string.len(protein[link]) ~= 0 then\\r\\\
v2 = v2 .. makeaddressbyte(tonumber(protein[link],16))\\r\\\
protein[link] = ''\\r\\\
n = n + 1\\r\\\
else\\r\\\
stick = sha256(stick)\\r\\\
end\\r\\\
until n == 9\\r\\\
return v2\\r\\\
end\\r\\\
local function postgraphic(px,py,id)\\r\\\
term.setCursorPos(px,py)\\r\\\
if id == 0 then drawKrist()\\r\\\
elseif id == 1 then\\r\\\
--Mined Krist\\r\\\
term.setCursorPos(px+1,py)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setTextColor(128)\\r\\\
term.write(\\\"/T\\\\\\\\\\\")\\r\\\
term.setCursorPos(px,py+1)\\r\\\
term.write(\\\"/\\\")\\r\\\
term.setCursorPos(px+2,py+1)\\r\\\
term.write(\\\"|\\\")\\r\\\
term.setCursorPos(px+4,py+1)\\r\\\
term.write(\\\"\\\\\\\\\\\")\\r\\\
term.setCursorPos(px+2,py+2)\\r\\\
term.write(\\\"|\\\")\\r\\\
term.setCursorPos(px+2,py+3)\\r\\\
term.write(\\\"|\\\")\\r\\\
term.setCursorPos(px+4,py+2)\\r\\\
drawKrist()\\r\\\
elseif id == 2 then\\r\\\
--Sent Krist\\r\\\
term.setCursorPos(px,py+2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setTextColor(16384)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(px+5,py+2)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(px+2,py)\\r\\\
term.write(\\\"/\\\\\\\\\\\")\\r\\\
term.setCursorPos(px+2,py+1)\\r\\\
term.write(\\\"||\\\")\\r\\\
elseif id == 3 then\\r\\\
--Received Krist\\r\\\
term.setCursorPos(px,py+2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setTextColor(8192)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(px+5,py+2)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(px+2,py)\\r\\\
term.write(\\\"||\\\")\\r\\\
term.setCursorPos(px+2,py+1)\\r\\\
term.write(\\\"\\\\\\\\/\\\")\\r\\\
elseif id == 4 then\\r\\\
--Sent to yourself\\r\\\
term.setCursorPos(px,py+2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setTextColor(16)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(px+5,py+2)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(px+1,py)\\r\\\
term.write(\\\"/\\\\\\\\||\\\")\\r\\\
term.setCursorPos(px+1,py+1)\\r\\\
term.write(\\\"||\\\\\\\\/\\\")\\r\\\
elseif id == 5 then\\r\\\
--Swept from v1 address\\r\\\
term.setCursorPos(px+1,py)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setTextColor(128)\\r\\\
term.write(\\\" v1 \\\")\\r\\\
term.setCursorPos(px+2,py+1)\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setTextColor(2048)\\r\\\
term.write(\\\"||\\\")\\r\\\
term.setCursorPos(px+2,py+2)\\r\\\
term.write(\\\"\\\\\\\\/\\\")\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.setBackgroundColor(16)\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" v2 \\\")\\r\\\
elseif id == 6 then\\r\\\
--Name registered\\r\\\
term.setBackgroundColor(32)\\r\\\
term.setTextColor(8192)\\r\\\
term.setCursorPos(px+4,py)\\r\\\
term.write(\\\"/\\\")\\r\\\
term.setCursorPos(px+1,py+1)\\r\\\
term.write(\\\"\\\\\\\\\\\")\\r\\\
term.setCursorPos(px+3,py+1)\\r\\\
term.write(\\\"/\\\")\\r\\\
term.setCursorPos(px+2,py+2)\\r\\\
term.write(\\\"V\\\")\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.setBackgroundColor(16384)\\r\\\
term.setTextColor(4)\\r\\\
term.write(\\\".kst\\\")\\r\\\
elseif id == 7 then\\r\\\
--Name operation\\r\\\
term.setBackgroundColor(8)\\r\\\
term.setTextColor(512)\\r\\\
term.setCursorPos(px+1,py)\\r\\\
term.write(\\\" a \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.write(\\\"\\\\\\\\\\\")\\r\\\
term.setBackgroundColor(8)\\r\\\
term.setCursorPos(px+1,py+1)\\r\\\
term.write(\\\"====\\\")\\r\\\
term.setCursorPos(px+1,py+2)\\r\\\
term.write(\\\"====\\\")\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.setBackgroundColor(16384)\\r\\\
term.setTextColor(4)\\r\\\
term.write(\\\".kst\\\")\\r\\\
elseif id == 8 then\\r\\\
--Name sent\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.setBackgroundColor(16384)\\r\\\
term.setTextColor(4)\\r\\\
term.write(\\\".kst\\\")\\r\\\
term.setTextColor(16384)\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(px+2,py)\\r\\\
term.write(\\\"/\\\\\\\\\\\")\\r\\\
term.setCursorPos(px+2,py+1)\\r\\\
term.write(\\\"||\\\")\\r\\\
elseif id == 9 then\\r\\\
--Name received\\r\\\
term.setCursorPos(px+1,py+3)\\r\\\
term.setBackgroundColor(16384)\\r\\\
term.setTextColor(4)\\r\\\
term.write(\\\".kst\\\")\\r\\\
term.setTextColor(8192)\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(px+1,py)\\r\\\
term.write(\\\"||\\\")\\r\\\
term.setCursorPos(px+1,py+1)\\r\\\
term.write(\\\"\\\\\\\\/\\\")\\r\\\
term.setTextColor(16384)\\r\\\
term.setCursorPos(px+3,py)\\r\\\
term.write(\\\"/\\\\\\\\\\\")\\r\\\
term.setCursorPos(px+3,py+1)\\r\\\
term.write(\\\"||\\\")\\r\\\
end\\r\\\
end\\r\\\
function wallet()\\r\\\
hud()\\r\\\
local pagebefore = page\\r\\\
local event, button, xPos, yPos = os.pullEvent(\\\"mouse_click\\\")\\r\\\
if gui == 1 and xPos >= 3 and xPos <= 14 then\\r\\\
if yPos == 5 then\\r\\\
page = 1\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
end\\r\\\
if yPos == 7 then\\r\\\
page = 2\\r\\\
subject = address\\r\\\
scroll = 0\\r\\\
end\\r\\\
if yPos == 9 then\\r\\\
page = 3\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
end\\r\\\
if yPos == 11 then\\r\\\
page = 8\\r\\\
end\\r\\\
if yPos == 13 then\\r\\\
page = 4\\r\\\
end\\r\\\
if yPos == 15 then\\r\\\
page = 15\\r\\\
end\\r\\\
if yPos == 17 then\\r\\\
page = 0\\r\\\
end\\r\\\
elseif gui == 2 then\\r\\\
if yPos == 2 and xPos >= 19 and xPos <= 24 then\\r\\\
page = 0\\r\\\
end\\r\\\
end\\r\\\
local lexm = http.get(readconfig(\\\"syncnode\\\")..\\\"?listnames=\\\"..address)\\r\\\
local lem = false\\r\\\
local lexmm\\r\\\
if lexm.readAll then\\r\\\
lem = true\\r\\\
lexmm = lexm.readAll():gsub(\\\"\\\\n+$\\\", \\\"\\\")\\r\\\
end\\r\\\
\\r\\\
if page == 1 then\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
if (yPos-7)%5 == 0 and yPos >= 7 and xPos >= 26 and xPos <= 35 then\\r\\\
subject = string.sub(readURL(readconfig(\\\"syncnode\\\")..\\\"?listtx=\\\"..address..\\\"&overview\\\"),13+(31*((yPos-7)/5)),22+(31*((yPos-7)/5)))\\r\\\
if string.len(subject) == 10 and subject ~= \\\"N/A(Mined)\\\" and subject ~= \\\"N/A(Names)\\\" then\\r\\\
page = 2\\r\\\
end\\r\\\
end\\r\\\
elseif page == 2 then\\r\\\
if yPos > 2 and yPos <= 2+ar-(16*(scroll)) and xPos >= 31 and xPos < 41 then\\r\\\
if stpeer[(yPos-2)+(16*(scroll))] == \\\"N/A(Mined)\\\" then\\r\\\
--possibly link to a block later?\\r\\\
elseif stpeer[(yPos-2)+(16*(scroll))] == \\\"N/A(Names)\\\" then\\r\\\
--possibly link to a name later??\\r\\\
else\\r\\\
subject = stpeer[(yPos-2)+(16*(scroll))]\\r\\\
scroll = 0\\r\\\
end\\r\\\
end\\r\\\
if yPos == 19 and xPos >= 32 and xPos <= 36 then\\r\\\
scroll = 0\\r\\\
end\\r\\\
if yPos == 19 and xPos >= 38 and xPos <= 41 then\\r\\\
scroll = math.max(0,scroll-1)\\r\\\
end\\r\\\
if yPos == 19 and xPos >= 43 and xPos <= 46 then\\r\\\
scroll = math.min(lastpage,scroll+1)\\r\\\
end\\r\\\
if yPos == 19 and xPos >= 48 then\\r\\\
scroll = lastpage\\r\\\
end\\r\\\
if yPos == 1 and xPos >= 17 then\\r\\\
page = 6\\r\\\
end\\r\\\
log(\\\"Page index is \\\"..scroll)\\r\\\
elseif page == 3 then\\r\\\
if xPos >= 17 then\\r\\\
term.setCursorPos(33,5)\\r\\\
local recipient = read()\\r\\\
term.setCursorPos(33,6)\\r\\\
log(\\\"Read recipient for transfer\\\")\\r\\\
local amount = read()\\r\\\
log(\\\"Read amount for transfer\\\")\\r\\\
local transaction = readURL(readconfig(\\\"syncnode\\\")..\\\"?pushtx2&q=\\\"..recipient..\\\"&pkey=\\\"..masterkey..\\\"&amt=\\\"..amount)\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
log(\\\"Attempting to send \\\"..amount..\\\" KST to \\\"..recipient)\\r\\\
term.setCursorPos(19,8)\\r\\\
if transaction == \\\"Success\\\" then\\r\\\
term.setTextColor(8192)\\r\\\
term.write(\\\"Transfer successful\\\")\\r\\\
log(\\\"Transfer successful\\\")\\r\\\
term.setTextColor(32768)\\r\\\
elseif string.sub(transaction,0,5) == \\\"Error\\\" then\\r\\\
local problem = \\\"An unknown error happened\\\"\\r\\\
local code = tonumber(string.sub(transaction,6,10))\\r\\\
if code == 1 then problem = \\\"Insufficient funds available\\\" end\\r\\\
if code == 2 then problem = \\\"Not enough KST in transaction\\\" end\\r\\\
if code == 3 then problem = \\\"Can't comprehend amount to send\\\" end\\r\\\
if code == 4 then problem = \\\"Invalid recipient address\\\" end\\r\\\
term.setTextColor(16384)\\r\\\
term.write(problem)\\r\\\
log(problem)\\r\\\
term.setTextColor(32768)\\r\\\
else\\r\\\
term.setTextColor(16384)\\r\\\
term.write(transaction)\\r\\\
term.setTextColor(32768)\\r\\\
end\\r\\\
os.sleep(2.5) --lower this if you do tons of transfers\\r\\\
log(\\\"Unfroze display\\\")\\r\\\
end\\r\\\
elseif page == 4 then\\r\\\
if yPos == 3 and xPos >= 19 and xPos <= 31 then\\r\\\
page = 5\\r\\\
scroll = 0\\r\\\
end\\r\\\
if yPos == 4 and xPos >= 19 and xPos <= 31 then\\r\\\
page = 10\\r\\\
end\\r\\\
if yPos == 3 and xPos >= 35 and xPos <= 48 then\\r\\\
page = 6\\r\\\
end\\r\\\
if yPos == 4 and xPos >= 35 and xPos <= 46 then\\r\\\
page = 7\\r\\\
end\\r\\\
elseif page == 5 then\\r\\\
if yPos > 2 and xPos >= 27 and xPos <= 36 then\\r\\\
page = 2\\r\\\
subject = blkpeer[(yPos-2)]\\r\\\
scroll = 0\\r\\\
end\\r\\\
elseif page == 6 then\\r\\\
term.setCursorPos(18,1)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(18,1)\\r\\\
term.write(\\\"ADDRESS \\\")\\r\\\
subject = read()\\r\\\
if string.len(subject) == 10 then\\r\\\
page = 2\\r\\\
scroll = 0\\r\\\
else\\r\\\
page = 6\\r\\\
end\\r\\\
elseif page == 7 then\\r\\\
if yPos > 2 and yPos <= 18 and xPos >= 20 and xPos < 30 then\\r\\\
if blkpeer[(yPos-2)] ~= \\\"N/A(Burnt)\\\" then\\r\\\
page = 2\\r\\\
subject = blkpeer[(yPos-2)]\\r\\\
scroll = 0\\r\\\
end\\r\\\
end\\r\\\
elseif page == 15 then\\r\\\
\\r\\\
local function isEdit(xpo)\\r\\\
return xpo >= 39 and xpo <= 42\\r\\\
end\\r\\\
local function isSend(xpo)\\r\\\
return xpo >= 44 and xpo <= 47\\r\\\
end\\r\\\
\\r\\\
if xPos and yPos then\\r\\\
local listofnames = split(lexmm, \\\";\\\")\\r\\\
if yPos == 1 and xPos >= 46 then\\r\\\
page = 16\\r\\\
elseif lem and yPos >= 3 and isEdit(xPos) then\\r\\\
if listofnames[yPos - 3] then\\r\\\
page = 17\\r\\\
local nameclicked = yPos - 3\\r\\\
subject = listofnames[nameclicked]\\r\\\
end\\r\\\
elseif lem and yPos >= 3 and isSend(xPos) then\\r\\\
if listofnames[yPos - 3] then\\r\\\
page = 18\\r\\\
local nameclicked = yPos - 3\\r\\\
subject = listofnames[nameclicked]\\r\\\
end\\r\\\
end\\r\\\
end\\r\\\
elseif page == 8 then\\r\\\
if yPos == 3 and xPos >= 19 and xPos <= 30 then\\r\\\
page = 9\\r\\\
end\\r\\\
if yPos == 3 and xPos >= 35 and xPos <= 47 then\\r\\\
page = 16\\r\\\
end\\r\\\
if yPos == 4 and xPos >= 35 and xPos <= 47 then\\r\\\
--page = 18\\r\\\
end\\r\\\
if yPos == 4 and xPos >= 19 and xPos <= 29 then\\r\\\
page = 13\\r\\\
end\\r\\\
elseif page == 18 then\\r\\\
if yPos == 5 and xPos >= 30 then\\r\\\
term.setCursorPos(30,5)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(30,5)\\r\\\
maxspace = read():lower()\\r\\\
term.setCursorPos(19,7)\\r\\\
pagespace = readURL(readconfig(\\\"syncnode\\\")..\\\"?name_transfer&pkey=\\\"..masterkey..\\\"&name=\\\"..subject..\\\"&q=\\\"..maxspace)\\r\\\
if pagespace == \\\"Success\\\" then\\r\\\
end\\r\\\
term.write(\\\"Name transferred\\\")\\r\\\
log(\\\"Tried sending a name to \\\"..maxspace)\\r\\\
os.sleep(3)\\r\\\
page = 15\\r\\\
end\\r\\\
elseif page == 16 then\\r\\\
if yPos == 4 and xPos >= 25 then\\r\\\
term.setCursorPos(25,4)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(25,4)\\r\\\
name = read():lower():gsub(\\\".kst\\\",\\\"\\\"):gsub(\\\" \\\",\\\"\\\")\\r\\\
term.setCursorPos(25,4)\\r\\\
term.write(\\\"Please wait... \\\")\\r\\\
if string.len(name) > 0 then\\r\\\
if name == \\\"a\\\" or name == \\\"name\\\" or name == \\\"id\\\" or name == \\\"owner\\\" or name == \\\"registered\\\" or name == \\\"updated\\\" or name == \\\"expires\\\" or name == \\\"unpaid\\\" then\\r\\\
availability = 0\\r\\\
else\\r\\\
availability = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?name_check=\\\"..name))\\r\\\
log(\\\"Checked \\\"..name..\\\".kst for availability (\\\"..availability..\\\")\\\")\\r\\\
term.setCursorPos(19,7)\\r\\\
if availability then\\r\\\
term.setTextColor(colors.green)\\r\\\
term.write(\\\"Available!\\\")\\r\\\
else\\r\\\
term.setTextColor(colors.red)\\r\\\
term.write(\\\"Not available!\\\")\\r\\\
end\\r\\\
end\\r\\\
else\\r\\\
name = \\\"\\\"\\r\\\
end\\r\\\
elseif yPos == 7 and xPos >= 30 and xPos <= 39 and availability == 1 and balance >= 500 then\\r\\\
availability = 2\\r\\\
local k = readURL(readconfig(\\\"syncnode\\\")..\\\"?name_new&pkey=\\\"..masterkey..\\\"&name=\\\"..name)\\r\\\
end\\r\\\
elseif page == 17 then\\r\\\
if yPos == 5 and xPos >= 25 then\\r\\\
term.setCursorPos(25,5)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(25,5)\\r\\\
zone = read():gsub(\\\"http://\\\",\\\"\\\")\\r\\\
term.setCursorPos(25,5)\\r\\\
term.write(\\\"Please wait... \\\")\\r\\\
local sevenminutesleftuntilmaystartsfuckihavetoreleasethisnow = readURL(readconfig(\\\"syncnode\\\")..\\\"?name_update&pkey=\\\"..masterkey..\\\"&name=\\\"..subject..\\\"&ar=\\\"..zone)\\r\\\
elseif yPos == 7 and xPos >= 30 and xPos <= 39 and availability == 1 and balance >= 500 then\\r\\\
availability = 2\\r\\\
local k = readURL(readconfig(\\\"syncnode\\\")..\\\"?name_new&pkey=\\\"..masterkey..\\\"&name=\\\"..name)\\r\\\
end\\r\\\
elseif page == 9 then\\r\\\
if yPos == 4 and xPos >= 30 then\\r\\\
term.setCursorPos(30,4)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(30,4)\\r\\\
doublekey = read(\\\"*\\\")\\r\\\
term.setCursorPos(30,4)\\r\\\
term.write(\\\"Please wait... \\\")\\r\\\
if string.len(doublekey) > 0 then\\r\\\
doublekey = sha256(masterkey..\\\"-\\\"..sha256(doublekey))\\r\\\
addressdv = makev2address(doublekey)\\r\\\
balance2 = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..addressdv))\\r\\\
log(\\\"Derived double vault \\\"..addressdv)\\r\\\
else\\r\\\
addressdv = \\\"\\\"\\r\\\
balance2 = 0\\r\\\
end\\r\\\
end\\r\\\
if yPos == 5 and xPos >= 33 then\\r\\\
term.setCursorPos(33,5)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(33,5)\\r\\\
amt = read()\\r\\\
if tonumber(amt) == nil then\\r\\\
amt = 0\\r\\\
elseif tonumber(amt) % 1 ~= 0 then\\r\\\
amt = 0\\r\\\
elseif tonumber(amt) <= 0 then\\r\\\
amt = 0\\r\\\
end\\r\\\
end\\r\\\
if yPos == 6 and xPos >= 25 and xPos <= 33 then\\r\\\
if tonumber(amt) > 0 and string.len(doublekey) > 0 then\\r\\\
if tonumber(amt) <= balance then\\r\\\
local transaction = readURL(readconfig(\\\"syncnode\\\")..\\\"?pushtx2&q=\\\"..addressdv..\\\"&pkey=\\\"..masterkey..\\\"&amt=\\\"..tonumber(amt))\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
balance2 = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..addressdv))\\r\\\
log(\\\"Put \\\"..amt..\\\" KST in a double vault\\\")\\r\\\
end\\r\\\
end\\r\\\
end\\r\\\
if yPos == 6 and xPos >= 35 and xPos <= 44 then\\r\\\
if tonumber(amt) > 0 and string.len(doublekey) > 0 then\\r\\\
if tonumber(amt) <= balance2 then\\r\\\
local transaction = readURL(readconfig(\\\"syncnode\\\")..\\\"?pushtx2&q=\\\"..address..\\\"&pkey=\\\"..doublekey..\\\"&amt=\\\"..tonumber(amt))\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
balance2 = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..addressdv))\\r\\\
log(\\\"Took \\\"..amt..\\\" KST from a double vault\\\")\\r\\\
end\\r\\\
end\\r\\\
end\\r\\\
elseif page == 13 then\\r\\\
if yPos == 5 and xPos >= 33 then\\r\\\
term.setCursorPos(33,5)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(33,5)\\r\\\
term.setTextColor(32768)\\r\\\
amt = read()\\r\\\
if tonumber(amt) == nil then\\r\\\
amt = 0\\r\\\
elseif tonumber(amt) % 1 ~= 0 then\\r\\\
amt = 0\\r\\\
elseif tonumber(amt) <= 0 then\\r\\\
amt = 0\\r\\\
end\\r\\\
end\\r\\\
if yPos == 6 and xPos >= 25 and xPos <= 33 then\\r\\\
if tonumber(amt) > 0 then\\r\\\
if tonumber(amt) <= balance then\\r\\\
local transaction = readURL(readconfig(\\\"syncnode\\\")..\\\"?pushtx2&q=\\\"..addresslv..\\\"&pkey=\\\"..masterkey..\\\"&amt=\\\"..tonumber(amt))\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
log(\\\"Put \\\"..amt..\\\" KST in a local vault\\\")\\r\\\
end\\r\\\
end\\r\\\
end\\r\\\
if yPos == 6 and xPos >= 35 and xPos <= 44 then\\r\\\
if tonumber(amt) > 0 then\\r\\\
if tonumber(amt) <= balance3 then\\r\\\
local transaction = readURL(readconfig(\\\"syncnode\\\")..\\\"?pushtx2&q=\\\"..address..\\\"&pkey=\\\"..readconfig(\\\"keyLV\\\")..\\\"&amt=\\\"..tonumber(amt))\\r\\\
balance = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..address))\\r\\\
log(\\\"Took \\\"..amt..\\\" KST from a local vault\\\")\\r\\\
end\\r\\\
end\\r\\\
end\\r\\\
end\\r\\\
if pagebefore ~= page then log(\\\"Switched to page \\\"..page) end\\r\\\
end\\r\\\
local function drawTab(text)\\r\\\
term.setBackgroundColor(512)\\r\\\
term.write(text)\\r\\\
end\\r\\\
local function drawBtn(text)\\r\\\
term.setBackgroundColor(32)\\r\\\
term.write(text)\\r\\\
end\\r\\\
function hud()\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setTextColor(32768)\\r\\\
term.clear()\\r\\\
if gui == 1 then\\r\\\
local sidebar = 1\\r\\\
while sidebar < 51 do\\r\\\
term.setCursorPos(1,sidebar)\\r\\\
term.setBackgroundColor(8)\\r\\\
term.write(\\\" \\\")\\r\\\
sidebar = sidebar + 1\\r\\\
end\\r\\\
term.setCursorPos(2,2)\\r\\\
drawKrist()\\r\\\
term.setBackgroundColor(8)\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" KristWallet\\\")\\r\\\
term.setCursorPos(5,3)\\r\\\
term.setTextColor(2048)\\r\\\
term.write(\\\"release \\\"..version..\\\"\\\")\\r\\\
term.setCursorPos(2,19)\\r\\\
term.write(\\\" by 3d6\\\")\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(3,5)\\r\\\
drawTab(\\\" Overview \\\")\\r\\\
term.setCursorPos(3,7)\\r\\\
drawTab(\\\"Transactions\\\")\\r\\\
term.setCursorPos(3,9)\\r\\\
drawTab(\\\" Send Krist \\\")\\r\\\
term.setCursorPos(3,11)\\r\\\
drawTab(\\\" Special TX \\\")\\r\\\
term.setCursorPos(3,13)\\r\\\
drawTab(\\\" Economicon \\\")\\r\\\
term.setCursorPos(3,15)\\r\\\
drawTab(\\\"Name Manager\\\")\\r\\\
term.setCursorPos(3,17)\\r\\\
drawTab(\\\" Exit \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
elseif gui == 2 then\\r\\\
term.setCursorPos(1,1)\\r\\\
term.setBackgroundColor(8)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(1,2)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(1,3)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(1,4)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(2,2)\\r\\\
drawKrist()\\r\\\
term.setBackgroundColor(8)\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" KristWallet\\\")\\r\\\
term.setCursorPos(5,3)\\r\\\
term.setTextColor(2048)\\r\\\
term.write(\\\"release \\\"..version..\\\"\\\")\\r\\\
term.setCursorPos(19,2)\\r\\\
term.setBackgroundColor(16384)\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" Exit \\\")\\r\\\
end\\r\\\
if page == 1 then\\r\\\
term.setCursorPos(19,2)\\r\\\
term.write(\\\"Your address: \\\")\\r\\\
term.setTextColor(16384)\\r\\\
term.write(address)\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(19,5)\\r\\\
local recenttransactions = \\\"\\\"\\r\\\
if tostring(balance) ~= 'nil' then recenttransactions = readURL(readconfig(\\\"syncnode\\\")..\\\"?listtx=\\\"..address..\\\"&overview\\\") end\\r\\\
local txtype = 0\\r\\\
local graphics = 0\\r\\\
if string.len(recenttransactions) > 25 then\\r\\\
repeat\\r\\\
if string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == \\\"N/A(Mined)\\\" then txtype = 1\\r\\\
elseif string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == \\\"N/A(Names)\\\" and tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) == 0 then txtype = 7\\r\\\
elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) == 0 then txtype = 9\\r\\\
elseif string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == \\\"N/A(Names)\\\" then txtype = 6\\r\\\
elseif string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == address then txtype = 4\\r\\\
elseif string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == addressv1 then txtype = 5\\r\\\
elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) < 0 then txtype = 2\\r\\\
elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) > 0 then txtype = 3\\r\\\
else txtype = 8\\r\\\
end\\r\\\
postgraphic(19,5+(5*graphics),txtype)\\r\\\
term.setCursorPos(26,5+(5*graphics))\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setTextColor(32768)\\r\\\
if txtype == 1 then term.write(\\\"Mined\\\")\\r\\\
elseif txtype == 2 then term.write(\\\"Sent\\\")\\r\\\
elseif txtype == 3 then term.write(\\\"Received\\\")\\r\\\
elseif txtype == 4 then term.write(\\\"Sent to yourself\\\")\\r\\\
elseif txtype == 5 then term.write(\\\"Imported\\\")\\r\\\
elseif txtype == 6 then term.write(\\\"Name registered\\\")\\r\\\
elseif txtype == 7 then term.write(\\\"Name operation\\\")\\r\\\
elseif txtype == 8 then term.write(\\\"Unknown\\\")\\r\\\
elseif txtype == 9 then term.write(\\\"Name transfer\\\")\\r\\\
end\\r\\\
term.setCursorPos(26,6+(5*graphics))\\r\\\
if txtype == 4 then\\r\\\
term.setTextColor(32768)\\r\\\
elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) > 0 then\\r\\\
term.setTextColor(8192)\\r\\\
term.write(\\\"+\\\")\\r\\\
elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) == 0 then\\r\\\
term.setTextColor(16)\\r\\\
else\\r\\\
term.setTextColor(16384)\\r\\\
end\\r\\\
if txtype < 7 then term.write(tostring(tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))))..\\\" KST\\\") end\\r\\\
term.setCursorPos(26,7+(5*graphics))\\r\\\
term.setTextColor(32768)\\r\\\
if txtype ~= 6 then term.setTextColor(512) end\\r\\\
if txtype == 9 or (txtype > 1 and txtype < 6) then term.write(string.sub(recenttransactions,13+(31*graphics),22+(31*graphics))) end\\r\\\
--if txtype == 6 then term.write(\\\".kst\\\") end\\r\\\
term.setCursorPos(26,8+(5*graphics))\\r\\\
term.setTextColor(128)\\r\\\
term.write(string.sub(recenttransactions,1+(31*graphics),12+(31*graphics)))\\r\\\
graphics = graphics + 1\\r\\\
until graphics >= math.floor(string.len(recenttransactions)/32)\\r\\\
end\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(19,3)\\r\\\
term.write(\\\"Your balance: \\\")\\r\\\
term.setTextColor(1024)\\r\\\
if tostring(balance) == 'nil' then balance = 0 end\\r\\\
term.write(tostring(balance)..\\\" KST \\\")\\r\\\
term.setTextColor(512)\\r\\\
local names = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getnames=\\\"..address))\\r\\\
if names > 0 then term.write(\\\"[\\\"..tostring(names)..\\\"]\\\") end\\r\\\
if address == \\\"ke3kjplzsz\\\" or address == \\\"767fc628a4\\\" or address == \\\"e3b0c44298\\\" then\\r\\\
term.setCursorPos(1,1)\\r\\\
term.setBackgroundColor(16384)\\r\\\
term.setTextColor(16)\\r\\\
term.clearLine()\\r\\\
term.write(\\\"You are currently using a blank string password.\\\")\\r\\\
end\\r\\\
elseif page == 2 then\\r\\\
term.setCursorPos(18,1)\\r\\\
term.write(\\\"Please wait...\\\")\\r\\\
os.sleep(0)\\r\\\
subbal = readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..subject)\\r\\\
subtxs = readURL(readconfig(\\\"syncnode\\\")..\\\"?listtx=\\\"..subject)\\r\\\
log(\\\"Loaded transactions for address \\\"..subject)\\r\\\
log(\\\"Page index is \\\"..scroll)\\r\\\
term.setCursorPos(18,1)\\r\\\
if subtxs == \\\"end\\\" then subbal = 0 end\\r\\\
term.write(\\\"ADDRESS \\\"..subject..\\\" - \\\"..subbal..\\\" KST\\\")\\r\\\
term.setCursorPos(17,2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.write(\\\" Time Peer Value \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
if subtxs ~= \\\"end\\\" then\\r\\\
local tx = 0\\r\\\
local s = 0\\r\\\
ar = 16*scroll\\r\\\
repeat\\r\\\
tx = tx + 1\\r\\\
stdate[tx] = string.sub(subtxs,1,12)\\r\\\
subtxs = string.sub(subtxs,13)\\r\\\
stpeer[tx] = string.sub(subtxs,1,10)\\r\\\
subtxs = string.sub(subtxs,11)\\r\\\
stval[tx] = tonumber(string.sub(subtxs,1,9))\\r\\\
subtxs = string.sub(subtxs,10)\\r\\\
if stpeer[tx] == subject then stval[tx] = 0 end\\r\\\
until string.len(subtxs) == 3\\r\\\
repeat\\r\\\
ar = ar + 1\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(18,2+ar-(16*(scroll)))\\r\\\
term.write(stdate[ar])\\r\\\
if stpeer[ar] ~= \\\"N/A(Mined)\\\" then term.setTextColor(512) end\\r\\\
if stpeer[ar] == subject then term.setTextColor(32768) end\\r\\\
if stpeer[ar] == \\\"N/A(Names)\\\" then term.setTextColor(32768) end\\r\\\
term.setCursorPos(31,2+ar-(16*(scroll)))\\r\\\
term.write(stpeer[ar])\\r\\\
term.setCursorPos(50-string.len(tostring(math.abs(stval[ar]))),2+ar-(16*(scroll)))\\r\\\
if stval[ar] > 0 then\\r\\\
term.setTextColor(8192)\\r\\\
term.write(\\\"+\\\")\\r\\\
elseif stval[ar] < 0 then\\r\\\
term.setTextColor(16384)\\r\\\
else\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" \\\")\\r\\\
end\\r\\\
term.write(tostring(stval[ar]))\\r\\\
until ar == math.min(tx,16*(scroll+1))\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setCursorPos(17,19)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(17,19)\\r\\\
term.setTextColor(32768)\\r\\\
lastpage = math.floor((tx-1)/16)\\r\\\
if (1+lastpage) < 100 then maxspace = maxspace..\\\" \\\" end\\r\\\
if (1+lastpage) < 10 then maxspace = maxspace..\\\" \\\" end\\r\\\
if (1+scroll) < 100 then pagespace = pagespace..\\\" \\\" end\\r\\\
if (1+scroll) < 10 then pagespace = pagespace..\\\" \\\" end\\r\\\
term.write(\\\" Page \\\"..pagespace..(1+scroll)..\\\"/\\\"..maxspace..(1+lastpage))\\r\\\
pagespace = \\\"\\\"\\r\\\
maxspace = \\\"\\\"\\r\\\
term.setCursorPos(32,19)\\r\\\
term.setTextColor(128)\\r\\\
term.write(\\\"First Prev Next Last\\\")\\r\\\
if (scroll > 0) then\\r\\\
term.setCursorPos(32,19)\\r\\\
term.setTextColor(2048)\\r\\\
term.write(\\\"First Prev\\\")\\r\\\
end\\r\\\
if (scroll < lastpage and tx > 16) then\\r\\\
term.setCursorPos(43,19)\\r\\\
term.setTextColor(2048)\\r\\\
term.write(\\\"Next Last\\\")\\r\\\
end\\r\\\
else\\r\\\
term.write(\\\"No transactions to display!\\\")\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setCursorPos(17,19)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(17,19)\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" Page 1/ 1\\\")\\r\\\
term.setCursorPos(32,19)\\r\\\
term.setTextColor(128)\\r\\\
term.write(\\\"First Prev Next Last\\\")\\r\\\
end\\r\\\
elseif page == 3 then\\r\\\
term.setCursorPos(19,2)\\r\\\
term.write(\\\"Your address: \\\")\\r\\\
term.setTextColor(16384)\\r\\\
term.write(address)\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(19,3)\\r\\\
term.write(\\\"Your balance: \\\")\\r\\\
term.setTextColor(1024)\\r\\\
if tostring(balance) == 'nil' then balance = 0 end\\r\\\
term.write(tostring(balance)..\\\" KST\\\")\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(19,5)\\r\\\
term.write(\\\"Recipient: \\\")\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(19,6)\\r\\\
term.write(\\\"Amount (KST): \\\")\\r\\\
term.write(\\\" \\\")\\r\\\
elseif page == 4 then\\r\\\
term.setCursorPos(19,2)\\r\\\
term.write(\\\"Mining Addresses\\\")\\r\\\
term.setTextColor(512)\\r\\\
term.setCursorPos(19,3)\\r\\\
term.write(\\\"Latest blocks Address lookup\\\")\\r\\\
term.setCursorPos(19,4)\\r\\\
term.write(\\\"Lowest hashes Top balances\\\")\\r\\\
term.setCursorPos(19,5)\\r\\\
--term.write(\\\"Lowest nonces \\\")\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(19,7)\\r\\\
--term.write(\\\"Economy Transactions\\\")\\r\\\
term.setTextColor(512)\\r\\\
term.setCursorPos(19,8)\\r\\\
--term.write(\\\"KST issuance Latest transfers\\\")\\r\\\
term.setCursorPos(19,9)\\r\\\
--term.write(\\\"KST distrib. Largest transfers\\\")\\r\\\
elseif page == 5 then\\r\\\
local blocks = readURL(readconfig(\\\"syncnode\\\")..\\\"?blocks\\\")\\r\\\
local tx = 0\\r\\\
ar = 0\\r\\\
local height = string.sub(blocks,1,8)\\r\\\
local blktime = {}\\r\\\
blkpeer = {}\\r\\\
local blkhash = {}\\r\\\
height = tonumber(string.sub(blocks,1,8))\\r\\\
blocks = string.sub(blocks,9)\\r\\\
local today = string.sub(blocks,1,10)\\r\\\
blocks = string.sub(blocks,11)\\r\\\
repeat\\r\\\
tx = tx + 1\\r\\\
blktime[tx] = string.sub(blocks,1,8)\\r\\\
blocks = string.sub(blocks,9)\\r\\\
blkpeer[tx] = string.sub(blocks,1,10)\\r\\\
blocks = string.sub(blocks,11)\\r\\\
blkhash[tx] = string.sub(blocks,1,12)\\r\\\
blocks = string.sub(blocks,13)\\r\\\
if stpeer[tx] == subject then stval[tx] = 0 end\\r\\\
until string.len(blocks) == 0\\r\\\
term.setCursorPos(18,1)\\r\\\
term.write(\\\"Height: \\\"..tostring(height))\\r\\\
term.setCursorPos(36,1)\\r\\\
term.write(\\\"Date: \\\"..today)\\r\\\
term.setCursorPos(17,2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.write(\\\" Time Miner Hash \\\")\\r\\\
----------(\\\" 00:00:00 0000000000 000000000000 \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
repeat\\r\\\
ar = ar + 1\\r\\\
term.setCursorPos(18,2+ar)\\r\\\
term.write(blktime[ar])\\r\\\
if blkpeer[ar] ~= \\\"N/A(Burnt)\\\" then term.setTextColor(512) end\\r\\\
term.setCursorPos(27,2+ar)\\r\\\
term.write(blkpeer[ar])\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(38,2+ar)\\r\\\
term.write(blkhash[ar])\\r\\\
until ar == math.min(tx,17*(scroll+1))\\r\\\
elseif page == 6 then\\r\\\
term.setCursorPos(17,2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.write(\\\" Time Peer Value \\\")\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setCursorPos(17,19)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setCursorPos(17,19)\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" Page /\\\")\\r\\\
term.setCursorPos(32,19)\\r\\\
term.setTextColor(128)\\r\\\
term.write(\\\"First Prev Next Last\\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(18,1)\\r\\\
term.write(\\\"ADDRESS (click to edit)\\\")\\r\\\
elseif page == 7 then\\r\\\
local blocks = readURL(readconfig(\\\"syncnode\\\")..\\\"?richapi\\\")\\r\\\
local tx = 0\\r\\\
ar = 0\\r\\\
local height = string.sub(blocks,1,8)\\r\\\
local blktime = {}\\r\\\
blkpeer = {}\\r\\\
local blkhash = {}\\r\\\
repeat\\r\\\
tx = tx + 1\\r\\\
blkpeer[tx] = string.sub(blocks,1,10)\\r\\\
blocks = string.sub(blocks,11)\\r\\\
blktime[tx] = tonumber(string.sub(blocks,1,8))\\r\\\
blocks = string.sub(blocks,9)\\r\\\
blkhash[tx] = string.sub(blocks,1,11)\\r\\\
blocks = string.sub(blocks,12)\\r\\\
until string.len(blocks) == 0\\r\\\
term.setCursorPos(18,1)\\r\\\
term.write(\\\"Krist address rich list\\\")\\r\\\
term.setCursorPos(17,2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.write(\\\"R# Address Balance First seen \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
repeat\\r\\\
ar = ar + 1\\r\\\
term.setCursorPos(17,2+ar)\\r\\\
if ar < 10 then term.write(\\\" \\\") end\\r\\\
term.write(ar)\\r\\\
term.setCursorPos(20,2+ar)\\r\\\
if blkpeer[ar] ~= \\\"N/A(Burnt)\\\" then term.setTextColor(512) end\\r\\\
term.write(blkpeer[ar])\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(39-string.len(tostring(math.abs(blktime[ar]))),2+ar)\\r\\\
term.write(blktime[ar])\\r\\\
term.setCursorPos(40,2+ar)\\r\\\
term.write(blkhash[ar])\\r\\\
until ar == 16\\r\\\
elseif page == 8 then\\r\\\
term.setCursorPos(19,2)\\r\\\
term.write(\\\"Storage Names\\\")\\r\\\
term.setTextColor(512)\\r\\\
term.setCursorPos(19,3)\\r\\\
term.write(\\\"Double vault Register name\\\")\\r\\\
term.setCursorPos(19,4)\\r\\\
term.write(\\\"Local vault\\\")\\r\\\
term.setCursorPos(19,5)\\r\\\
--term.write(\\\"Disk vault v1 SHA vault\\\")\\r\\\
term.setCursorPos(19,6)\\r\\\
--term.write(\\\"SHA vault v1 wallet\\\")\\r\\\
elseif page == 9 then\\r\\\
term.setCursorPos(25,2)\\r\\\
term.write(\\\"Double vault manager\\\")\\r\\\
term.setCursorPos(19,8)\\r\\\
term.write(\\\"Using double vaults is a way to\\\")\\r\\\
term.setCursorPos(19,9)\\r\\\
term.write(\\\"store your Krist under an extra\\\")\\r\\\
term.setCursorPos(19,10)\\r\\\
term.write(\\\"layer of security. You can only\\\")\\r\\\
term.setCursorPos(19,11)\\r\\\
term.write(\\\"access a double vault from your\\\")\\r\\\
term.setCursorPos(19,12)\\r\\\
term.write(\\\"wallet (on any server) and then\\\")\\r\\\
term.setCursorPos(19,13)\\r\\\
term.write(\\\"only after typing an extra pass\\\")\\r\\\
term.setCursorPos(19,14)\\r\\\
term.write(\\\"code. Double wallets are wholly\\\")\\r\\\
term.setCursorPos(19,15)\\r\\\
term.write(\\\"invisible to unauthorized users\\\")\\r\\\
term.setCursorPos(19,16)\\r\\\
term.write(\\\"of your wallet; they can not be\\\")\\r\\\
term.setCursorPos(19,17)\\r\\\
term.write(\\\"seen or opened without the pass\\\")\\r\\\
term.setCursorPos(19,18)\\r\\\
term.write(\\\"code set by you.\\\")\\r\\\
term.setCursorPos(19,4)\\r\\\
term.write(\\\"Pass code: \\\")\\r\\\
term.setCursorPos(19,5)\\r\\\
term.write(\\\"Amount (KST): \\\")\\r\\\
term.setCursorPos(30,4)\\r\\\
if string.len(doublekey) == 0 then\\r\\\
term.setTextColor(256)\\r\\\
term.write(\\\"(click to set)\\\")\\r\\\
else\\r\\\
term.setTextColor(8192)\\r\\\
term.write(\\\"Ready: \\\"..balance2..\\\" KST\\\")\\r\\\
if tonumber(amt) > 0 then\\r\\\
term.setCursorPos(25,6)\\r\\\
term.setTextColor(32768)\\r\\\
term.setBackgroundColor(128)\\r\\\
if tonumber(amt) <= balance then\\r\\\
term.setBackgroundColor(2)\\r\\\
end\\r\\\
term.write(\\\" Deposit \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setBackgroundColor(128)\\r\\\
if tonumber(amt) <= balance2 then\\r\\\
term.setBackgroundColor(2)\\r\\\
end\\r\\\
term.write(\\\" Withdraw \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
end\\r\\\
end\\r\\\
term.setCursorPos(33,5)\\r\\\
if amt == 0 then\\r\\\
term.setTextColor(256)\\r\\\
term.write(\\\"(click to set)\\\")\\r\\\
else\\r\\\
term.setTextColor(32768)\\r\\\
term.write(amt)\\r\\\
end\\r\\\
term.setTextColor(32768)\\r\\\
elseif page == 10 then\\r\\\
local blocks = readURL(readconfig(\\\"syncnode\\\")..\\\"?blocks&low\\\")\\r\\\
local tx = 0\\r\\\
ar = 0\\r\\\
local blktime = {}\\r\\\
blkpeer = {}\\r\\\
local blkhash = {}\\r\\\
repeat\\r\\\
tx = tx + 1\\r\\\
blktime[tx] = string.sub(blocks,1,6)\\r\\\
blocks = string.sub(blocks,7)\\r\\\
blkpeer[tx] = string.sub(blocks,1,6)\\r\\\
blocks = string.sub(blocks,7)\\r\\\
blkhash[tx] = string.sub(blocks,1,20)\\r\\\
blocks = string.sub(blocks,21)\\r\\\
until string.len(blocks) == 0\\r\\\
term.setCursorPos(17,1)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.write(\\\" Date Block# Hash \\\")\\r\\\
----------(\\\" Feb 28 000000 000000000000oooooooo\\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
repeat\\r\\\
ar = ar + 1\\r\\\
term.setCursorPos(18,1+ar)\\r\\\
term.write(blktime[ar])\\r\\\
term.setCursorPos(31-string.len(tostring(math.abs(tonumber(blkpeer[ar])))),1+ar)\\r\\\
term.write(tonumber(blkpeer[ar]))\\r\\\
term.setTextColor(256)\\r\\\
term.setCursorPos(32,1+ar)\\r\\\
term.write(blkhash[ar])\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(32,1+ar)\\r\\\
term.write(string.sub(blkhash[ar],1,12))\\r\\\
until ar == math.min(tx,18)\\r\\\
elseif page == 11 then\\r\\\
local blocks = readURL(readconfig(\\\"syncnode\\\")..\\\"?blocks&low&lownonce\\\")\\r\\\
local tx = 0\\r\\\
ar = 0\\r\\\
local blktime = {}\\r\\\
blkpeer = {}\\r\\\
local blkhash = {}\\r\\\
repeat\\r\\\
tx = tx + 1\\r\\\
blktime[tx] = string.sub(blocks,1,6)\\r\\\
blocks = string.sub(blocks,7)\\r\\\
blkpeer[tx] = string.sub(blocks,1,6)\\r\\\
blocks = string.sub(blocks,7)\\r\\\
blkhash[tx] = string.sub(blocks,1,12)\\r\\\
blocks = string.sub(blocks,13)\\r\\\
until string.len(blocks) == 0\\r\\\
term.setCursorPos(17,1)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.write(\\\" Date Block# Nonce \\\")\\r\\\
----------(\\\" Feb 28 000000 000000000000\\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
repeat\\r\\\
ar = ar + 1\\r\\\
term.setCursorPos(18,1+ar)\\r\\\
term.write(blktime[ar])\\r\\\
term.setCursorPos(31-string.len(tostring(math.abs(tonumber(blkpeer[ar])))),1+ar)\\r\\\
term.write(tonumber(blkpeer[ar]))\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(32,1+ar)\\r\\\
term.write(tonumber(blkhash[ar]))\\r\\\
until ar == math.min(tx,18)\\r\\\
elseif page == 12 then\\r\\\
local blocks = readURL(readconfig(\\\"syncnode\\\")..\\\"?blocks&low&highnonce\\\")\\r\\\
local tx = 0\\r\\\
ar = 0\\r\\\
local blktime = {}\\r\\\
blkpeer = {}\\r\\\
local blkhash = {}\\r\\\
repeat\\r\\\
tx = tx + 1\\r\\\
blktime[tx] = string.sub(blocks,1,6)\\r\\\
blocks = string.sub(blocks,7)\\r\\\
blkpeer[tx] = string.sub(blocks,1,6)\\r\\\
blocks = string.sub(blocks,7)\\r\\\
blkhash[tx] = string.sub(blocks,1,12)\\r\\\
blocks = string.sub(blocks,13)\\r\\\
until string.len(blocks) == 0\\r\\\
term.setCursorPos(17,1)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.write(\\\" Date Block# Nonce \\\")\\r\\\
----------(\\\" Feb 28 000000 000000000000\\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
repeat\\r\\\
ar = ar + 1\\r\\\
term.setCursorPos(18,1+ar)\\r\\\
term.write(blktime[ar])\\r\\\
term.setCursorPos(31-string.len(tostring(math.abs(tonumber(blkpeer[ar])))),1+ar)\\r\\\
term.write(tonumber(blkpeer[ar]))\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(32,1+ar)\\r\\\
term.write(tonumber(blkhash[ar]))\\r\\\
until ar == math.min(tx,18)\\r\\\
elseif page == 13 then\\r\\\
balance3 = tonumber(readURL(readconfig(\\\"syncnode\\\")..\\\"?getbalance=\\\"..addresslv))\\r\\\
term.setCursorPos(25,2)\\r\\\
term.write(\\\"Local vault manager\\\")\\r\\\
term.setCursorPos(19,8)\\r\\\
term.write(\\\"Local vaults are a place to put\\\")\\r\\\
term.setCursorPos(19,9)\\r\\\
term.write(\\\"Krist in the form of a file on\\\")\\r\\\
term.setCursorPos(19,10)\\r\\\
term.write(\\\"a computer. Unlike traditional\\\")\\r\\\
term.setCursorPos(19,11)\\r\\\
term.write(\\\"wallets, local vaults can only\\\")\\r\\\
term.setCursorPos(19,12)\\r\\\
term.write(\\\"be accessed on the computer\\\")\\r\\\
term.setCursorPos(19,13)\\r\\\
term.write(\\\"they were initially created on.\\\")\\r\\\
term.setCursorPos(19,14)\\r\\\
term.write(\\\"If you do this, please ensure\\\")\\r\\\
term.setCursorPos(19,15)\\r\\\
term.write(\\\"that this computer is never\\\")\\r\\\
term.setCursorPos(19,16)\\r\\\
term.write(\\\"stolen or broken, as your money\\\")\\r\\\
term.setCursorPos(19,17)\\r\\\
term.write(\\\"may be lost if you don't have a\\\")\\r\\\
term.setCursorPos(19,18)\\r\\\
term.write(\\\"backup.\\\")\\r\\\
term.setCursorPos(19,4)\\r\\\
term.write(\\\"KST put here: \\\"..balance3)\\r\\\
term.setCursorPos(19,5)\\r\\\
term.write(\\\"Amount (KST): \\\")\\r\\\
term.setCursorPos(33,5)\\r\\\
if amt == 0 then\\r\\\
term.setTextColor(256)\\r\\\
term.write(\\\"(click to set)\\\")\\r\\\
else\\r\\\
term.setTextColor(32768)\\r\\\
term.write(amt)\\r\\\
end\\r\\\
if tonumber(amt) > 0 then\\r\\\
term.setCursorPos(25,6)\\r\\\
term.setTextColor(32768)\\r\\\
term.setBackgroundColor(128)\\r\\\
if tonumber(amt) <= balance then\\r\\\
term.setBackgroundColor(2)\\r\\\
end\\r\\\
term.write(\\\" Deposit \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.write(\\\" \\\")\\r\\\
term.setBackgroundColor(128)\\r\\\
if tonumber(amt) <= balance3 then\\r\\\
term.setBackgroundColor(2)\\r\\\
end\\r\\\
term.write(\\\" Withdraw \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
end\\r\\\
elseif page == 14 then\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(19,2)\\r\\\
term.write(\\\"Local settings\\\")\\r\\\
--deprecated for now\\r\\\
elseif page == 15 then\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(18,1)\\r\\\
term.write(\\\".KST domain name manager [New]\\\")\\r\\\
term.setCursorPos(46,1)\\r\\\
term.setBackgroundColor(32)\\r\\\
term.setTextColor(1)\\r\\\
term.write(\\\" + NEW\\\")\\r\\\
term.setCursorPos(17,2)\\r\\\
term.setBackgroundColor(256)\\r\\\
term.setTextColor(32768)\\r\\\
term.write(\\\" Name Actions \\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(18,3)\\r\\\
local namelist = readURL(readconfig(\\\"syncnode\\\")..\\\"?listnames=\\\"..address)\\r\\\
local splitname = split(namelist, \\\";\\\")\\r\\\
\\r\\\
\\r\\\
if #splitname == 0 then\\r\\\
term.setTextColor(256)\\r\\\
term.write(\\\"No names to display!\\\")\\r\\\
else\\r\\\
local namecount = 1\\r\\\
repeat\\r\\\
local thisname = splitname[namecount]\\r\\\
--namelist:sub(0,namelist:find(\\\";\\\")-1)\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(18,3+namecount)\\r\\\
term.write(splitname[namecount]..\\\".kst\\\")\\r\\\
term.setCursorPos(39,3+namecount)\\r\\\
term.setTextColor(512)\\r\\\
if thisname == \\\"a\\\" or thisname == \\\"name\\\" or thisname == \\\"owner\\\" or thisname == \\\"updated\\\" or thisname == \\\"registered\\\" or thisname == \\\"expires\\\" or thisname == \\\"id\\\" or thisname == \\\"unpaid\\\" then term.setTextColor(256) end\\r\\\
term.write(\\\"Edit Send \\\")\\r\\\
term.setTextColor(256)\\r\\\
term.write(\\\"Go\\\")\\r\\\
namecount = namecount + 1\\r\\\
until namecount == #splitname+1\\r\\\
end\\r\\\
--term.write(\\\"a.kst Edit Send Go\\\")\\r\\\
term.setBackgroundColor(1)\\r\\\
elseif page == 16 then\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(20,2)\\r\\\
term.write(\\\".KST domain name registration\\\")\\r\\\
term.setCursorPos(19,4)\\r\\\
term.write(\\\"Name: \\\")\\r\\\
if name == \\\"\\\" then\\r\\\
term.setTextColor(colors.lightGray)\\r\\\
term.write(\\\"(click to set)\\\")\\r\\\
else\\r\\\
term.write(name)\\r\\\
term.setTextColor(colors.lightGray)\\r\\\
term.write(\\\".kst\\\")\\r\\\
end\\r\\\
term.setTextColor(colors.black)\\r\\\
term.setCursorPos(19,5)\\r\\\
term.write(\\\"Cost: 500 KST\\\")\\r\\\
term.setCursorPos(19,7)\\r\\\
--term.write(\\\"Available! [Register]\\\")\\r\\\
if name == \\\"\\\" then\\r\\\
term.setTextColor(colors.blue)\\r\\\
term.write(\\\"Please select a name!\\\")\\r\\\
elseif availability == 1 then\\r\\\
term.setTextColor(colors.green)\\r\\\
term.write(\\\"Available! \\\")\\r\\\
--if balance >= 500 then\\r\\\
term.setBackgroundColor(colors.green)\\r\\\
term.setTextColor(colors.lime)\\r\\\
term.write(\\\" Register \\\")\\r\\\
term.setBackgroundColor(colors.white)\\r\\\
--end\\r\\\
elseif availability == 2 then\\r\\\
term.setTextColor(colors.yellow)\\r\\\
term.write(\\\"Name registered!\\\")\\r\\\
else\\r\\\
term.setTextColor(colors.red)\\r\\\
term.write(\\\"Not available!\\\")\\r\\\
end\\r\\\
term.setTextColor(colors.black)\\r\\\
term.setCursorPos(19,9)\\r\\\
term.write(\\\".KST domain names are used on\\\")\\r\\\
term.setCursorPos(19,10)\\r\\\
term.write(\\\"the KristScape browser. For\\\")\\r\\\
term.setCursorPos(19,11)\\r\\\
term.write(\\\"more information, please see\\\")\\r\\\
term.setCursorPos(19,12)\\r\\\
term.write(\\\"the Krist thread.\\\")\\r\\\
term.setCursorPos(19,14)\\r\\\
term.write(\\\"All Krist spent on names will\\\")\\r\\\
term.setCursorPos(19,15)\\r\\\
term.write(\\\"be added to the value of\\\")\\r\\\
term.setCursorPos(19,16)\\r\\\
term.write(\\\"future blocks; essentially\\\")\\r\\\
term.setCursorPos(19,17)\\r\\\
term.write(\\\"being \\\\\\\"re-mined.\\\\\\\"\\\")\\r\\\
elseif page == 17 then\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(28,2)\\r\\\
term.write(\\\".KST zone file\\\")\\r\\\
term.setCursorPos(19,4)\\r\\\
term.write(\\\"Name: \\\"..subject)\\r\\\
term.setTextColor(colors.lightGray)\\r\\\
term.write(\\\".kst\\\")\\r\\\
term.setTextColor(colors.black)\\r\\\
term.setCursorPos(19,7)\\r\\\
term.write(\\\"Your name's zone file is the\\\")\\r\\\
term.setCursorPos(19,8)\\r\\\
term.write(\\\"URL of the site it is pointing\\\")\\r\\\
term.setCursorPos(19,9)\\r\\\
term.write(\\\"to. When KristScape navigates\\\")\\r\\\
term.setCursorPos(19,10)\\r\\\
term.write(\\\"to a name, it will make an HTTP\\\")\\r\\\
term.setCursorPos(19,11)\\r\\\
term.write(\\\"get request to the above URL.\\\")\\r\\\
term.setCursorPos(19,12)\\r\\\
term.write(\\\"The zone record should not\\\")\\r\\\
term.setCursorPos(19,13)\\r\\\
term.write(\\\"include a protocol (http://)\\\")\\r\\\
term.setCursorPos(19,14)\\r\\\
term.write(\\\"and shouldn't end with a\\\")\\r\\\
term.setCursorPos(19,15)\\r\\\
term.write(\\\"slash. You can redirect a name\\\")\\r\\\
term.setCursorPos(19,16)\\r\\\
term.write(\\\"to another name by making the\\\")\\r\\\
term.setCursorPos(19,17)\\r\\\
term.write(\\\"first character of the record\\\")\\r\\\
term.setCursorPos(19,18)\\r\\\
term.write(\\\"a dollar sign; e.g. $krist.kst\\\")\\r\\\
term.setTextColor(colors.black)\\r\\\
term.setCursorPos(19,5)\\r\\\
term.write(\\\"Zone: \\\")\\r\\\
zone = readURL(readconfig(\\\"syncnode\\\")..\\\"?a=\\\"..subject)\\r\\\
if zone == \\\"\\\" then\\r\\\
term.setTextColor(colors.lightGray)\\r\\\
term.write(\\\"(click to set)\\\")\\r\\\
else\\r\\\
term.write(zone)\\r\\\
end\\r\\\
elseif page == 18 then\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(28,2)\\r\\\
term.write(\\\"Name transfer\\\")\\r\\\
term.setCursorPos(19,4)\\r\\\
term.write(\\\"Name: \\\"..subject)\\r\\\
term.setTextColor(colors.lightGray)\\r\\\
term.write(\\\".kst\\\")\\r\\\
term.setTextColor(colors.black)\\r\\\
term.setCursorPos(19,5)\\r\\\
term.write(\\\"Recipient: \\\")\\r\\\
elseif page == 21 then\\r\\\
term.setBackgroundColor(1)\\r\\\
term.setCursorPos(4,6)\\r\\\
term.write(\\\"Address - \\\")\\r\\\
term.setTextColor(16384)\\r\\\
term.write(address)\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(4,7)\\r\\\
term.write(\\\"Balance - \\\")\\r\\\
term.setTextColor(1024)\\r\\\
if tostring(balance) == 'nil' then balance = 0 end\\r\\\
term.write(tostring(balance)..\\\" KST\\\")\\r\\\
term.setTextColor(32768)\\r\\\
term.setCursorPos(3,9)\\r\\\
end\\r\\\
end\\r\\\
boot()\",\
}",
config = "{\
type = \"Cryptocurrency\",\
name = \"Krist Wallet\",\
version = 14,\
main = \"krist.lua\",\
id = \"3d6.kristwallet\",\
author = \"3d6\",\
hidden = false,\
}",
}