Advertisement
Guest User

kristwallet

a guest
Oct 19th, 2016
3,353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 57.91 KB | None | 0 0
  1. --[[-----------------------------------------------
  2. |               KristWallet by 3d6                |
  3. ---------------------------------------------------
  4. | This is the reference wallet for Krist.         |
  5. | It is the basic definition of a functional      |
  6. | Krist program, although it is not as old as the |
  7. | network (we used to just use raw API calls).    |
  8. ---------------------------------------------------
  9.  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\
  10. /  \/  \/  \/  \/  \/  \/  \/  \/  \/  \/  \/  \/
  11. ---------------------------------------------------
  12. | Do whatever you want with this, but if you make |
  13. | it interact with a currency or network other    |
  14. | than Krist, please give me credit. Thanks <3    |
  15. ---------------------------------------------------
  16. | This wallet will NEVER save passwords anywhere. |]]local
  17. -----------------------------------------------]]--
  18.                    version = 14
  19. local latest = 0
  20. local balance = 0
  21. local balance2 = 0
  22. local balance3 = 0
  23. local MOD = 2^32
  24. local MODM = MOD-1
  25. local gui = 0
  26. local page = 0
  27. local lastpage = 0
  28. local scroll = 0
  29. local masterkey = ""
  30. local doublekey = ""
  31. local address = ""
  32. local addressv1 = ""
  33. local addressdv = ""
  34. local addresslv = ""
  35. local subject = ""
  36. local name = ""
  37. local subbal = 0
  38. local subtxs = ""
  39. local stdate = {}
  40. local stpeer = {}
  41. local stval = {}
  42. local blkpeer = {}
  43. local pagespace = ""
  44. local maxspace = ""
  45. local ar = 0
  46. local amt = 0
  47. local availability = 0
  48. local wallet, hud, update, settle, log, readconfig, checkdir, openwallet, makev2address
  49.  
  50. local function split(inputstr, sep)
  51.         if sep == nil then
  52.                 sep = "%s"
  53.         end
  54.         local t={} ; i=1
  55.         for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  56.                 t[i] = str
  57.                 i = i + 1
  58.         end
  59.         return t
  60. end
  61.  
  62. local function readURL(url)
  63.   local resp = http.get(url)
  64.   if not resp then
  65.     log("Could not reach "..url)
  66.     error("Error connecting to server")
  67.     panic()
  68.   end
  69.   local content = resp.readAll():gsub("\n+$", "")
  70.   resp.close()
  71.   return content
  72. end
  73.  
  74. local function boot()
  75.   for i=1,2 do checkdir() end
  76.   print("Starting KristWallet v"..tostring(version))
  77.   log("Started KristWallet v"..tostring(version))
  78.   update()
  79.   if readconfig("enabled") and latest <= version then
  80.     settle()
  81.     openwallet()
  82.     while page ~= 0 do
  83.       wallet()
  84.     end
  85.     term.setBackgroundColor(32768)
  86.     term.setTextColor(16)
  87.     term.clear()
  88.     term.setCursorPos(1,1)
  89.     log("KristWallet closed safely")
  90.   else
  91.     if not readconfig("enabled") then print("KristWallet is disabled on this computer.") log("Disabled, shutting down") end
  92.   end
  93.   if readconfig("rebootonexit") then
  94.     log("Rebooted computer")
  95.     os.reboot()
  96.   end
  97. end
  98. function update()
  99.   latest = tonumber(readURL(readconfig("versionserver")))
  100.   if latest > version then
  101.     print("An update is available!")
  102.     log("Discovered update")
  103.     if readconfig("autoupdate") and not bench then
  104.       local me = fs.open(fs.getName(shell.getRunningProgram()),"w")
  105.       local nextversion = readURL(readconfig("updateserver"))
  106.       print("Installed update. Run this program again to start v"..latest..".")
  107.       me.write(nextversion)
  108.       me.close()
  109.       log("Installed update")
  110.     else
  111.       log("Ignored update")
  112.       latest = -2
  113.     end
  114.   else
  115.     log("No updates found")
  116.   end
  117. end
  118. function log(text)
  119.   local logfile = fs.open("kst/log_wallet","a")
  120.   logfile.writeLine(tostring(os.day()).."-"..tostring(os.time()).."/"..text)
  121.   logfile.close()
  122. end
  123. local function checkfile(path,default)
  124.   if not fs.exists("kst/"..path) or path == "syncnode" then
  125.     local file = fs.open("kst/"..path,"w")
  126.     file.writeLine(default)
  127.     file.close()
  128.     log("Created file "..path)
  129.     return false
  130.   else
  131.     return true
  132.   end
  133. end
  134. function readconfig(path)
  135.   if fs.exists("kst/"..path) then
  136.     local file = fs.open("kst/"..path,"r")
  137.     local context = file.readAll():gsub("\n+$", "")
  138.     file.close()
  139.     if context == "true" then return true end
  140.     if context == "false" then return false end
  141.     return context
  142.   else
  143.     print("An unknown error happened")
  144.   end
  145. end
  146. function settle()
  147.   if term.isColor() then gui = 1 end
  148.   if term.isColor() and pocket then gui = 2 end
  149. end
  150. local function drawKrist()
  151.   local posx, posy = term.getCursorPos()
  152.   term.setBackgroundColor(1)
  153.   term.setTextColor(32)
  154.   term.write("/")
  155.   term.setBackgroundColor(32)
  156.   term.setTextColor(8192)
  157.   term.write("\\")
  158.   term.setCursorPos(posx,posy+1)
  159.   term.setBackgroundColor(32)
  160.   term.setTextColor(8192)
  161.   term.write("\\")
  162.   term.setBackgroundColor(8192)
  163.   term.setTextColor(32)
  164.   term.write("/")
  165.   term.setCursorPos(posx+2,posy)
  166. end
  167. local function memoize(f)
  168.   local mt = {}
  169.   local t = setmetatable({}, mt)
  170.   function mt:__index(k)
  171.     local v = f(k)
  172.     t[k] = v
  173.     return v
  174.   end
  175.   return t
  176. end
  177. local function make_bitop_uncached(t, m)
  178.   local function bitop(a, b)
  179.     local res,p = 0,1
  180.     while a ~= 0 and b ~= 0 do
  181.       local am, bm = a % m, b % m
  182.       res = res + t[am][bm] * p
  183.       a = (a - am) / m
  184.       b = (b - bm) / m
  185.       p = p*m
  186.     end
  187.     res = res + (a + b) * p
  188.     return res
  189.   end
  190.   return bitop
  191. end
  192. local function make_bitop(t)
  193.   local op1 = make_bitop_uncached(t,2^1)
  194.   local op2 = memoize(function(a) return memoize(function(b) return op1(a, b) end) end)
  195.   return make_bitop_uncached(op2, 2 ^ (t.n or 1))
  196. end
  197. local bxor1 = make_bitop({[0] = {[0] = 0,[1] = 1}, [1] = {[0] = 1, [1] = 0}, n = 4})
  198. local function bxor(a, b, c, ...)
  199.   local z = nil
  200.   if b then
  201.     a = a % MOD
  202.     b = b % MOD
  203.     z = bxor1(a, b)
  204.     if c then z = bxor(z, c, ...) end
  205.     return z
  206.   elseif a then return a % MOD
  207.   else return 0 end
  208. end
  209. local function band(a, b, c, ...)
  210.   local z
  211.   if b then
  212.     a = a % MOD
  213.     b = b % MOD
  214.     z = ((a + b) - bxor1(a,b)) / 2
  215.     if c then z = bit32_band(z, c, ...) end
  216.     return z
  217.   elseif a then return a % MOD
  218.   else return MODM end
  219. end
  220. local function bnot(x) return (-1 - x) % MOD end
  221. local function rshift1(a, disp)
  222.   if disp < 0 then return lshift(a,-disp) end
  223.   return math.floor(a % 2 ^ 32 / 2 ^ disp)
  224. end
  225. local function rshift(x, disp)
  226.   if disp > 31 or disp < -31 then return 0 end
  227.   return rshift1(x % MOD, disp)
  228. end
  229. local function lshift(a, disp)
  230.   if disp < 0 then return rshift(a,-disp) end
  231.   return (a * 2 ^ disp) % 2 ^ 32
  232. end
  233. local function rrotate(x, disp)
  234.   x = x % MOD
  235.   disp = disp % 32
  236.   local low = band(x, 2 ^ disp - 1)
  237.   return rshift(x, disp) + lshift(low, 32 - disp)
  238. end
  239. local k = {
  240.   0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  241.   0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  242.   0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  243.   0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  244.   0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  245.   0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  246.   0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  247.   0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  248.   0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  249.   0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  250.   0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  251.   0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  252.   0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  253.   0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  254.   0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  255.   0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
  256. }
  257. local function str2hexa(s)
  258.   return (string.gsub(s, ".", function(c) return string.format("%02x", string.byte(c)) end))
  259. end
  260. local function num2s(l, n)
  261.   local s = ""
  262.   for i = 1, n do
  263.     local rem = l % 256
  264.     s = string.char(rem) .. s
  265.     l = (l - rem) / 256
  266.   end
  267.   return s
  268. end
  269. local function s232num(s, i)
  270.   local n = 0
  271.   for i = i, i + 3 do n = n*256 + string.byte(s, i) end
  272.   return n
  273. end
  274. local function preproc(msg, len)
  275.   local extra = 64 - ((len + 9) % 64)
  276.   len = num2s(8 * len, 8)
  277.   msg = msg .. "\128" .. string.rep("\0", extra) .. len
  278.   assert(#msg % 64 == 0)
  279.   return msg
  280. end
  281. local function initH256(H)
  282.   H[1] = 0x6a09e667
  283.   H[2] = 0xbb67ae85
  284.   H[3] = 0x3c6ef372
  285.   H[4] = 0xa54ff53a
  286.   H[5] = 0x510e527f
  287.   H[6] = 0x9b05688c
  288.   H[7] = 0x1f83d9ab
  289.   H[8] = 0x5be0cd19
  290.   return H
  291. end
  292. local function digestblock(msg, i, H)
  293.   local w = {}
  294.   for j = 1, 16 do w[j] = s232num(msg, i + (j - 1)*4) end
  295.   for j = 17, 64 do
  296.     local v = w[j - 15]
  297.     local s0 = bxor(rrotate(v, 7), rrotate(v, 18), rshift(v, 3))
  298.     v = w[j - 2]
  299.     w[j] = w[j - 16] + s0 + w[j - 7] + bxor(rrotate(v, 17), rrotate(v, 19), rshift(v, 10))
  300.   end
  301.  
  302.   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]
  303.   for i = 1, 64 do
  304.     local s0 = bxor(rrotate(a, 2), rrotate(a, 13), rrotate(a, 22))
  305.     local maj = bxor(band(a, b), band(a, c), band(b, c))
  306.     local t2 = s0 + maj
  307.     local s1 = bxor(rrotate(e, 6), rrotate(e, 11), rrotate(e, 25))
  308.     local ch = bxor (band(e, f), band(bnot(e), g))
  309.     local t1 = h + s1 + ch + k[i] + w[i]
  310.     h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2
  311.   end
  312.  
  313.   H[1] = band(H[1] + a)
  314.   H[2] = band(H[2] + b)
  315.   H[3] = band(H[3] + c)
  316.   H[4] = band(H[4] + d)
  317.   H[5] = band(H[5] + e)
  318.   H[6] = band(H[6] + f)
  319.   H[7] = band(H[7] + g)
  320.   H[8] = band(H[8] + h)
  321. end
  322. local function sha256(msg)
  323.   msg = preproc(msg, #msg)
  324.   local H = initH256({})
  325.   for i = 1, #msg, 64 do digestblock(msg, i, H) end
  326.   return str2hexa(num2s(H[1], 4) .. num2s(H[2], 4) .. num2s(H[3], 4) .. num2s(H[4], 4) ..
  327.           num2s(H[5], 4) .. num2s(H[6], 4) .. num2s(H[7], 4) .. num2s(H[8], 4))
  328. end
  329. local function panic()
  330.   page = 0
  331.   log("Panicking! Shutting down KristWallet.")
  332. end
  333. local function makeaddressbyte(j)
  334.   if j <= 6 then return "0"
  335.   elseif j <= 13 then return "1"
  336.   elseif j <= 20 then return "2"
  337.   elseif j <= 27 then return "3"
  338.   elseif j <= 34 then return "4"
  339.   elseif j <= 41 then return "5"
  340.   elseif j <= 48 then return "6"
  341.   elseif j <= 55 then return "7"
  342.   elseif j <= 62 then return "8"
  343.   elseif j <= 69 then return "9"
  344.   elseif j <= 76 then return "a"
  345.   elseif j <= 83 then return "b"
  346.   elseif j <= 90 then return "c"
  347.   elseif j <= 97 then return "d"
  348.   elseif j <= 104 then return "e"
  349.   elseif j <= 111 then return "f"
  350.   elseif j <= 118 then return "g"
  351.   elseif j <= 125 then return "h"
  352.   elseif j <= 132 then return "i"
  353.   elseif j <= 139 then return "j"
  354.   elseif j <= 146 then return "k"
  355.   elseif j <= 153 then return "l"
  356.   elseif j <= 160 then return "m"
  357.   elseif j <= 167 then return "n"
  358.   elseif j <= 174 then return "o"
  359.   elseif j <= 181 then return "p"
  360.   elseif j <= 188 then return "q"
  361.   elseif j <= 195 then return "r"
  362.   elseif j <= 202 then return "s"
  363.   elseif j <= 209 then return "t"
  364.   elseif j <= 216 then return "u"
  365.   elseif j <= 223 then return "v"
  366.   elseif j <= 230 then return "w"
  367.   elseif j <= 237 then return "x"
  368.   elseif j <= 244 then return "y"
  369.   elseif j <= 251 then return "z"
  370.   else return "e"
  371.   end
  372. end
  373. function checkdir()
  374.   if fs.isDir("kst") then
  375.     math.randomseed(os.time())
  376.     checkfile("log_wallet","-----KRISTWALLET LOG FILE-----")
  377.     checkfile("enabled","true") --Disabling this just makes KristWallet refuse to start.
  378.     checkfile("sweepv1","true")
  379.     checkfile("appendhashes","true") --Disabling this makes it possible to use KristWallet with extremely old addresses.
  380.     checkfile("autoupdate","true")
  381.     checkfile("whitelisted","false")
  382.     checkfile("rebootonexit","false")
  383.     checkfile("autologin","false")
  384.     checkfile("keyAL",sha256(""))
  385.     checkfile("keyLV",sha256(math.random(1000000)..os.time())) --This is where the local vault's krist is stored. DO NOT DESTROY!
  386.     checkfile("versionserver","https://raw.githubusercontent.com/BTCTaras/kristwallet/master/staticapi/version")
  387.     checkfile("updateserver","https://raw.githubusercontent.com/BTCTaras/kristwallet/master/kristwallet")
  388.     checkfile("syncnode","http://krist.ceriat.net/")
  389.     checkfile("whitelist","")
  390.     checkfile("blacklist","")
  391.   else
  392.     fs.makeDir("kst")
  393.   end
  394. end
  395. function openwallet()
  396.   term.setBackgroundColor(8)
  397.   term.clear()
  398.   local krists = 0
  399.   repeat
  400.     term.setCursorPos(3+(3*krists),3)
  401.     drawKrist()
  402.     krists = krists + 1
  403.   until krists == 16
  404.   krists = 0
  405.   repeat
  406.     term.setCursorPos(3+(3*krists),16)
  407.     drawKrist()
  408.     krists = krists + 1
  409.   until krists == 16
  410.   term.setBackgroundColor(8)
  411.   term.setTextColor(32768)
  412.   term.setCursorPos(6,6)
  413.   term.write("Password:")
  414.   term.setCursorPos(6,8)
  415.          -----|---+---------+---------+---------+-----|---+-
  416.   term.write("Please enter your secret password to")
  417.   term.setCursorPos(6,9)
  418.   term.write("use Krist. If this is your first time")
  419.   term.setCursorPos(6,10)
  420.   term.write("using Krist, type your desired password.")
  421.   term.setCursorPos(6,11)
  422.   term.write("You will be able to access your Krist")
  423.   term.setCursorPos(6,12)
  424.   term.write("on any computer on any server as long")
  425.   term.setCursorPos(6,13)
  426.   term.write("as you type in the same password! It will")
  427.   term.setCursorPos(6,14)
  428.   term.write("not be saved or shared with anyone.")
  429.   term.setCursorPos(16,6)
  430.   local password = ""
  431.   if readconfig("autologin") then
  432.     password = readconfig("keyAL")
  433.   else
  434.     password = read("*")
  435.     if password == "" then term.setCursorPos(16,6) password = read("*") end
  436.     if readconfig("appendhashes") then password = sha256("KRISTWALLET"..password) end
  437.   end
  438.   term.clear()
  439.   term.setCursorPos(1,1)
  440.   page = 1+gui*(10*(gui-1))
  441.   if readconfig("appendhashes") then masterkey = password.."-000" else masterkey = password end
  442.   log("Read password")
  443.   addressv1 = string.sub(sha256(masterkey),0,10)
  444.   log("Derived address: "..addressv1)
  445.   address = makev2address(masterkey)
  446.   log("Derived address: "..address)
  447.   balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..addressv1))
  448.   if balance > 0 and readconfig("sweepv1") then local transaction = readURL(readconfig("syncnode").."?pushtx&q="..address.."&pkey="..masterkey.."&amt="..balance); log("Swept hex address") end
  449.   balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  450.     if balance >= 100000 then log("Woah! There's a small fortune here!") elseif balance > 0 then log("There is some krist here!") end
  451.   if readconfig("whitelisted") then
  452.     local whitelist = readconfig("whitelist")
  453.     if string.find(whitelist, address) == nil then
  454.       log(address.." is not on the whitelist!")
  455.       print("Sorry, this wallet is not on the whitelist for this computer!")
  456.       page = 0
  457.       os.sleep(3)
  458.     end
  459.   else
  460.     local blacklist = readconfig("blacklist")
  461.     if string.find(blacklist, addressv1) ~= nil then
  462.       log(addressv1.." is on the blacklist!")
  463.       print("Your wallet is blocked from this computer!")
  464.       page = 0
  465.       os.sleep(3)
  466.     elseif string.find(blacklist, address) ~= nil then
  467.       log(address.." is on the blacklist!")
  468.       print("Your wallet is blocked from this computer!")
  469.       page = 0
  470.       os.sleep(3)
  471.     end
  472.   end
  473.   addresslv = makev2address(readconfig("keyLV"))
  474.   log("Loaded local vault")
  475. end
  476. function makev2address(key)
  477.   local protein = {}
  478.   local stick = sha256(sha256(key))
  479.   local n = 0
  480.   local link = 0
  481.   local v2 = "k"
  482.   repeat
  483.     if n < 9 then protein[n] = string.sub(stick,0,2)
  484.     stick = sha256(sha256(stick)) end
  485.     n = n + 1
  486.   until n == 9
  487.   n = 0
  488.   repeat
  489.     link = tonumber(string.sub(stick,1+(2*n),2+(2*n)),16) % 9
  490.     if string.len(protein[link]) ~= 0 then
  491.       v2 = v2 .. makeaddressbyte(tonumber(protein[link],16))
  492.       protein[link] = ''
  493.       n = n + 1
  494.     else
  495.       stick = sha256(stick)
  496.     end
  497.   until n == 9
  498.   return v2
  499. end
  500. local function postgraphic(px,py,id)
  501.   term.setCursorPos(px,py)
  502.   if id == 0 then drawKrist()
  503.   elseif id == 1 then
  504.     --Mined Krist
  505.     term.setCursorPos(px+1,py)
  506.     term.setBackgroundColor(256)
  507.     term.setTextColor(128)
  508.     term.write("/T\\")
  509.     term.setCursorPos(px,py+1)
  510.     term.write("/")
  511.     term.setCursorPos(px+2,py+1)
  512.     term.write("|")
  513.     term.setCursorPos(px+4,py+1)
  514.     term.write("\\")
  515.     term.setCursorPos(px+2,py+2)
  516.     term.write("|")
  517.     term.setCursorPos(px+2,py+3)
  518.     term.write("|")
  519.     term.setCursorPos(px+4,py+2)
  520.     drawKrist()
  521.   elseif id == 2 then
  522.     --Sent Krist
  523.     term.setCursorPos(px,py+2)
  524.     term.setBackgroundColor(256)
  525.     term.setTextColor(16384)
  526.     term.write(" ")
  527.     term.setCursorPos(px+1,py+3)
  528.     term.write("    ")
  529.     term.setCursorPos(px+5,py+2)
  530.     term.write(" ")
  531.     term.setBackgroundColor(1)
  532.     term.setCursorPos(px+2,py)
  533.     term.write("/\\")
  534.     term.setCursorPos(px+2,py+1)
  535.     term.write("||")
  536.   elseif id == 3 then
  537.     --Received Krist
  538.     term.setCursorPos(px,py+2)
  539.     term.setBackgroundColor(256)
  540.     term.setTextColor(8192)
  541.     term.write(" ")
  542.     term.setCursorPos(px+1,py+3)
  543.     term.write("    ")
  544.     term.setCursorPos(px+5,py+2)
  545.     term.write(" ")
  546.     term.setBackgroundColor(1)
  547.     term.setCursorPos(px+2,py)
  548.     term.write("||")
  549.     term.setCursorPos(px+2,py+1)
  550.     term.write("\\/")
  551.   elseif id == 4 then
  552.     --Sent to yourself
  553.     term.setCursorPos(px,py+2)
  554.     term.setBackgroundColor(256)
  555.     term.setTextColor(16)
  556.     term.write(" ")
  557.     term.setCursorPos(px+1,py+3)
  558.     term.write("    ")
  559.     term.setCursorPos(px+5,py+2)
  560.     term.write(" ")
  561.     term.setBackgroundColor(1)
  562.     term.setCursorPos(px+1,py)
  563.     term.write("/\\||")
  564.     term.setCursorPos(px+1,py+1)
  565.     term.write("||\\/")
  566.   elseif id == 5 then
  567.     --Swept from v1 address
  568.     term.setCursorPos(px+1,py)
  569.     term.setBackgroundColor(256)
  570.     term.setTextColor(128)
  571.     term.write(" v1 ")
  572.     term.setCursorPos(px+2,py+1)
  573.     term.setBackgroundColor(1)
  574.     term.setTextColor(2048)
  575.     term.write("||")
  576.     term.setCursorPos(px+2,py+2)
  577.     term.write("\\/")
  578.     term.setCursorPos(px+1,py+3)
  579.     term.setBackgroundColor(16)
  580.     term.setTextColor(32768)
  581.     term.write(" v2 ")
  582.   elseif id == 6 then
  583.     --Name registered
  584.     term.setBackgroundColor(32)
  585.     term.setTextColor(8192)
  586.     term.setCursorPos(px+4,py)
  587.     term.write("/")
  588.     term.setCursorPos(px+1,py+1)
  589.     term.write("\\")
  590.     term.setCursorPos(px+3,py+1)
  591.     term.write("/")
  592.     term.setCursorPos(px+2,py+2)
  593.     term.write("V")
  594.     term.setCursorPos(px+1,py+3)
  595.     term.setBackgroundColor(16384)
  596.     term.setTextColor(4)
  597.     term.write(".kst")
  598.   elseif id == 7 then
  599.     --Name operation
  600.     term.setBackgroundColor(8)
  601.     term.setTextColor(512)
  602.     term.setCursorPos(px+1,py)
  603.     term.write(" a ")
  604.     term.setBackgroundColor(1)
  605.     term.write("\\")
  606.     term.setBackgroundColor(8)
  607.     term.setCursorPos(px+1,py+1)
  608.     term.write("====")
  609.     term.setCursorPos(px+1,py+2)
  610.     term.write("====")
  611.     term.setCursorPos(px+1,py+3)
  612.     term.setBackgroundColor(16384)
  613.     term.setTextColor(4)
  614.     term.write(".kst")
  615.   elseif id == 8 then
  616.     --Name sent
  617.     term.setCursorPos(px+1,py+3)
  618.     term.setBackgroundColor(16384)
  619.     term.setTextColor(4)
  620.     term.write(".kst")
  621.     term.setTextColor(16384)
  622.     term.setBackgroundColor(1)
  623.     term.setCursorPos(px+2,py)
  624.     term.write("/\\")
  625.     term.setCursorPos(px+2,py+1)
  626.     term.write("||")
  627.   elseif id == 9 then
  628.     --Name received
  629.     term.setCursorPos(px+1,py+3)
  630.     term.setBackgroundColor(16384)
  631.     term.setTextColor(4)
  632.     term.write(".kst")
  633.     term.setTextColor(8192)
  634.     term.setBackgroundColor(1)
  635.     term.setCursorPos(px+1,py)
  636.     term.write("||")
  637.     term.setCursorPos(px+1,py+1)
  638.     term.write("\\/")
  639.     term.setTextColor(16384)
  640.     term.setCursorPos(px+3,py)
  641.     term.write("/\\")
  642.     term.setCursorPos(px+3,py+1)
  643.     term.write("||")
  644.   end
  645. end
  646. function wallet()
  647.   hud()
  648.   local pagebefore = page
  649.   local event, button, xPos, yPos = os.pullEvent("mouse_click")
  650.   if gui == 1 and xPos >= 3 and xPos <= 14 then
  651.     if yPos == 5 then
  652.       page = 1
  653.       balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  654.     end
  655.     if yPos == 7 then
  656.       page = 2
  657.       subject = address
  658.       scroll = 0
  659.     end
  660.     if yPos == 9 then
  661.       page = 3
  662.       balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  663.     end
  664.     if yPos == 11 then
  665.       page = 8
  666.     end
  667.     if yPos == 13 then
  668.       page = 4
  669.     end
  670.     if yPos == 15 then
  671.       page = 15
  672.     end
  673.     if yPos == 17 then
  674.       page = 0
  675.     end
  676.   elseif gui == 2 then
  677.     if yPos == 2 and xPos >= 19 and xPos <= 24 then
  678.       page = 0
  679.     end
  680.   end
  681.   local lexm = http.get(readconfig("syncnode").."?listnames="..address)
  682.   local lem = false
  683.   local lexmm
  684.   if lexm.readAll then
  685.     lem = true
  686.     lexmm = lexm.readAll():gsub("\n+$", "")
  687.   end
  688.    
  689.   if page == 1 then
  690.     balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  691.     if (yPos-7)%5 == 0 and yPos >= 7 and xPos >= 26 and xPos <= 35 then
  692.       subject = string.sub(readURL(readconfig("syncnode").."?listtx="..address.."&overview"),13+(31*((yPos-7)/5)),22+(31*((yPos-7)/5)))
  693.       if string.len(subject) == 10 and subject ~= "N/A(Mined)" and subject ~= "N/A(Names)" then
  694.         page = 2
  695.       end
  696.     end
  697.   elseif page == 2 then
  698.     if yPos > 2 and yPos <= 2+ar-(16*(scroll)) and xPos >= 31 and xPos < 41 then
  699.       if stpeer[(yPos-2)+(16*(scroll))] == "N/A(Mined)" then
  700.         --possibly link to a block later?
  701.       elseif stpeer[(yPos-2)+(16*(scroll))] == "N/A(Names)" then
  702.         --possibly link to a name later??
  703.       else
  704.         subject = stpeer[(yPos-2)+(16*(scroll))]
  705.         scroll = 0
  706.       end
  707.     end
  708.     if yPos == 19 and xPos >= 32 and xPos <= 36 then
  709.       scroll = 0
  710.     end
  711.     if yPos == 19 and xPos >= 38 and xPos <= 41 then
  712.       scroll = math.max(0,scroll-1)
  713.     end
  714.     if yPos == 19 and xPos >= 43 and xPos <= 46 then
  715.       scroll = math.min(lastpage,scroll+1)
  716.     end
  717.     if yPos == 19 and xPos >= 48 then
  718.       scroll = lastpage
  719.     end
  720.     if yPos == 1 and xPos >= 17 then
  721.       page = 6
  722.     end
  723.     log("Page index is "..scroll)
  724.   elseif page == 3 then
  725.     if xPos >= 17 then
  726.       term.setCursorPos(33,5)
  727.       local recipient = read()
  728.       term.setCursorPos(33,6)
  729.       log("Read recipient for transfer")
  730.       local amount = read()
  731.       log("Read amount for transfer")
  732.       local transaction = readURL(readconfig("syncnode").."?pushtx2&q="..recipient.."&pkey="..masterkey.."&amt="..amount)
  733.       balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  734.       log("Attempting to send "..amount.." KST to "..recipient)
  735.       term.setCursorPos(19,8)
  736.       if transaction == "Success" then
  737.         term.setTextColor(8192)
  738.         term.write("Transfer successful")
  739.         log("Transfer successful")
  740.         term.setTextColor(32768)
  741.       elseif string.sub(transaction,0,5) == "Error" then
  742.         local problem = "An unknown error happened"
  743.         local code = tonumber(string.sub(transaction,6,10))
  744.         if code == 1 then problem = "Insufficient funds available" end
  745.         if code == 2 then problem = "Not enough KST in transaction" end
  746.         if code == 3 then problem = "Can't comprehend amount to send" end
  747.         if code == 4 then problem = "Invalid recipient address" end
  748.         term.setTextColor(16384)
  749.         term.write(problem)
  750.         log(problem)
  751.         term.setTextColor(32768)
  752.       else
  753.         term.setTextColor(16384)
  754.         term.write(transaction)
  755.         term.setTextColor(32768)
  756.       end
  757.       os.sleep(2.5) --lower this if you do tons of transfers
  758.       log("Unfroze display")
  759.     end
  760.   elseif page == 4 then
  761.     if yPos == 3 and xPos >= 19 and xPos <= 31 then
  762.       page = 5
  763.       scroll = 0
  764.     end
  765.     if yPos == 4 and xPos >= 19 and xPos <= 31 then
  766.       page = 10
  767.     end
  768.     if yPos == 3 and xPos >= 35 and xPos <= 48 then
  769.       page = 6
  770.     end
  771.     if yPos == 4 and xPos >= 35 and xPos <= 46 then
  772.       page = 7
  773.     end
  774.   elseif page == 5 then
  775.     if yPos > 2 and xPos >= 27 and xPos <= 36 then
  776.       page = 2
  777.       subject = blkpeer[(yPos-2)]
  778.       scroll = 0
  779.     end
  780.   elseif page == 6 then
  781.     term.setCursorPos(18,1)
  782.     term.write("                       ")
  783.     term.setCursorPos(18,1)
  784.     term.write("ADDRESS ")
  785.     subject = read()
  786.     if string.len(subject) == 10 then
  787.       page = 2
  788.       scroll = 0
  789.     else
  790.       page = 6
  791.     end
  792.   elseif page == 7 then
  793.     if yPos > 2 and yPos <= 18 and xPos >= 20 and xPos < 30 then
  794.       if blkpeer[(yPos-2)] ~= "N/A(Burnt)" then
  795.         page = 2
  796.         subject = blkpeer[(yPos-2)]
  797.         scroll = 0
  798.       end
  799.     end
  800.   elseif page == 15 then
  801.    
  802.     local function isEdit(xpo)
  803.         return xpo >= 39 and xpo <= 42
  804.     end
  805.     local function isSend(xpo)
  806.         return xpo >= 44 and xpo <= 47
  807.     end
  808.    
  809.     if xPos and yPos then
  810.         local listofnames = split(lexmm, ";")
  811.         if yPos == 1 and xPos >= 46 then
  812.             page = 16
  813.         elseif lem and yPos >= 3 and isEdit(xPos) then
  814.             if listofnames[yPos - 3] then
  815.                 page = 17
  816.                 local nameclicked = yPos - 3
  817.                 subject = listofnames[nameclicked]
  818.             end
  819.         elseif lem and yPos >= 3 and isSend(xPos) then
  820.             if listofnames[yPos - 3] then
  821.                 page = 18
  822.                 local nameclicked = yPos - 3
  823.                 subject = listofnames[nameclicked]
  824.             end
  825.         end
  826.     end
  827.   elseif page == 8 then
  828.     if yPos == 3 and xPos >= 19 and xPos <= 30 then
  829.       page = 9
  830.     end
  831.     if yPos == 3 and xPos >= 35 and xPos <= 47 then
  832.       page = 16
  833.     end
  834.     if yPos == 4 and xPos >= 35 and xPos <= 47 then
  835.       --page = 18
  836.     end
  837.     if yPos == 4 and xPos >= 19 and xPos <= 29 then
  838.       page = 13
  839.     end
  840.   elseif page == 18 then
  841.         if yPos == 5 and xPos >= 30 then
  842.       term.setCursorPos(30,5)
  843.       term.write("                           ")
  844.       term.setCursorPos(30,5)
  845.       maxspace = read():lower()
  846.       term.setCursorPos(19,7)
  847.       pagespace = readURL(readconfig("syncnode").."?name_transfer&pkey="..masterkey.."&name="..subject.."&q="..maxspace)
  848.             if pagespace == "Success" then
  849.             end
  850.                 term.write("Name transferred")
  851.                 log("Tried sending a name to "..maxspace)
  852.                 os.sleep(3)
  853.                 page = 15
  854.         end
  855.   elseif page == 16 then
  856.     if yPos == 4 and xPos >= 25 then
  857.       term.setCursorPos(25,4)
  858.       term.write("                           ")
  859.       term.setCursorPos(25,4)
  860.       name = read():lower():gsub(".kst",""):gsub(" ","")
  861.       term.setCursorPos(25,4)
  862.       term.write("Please wait...             ")
  863.       if string.len(name) > 0 then
  864.         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
  865.           availability = 0
  866.         else
  867.           availability = tonumber(readURL(readconfig("syncnode").."?name_check="..name))
  868.           log("Checked "..name..".kst for availability ("..availability..")")
  869.           term.setCursorPos(19,7)
  870.           if availability then
  871.             term.setTextColor(colors.green)
  872.             term.write("Available!")
  873.           else
  874.             term.setTextColor(colors.red)
  875.             term.write("Not available!")
  876.           end
  877.         end
  878.       else
  879.         name = ""
  880.       end
  881.     elseif yPos == 7 and xPos >= 30 and xPos <= 39 and availability == 1 and balance >= 500 then
  882.       availability = 2
  883.       local k = readURL(readconfig("syncnode").."?name_new&pkey="..masterkey.."&name="..name)
  884.     end
  885.   elseif page == 17 then
  886.     if yPos == 5 and xPos >= 25 then
  887.       term.setCursorPos(25,5)
  888.       term.write("                           ")
  889.       term.setCursorPos(25,5)
  890.       zone = read():gsub("http://","")
  891.       term.setCursorPos(25,5)
  892.       term.write("Please wait...             ")
  893.       local sevenminutesleftuntilmaystartsfuckihavetoreleasethisnow = readURL(readconfig("syncnode").."?name_update&pkey="..masterkey.."&name="..subject.."&ar="..zone)
  894.     elseif yPos == 7 and xPos >= 30 and xPos <= 39 and availability == 1 and balance >= 500 then
  895.       availability = 2
  896.       local k = readURL(readconfig("syncnode").."?name_new&pkey="..masterkey.."&name="..name)
  897.     end
  898.   elseif page == 9 then
  899.     if yPos == 4 and xPos >= 30 then
  900.       term.setCursorPos(30,4)
  901.       term.write("                      ")
  902.       term.setCursorPos(30,4)
  903.       doublekey = read("*")
  904.       term.setCursorPos(30,4)
  905.       term.write("Please wait...        ")
  906.       if string.len(doublekey) > 0 then
  907.         doublekey = sha256(masterkey.."-"..sha256(doublekey))
  908.         addressdv = makev2address(doublekey)
  909.         balance2 = tonumber(readURL(readconfig("syncnode").."?getbalance="..addressdv))
  910.         log("Derived double vault "..addressdv)
  911.       else
  912.         addressdv = ""
  913.         balance2 = 0
  914.       end
  915.     end
  916.     if yPos == 5 and xPos >= 33 then
  917.       term.setCursorPos(33,5)
  918.       term.write("                      ")
  919.       term.setCursorPos(33,5)
  920.       amt = read()
  921.       if tonumber(amt) == nil then
  922.         amt = 0
  923.       elseif tonumber(amt) % 1 ~= 0 then
  924.         amt = 0
  925.       elseif tonumber(amt) <= 0 then
  926.         amt = 0
  927.       end
  928.     end
  929.     if yPos == 6 and xPos >= 25 and xPos <= 33 then
  930.       if tonumber(amt) > 0 and string.len(doublekey) > 0 then
  931.         if tonumber(amt) <= balance then
  932.           local transaction = readURL(readconfig("syncnode").."?pushtx2&q="..addressdv.."&pkey="..masterkey.."&amt="..tonumber(amt))
  933.           balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  934.           balance2 = tonumber(readURL(readconfig("syncnode").."?getbalance="..addressdv))
  935.           log("Put "..amt.." KST in a double vault")
  936.         end
  937.       end
  938.     end
  939.     if yPos == 6 and xPos >= 35 and xPos <= 44 then
  940.       if tonumber(amt) > 0 and string.len(doublekey) > 0 then
  941.         if tonumber(amt) <= balance2 then
  942.           local transaction = readURL(readconfig("syncnode").."?pushtx2&q="..address.."&pkey="..doublekey.."&amt="..tonumber(amt))
  943.           balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  944.           balance2 = tonumber(readURL(readconfig("syncnode").."?getbalance="..addressdv))
  945.           log("Took "..amt.." KST from a double vault")
  946.         end
  947.       end
  948.     end
  949.   elseif page == 13 then
  950.     if yPos == 5 and xPos >= 33 then
  951.       term.setCursorPos(33,5)
  952.       term.write("                      ")
  953.       term.setCursorPos(33,5)
  954.       term.setTextColor(32768)
  955.       amt = read()
  956.       if tonumber(amt) == nil then
  957.         amt = 0
  958.       elseif tonumber(amt) % 1 ~= 0 then
  959.         amt = 0
  960.       elseif tonumber(amt) <= 0 then
  961.         amt = 0
  962.       end
  963.     end
  964.     if yPos == 6 and xPos >= 25 and xPos <= 33 then
  965.       if tonumber(amt) > 0 then
  966.         if tonumber(amt) <= balance then
  967.           local transaction = readURL(readconfig("syncnode").."?pushtx2&q="..addresslv.."&pkey="..masterkey.."&amt="..tonumber(amt))
  968.           balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  969.           log("Put "..amt.." KST in a local vault")
  970.         end
  971.       end
  972.     end
  973.     if yPos == 6 and xPos >= 35 and xPos <= 44 then
  974.       if tonumber(amt) > 0 then
  975.         if tonumber(amt) <= balance3 then
  976.           local transaction = readURL(readconfig("syncnode").."?pushtx2&q="..address.."&pkey="..readconfig("keyLV").."&amt="..tonumber(amt))
  977.           balance = tonumber(readURL(readconfig("syncnode").."?getbalance="..address))
  978.           log("Took "..amt.." KST from a local vault")
  979.         end
  980.       end
  981.     end
  982.   end
  983.   if pagebefore ~= page then log("Switched to page "..page) end
  984. end
  985. local function drawTab(text)
  986.   term.setBackgroundColor(512)
  987.   term.write(text)
  988. end
  989. local function drawBtn(text)
  990.   term.setBackgroundColor(32)
  991.   term.write(text)
  992. end
  993. function hud()
  994.   term.setBackgroundColor(1)
  995.   term.setTextColor(32768)
  996.   term.clear()
  997.   if gui == 1 then
  998.     local sidebar = 1
  999.     while sidebar < 51 do
  1000.       term.setCursorPos(1,sidebar)
  1001.       term.setBackgroundColor(8)
  1002.       term.write("                ")
  1003.       sidebar = sidebar + 1
  1004.     end
  1005.     term.setCursorPos(2,2)
  1006.     drawKrist()
  1007.     term.setBackgroundColor(8)
  1008.     term.setTextColor(32768)
  1009.     term.write(" KristWallet")
  1010.     term.setCursorPos(5,3)
  1011.     term.setTextColor(2048)
  1012.     term.write("release "..version.."")
  1013.     term.setCursorPos(2,19)
  1014.     term.write("    by 3d6")
  1015.     term.setTextColor(32768)
  1016.     term.setCursorPos(3,5)
  1017.     drawTab("  Overview  ")
  1018.     term.setCursorPos(3,7)
  1019.     drawTab("Transactions")
  1020.     term.setCursorPos(3,9)
  1021.     drawTab(" Send Krist ")
  1022.     term.setCursorPos(3,11)
  1023.     drawTab(" Special TX ")
  1024.     term.setCursorPos(3,13)
  1025.     drawTab(" Economicon ")
  1026.     term.setCursorPos(3,15)
  1027.     drawTab("Name Manager")
  1028.     term.setCursorPos(3,17)
  1029.     drawTab("    Exit    ")
  1030.     term.setBackgroundColor(1)
  1031.   elseif gui == 2 then
  1032.     term.setCursorPos(1,1)
  1033.     term.setBackgroundColor(8)
  1034.     term.write("                          ")
  1035.     term.setCursorPos(1,2)
  1036.     term.write("                          ")
  1037.     term.setCursorPos(1,3)
  1038.     term.write("                          ")
  1039.     term.setCursorPos(1,4)
  1040.     term.write("                          ")
  1041.     term.setCursorPos(2,2)
  1042.     drawKrist()
  1043.     term.setBackgroundColor(8)
  1044.     term.setTextColor(32768)
  1045.     term.write(" KristWallet")
  1046.     term.setCursorPos(5,3)
  1047.     term.setTextColor(2048)
  1048.     term.write("release "..version.."")
  1049.     term.setCursorPos(19,2)
  1050.     term.setBackgroundColor(16384)
  1051.     term.setTextColor(32768)
  1052.     term.write(" Exit ")
  1053.   end
  1054.   if page == 1 then
  1055.     term.setCursorPos(19,2)
  1056.     term.write("Your address: ")
  1057.     term.setTextColor(16384)
  1058.     term.write(address)
  1059.     term.setTextColor(32768)
  1060.     term.setCursorPos(19,5)
  1061.     local recenttransactions = ""
  1062.     if tostring(balance) ~= 'nil' then recenttransactions = readURL(readconfig("syncnode").."?listtx="..address.."&overview") end
  1063.     local txtype = 0
  1064.     local graphics = 0
  1065.     if string.len(recenttransactions) > 25 then
  1066.       repeat
  1067.         if string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == "N/A(Mined)" then txtype = 1
  1068.         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
  1069.         elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) == 0 then txtype = 9
  1070.         elseif string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == "N/A(Names)" then txtype = 6
  1071.         elseif string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == address then txtype = 4
  1072.         elseif string.sub(recenttransactions,13+(31*graphics),22+(31*graphics)) == addressv1 then txtype = 5
  1073.         elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) < 0 then txtype = 2
  1074.         elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) > 0 then txtype = 3
  1075.         else txtype = 8
  1076.         end
  1077.         postgraphic(19,5+(5*graphics),txtype)
  1078.         term.setCursorPos(26,5+(5*graphics))
  1079.         term.setBackgroundColor(1)
  1080.         term.setTextColor(32768)
  1081.         if txtype == 1 then term.write("Mined")
  1082.         elseif txtype == 2 then term.write("Sent")
  1083.         elseif txtype == 3 then term.write("Received")
  1084.         elseif txtype == 4 then term.write("Sent to yourself")
  1085.         elseif txtype == 5 then term.write("Imported")
  1086.         elseif txtype == 6 then term.write("Name registered")
  1087.         elseif txtype == 7 then term.write("Name operation")
  1088.         elseif txtype == 8 then term.write("Unknown")
  1089.         elseif txtype == 9 then term.write("Name transfer")
  1090.         end
  1091.         term.setCursorPos(26,6+(5*graphics))
  1092.         if txtype == 4 then
  1093.           term.setTextColor(32768)
  1094.         elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) > 0 then
  1095.           term.setTextColor(8192)
  1096.           term.write("+")
  1097.         elseif tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics))) == 0 then
  1098.           term.setTextColor(16)
  1099.         else
  1100.           term.setTextColor(16384)
  1101.         end
  1102.         if txtype < 7 then term.write(tostring(tonumber(string.sub(recenttransactions,23+(31*graphics),31+(31*graphics)))).." KST") end
  1103.         term.setCursorPos(26,7+(5*graphics))
  1104.         term.setTextColor(32768)
  1105.         if txtype ~= 6 then term.setTextColor(512) end
  1106.         if txtype == 9 or (txtype > 1 and txtype < 6) then term.write(string.sub(recenttransactions,13+(31*graphics),22+(31*graphics))) end
  1107.         --if txtype == 6 then term.write(".kst") end
  1108.         term.setCursorPos(26,8+(5*graphics))
  1109.         term.setTextColor(128)
  1110.         term.write(string.sub(recenttransactions,1+(31*graphics),12+(31*graphics)))
  1111.         graphics = graphics + 1
  1112.       until graphics >= math.floor(string.len(recenttransactions)/32)
  1113.     end
  1114.     term.setTextColor(32768)
  1115.     term.setCursorPos(19,3)
  1116.     term.write("Your balance: ")
  1117.     term.setTextColor(1024)
  1118.     if tostring(balance) == 'nil' then balance = 0 end
  1119.     term.write(tostring(balance).." KST ")
  1120.     term.setTextColor(512)
  1121.     local names = tonumber(readURL(readconfig("syncnode").."?getnames="..address))
  1122.     if names > 0 then term.write("["..tostring(names).."]") end
  1123.     if address == "ke3kjplzsz" or address == "767fc628a4" or address == "e3b0c44298" then
  1124.       term.setCursorPos(1,1)
  1125.       term.setBackgroundColor(16384)
  1126.       term.setTextColor(16)
  1127.       term.clearLine()
  1128.       term.write("You are currently using a blank string password.")
  1129.     end
  1130.   elseif page == 2 then
  1131.     term.setCursorPos(18,1)
  1132.     term.write("Please wait...")
  1133.     os.sleep(0)
  1134.     subbal = readURL(readconfig("syncnode").."?getbalance="..subject)
  1135.     subtxs = readURL(readconfig("syncnode").."?listtx="..subject)
  1136.     log("Loaded transactions for address "..subject)
  1137.     log("Page index is "..scroll)
  1138.     term.setCursorPos(18,1)
  1139.     if subtxs == "end" then subbal = 0 end
  1140.     term.write("ADDRESS "..subject.." - "..subbal.." KST")
  1141.     term.setCursorPos(17,2)
  1142.     term.setBackgroundColor(256)
  1143.     term.write(" Time         Peer           Value ")
  1144.     term.setBackgroundColor(1)
  1145.     if subtxs ~= "end" then
  1146.       local tx = 0
  1147.       local s = 0
  1148.       ar = 16*scroll
  1149.       repeat
  1150.         tx = tx + 1
  1151.         stdate[tx] = string.sub(subtxs,1,12)
  1152.         subtxs = string.sub(subtxs,13)
  1153.         stpeer[tx] = string.sub(subtxs,1,10)
  1154.         subtxs = string.sub(subtxs,11)
  1155.         stval[tx] = tonumber(string.sub(subtxs,1,9))
  1156.         subtxs = string.sub(subtxs,10)
  1157.         if stpeer[tx] == subject then stval[tx] = 0 end
  1158.       until string.len(subtxs) == 3
  1159.       repeat
  1160.         ar = ar + 1
  1161.         term.setTextColor(32768)
  1162.         term.setCursorPos(18,2+ar-(16*(scroll)))
  1163.         term.write(stdate[ar])
  1164.         if stpeer[ar] ~= "N/A(Mined)" then term.setTextColor(512) end
  1165.         if stpeer[ar] == subject then term.setTextColor(32768) end
  1166.         if stpeer[ar] == "N/A(Names)" then term.setTextColor(32768) end
  1167.         term.setCursorPos(31,2+ar-(16*(scroll)))
  1168.         term.write(stpeer[ar])
  1169.         term.setCursorPos(50-string.len(tostring(math.abs(stval[ar]))),2+ar-(16*(scroll)))
  1170.         if stval[ar] > 0 then
  1171.           term.setTextColor(8192)
  1172.           term.write("+")
  1173.         elseif stval[ar] < 0 then
  1174.           term.setTextColor(16384)
  1175.         else
  1176.           term.setTextColor(32768)
  1177.           term.write(" ")
  1178.         end
  1179.         term.write(tostring(stval[ar]))
  1180.       until ar == math.min(tx,16*(scroll+1))
  1181.       term.setBackgroundColor(256)
  1182.       term.setCursorPos(17,19)
  1183.       term.write("                                   ")
  1184.       term.setCursorPos(17,19)
  1185.       term.setTextColor(32768)
  1186.       lastpage = math.floor((tx-1)/16)
  1187.       if (1+lastpage) < 100 then maxspace = maxspace.." " end
  1188.       if (1+lastpage) < 10 then maxspace = maxspace.." " end
  1189.       if (1+scroll) < 100 then pagespace = pagespace.." " end
  1190.       if (1+scroll) < 10 then pagespace = pagespace.." " end
  1191.       term.write(" Page "..pagespace..(1+scroll).."/"..maxspace..(1+lastpage))
  1192.       pagespace = ""
  1193.       maxspace = ""
  1194.       term.setCursorPos(32,19)
  1195.       term.setTextColor(128)
  1196.       term.write("First Prev Next Last")
  1197.       if (scroll > 0) then
  1198.         term.setCursorPos(32,19)
  1199.         term.setTextColor(2048)
  1200.         term.write("First Prev")
  1201.       end
  1202.       if (scroll < lastpage and tx > 16) then
  1203.         term.setCursorPos(43,19)
  1204.         term.setTextColor(2048)
  1205.         term.write("Next Last")
  1206.       end
  1207.     else
  1208.       term.write("No transactions to display!")
  1209.       term.setBackgroundColor(256)
  1210.       term.setCursorPos(17,19)
  1211.       term.write("                                   ")
  1212.       term.setCursorPos(17,19)
  1213.       term.setTextColor(32768)
  1214.       term.write(" Page   1/  1")
  1215.       term.setCursorPos(32,19)
  1216.       term.setTextColor(128)
  1217.       term.write("First Prev Next Last")
  1218.     end
  1219.   elseif page == 3 then
  1220.     term.setCursorPos(19,2)
  1221.     term.write("Your address: ")
  1222.     term.setTextColor(16384)
  1223.     term.write(address)
  1224.     term.setTextColor(32768)
  1225.     term.setCursorPos(19,3)
  1226.     term.write("Your balance: ")
  1227.     term.setTextColor(1024)
  1228.     if tostring(balance) == 'nil' then balance = 0 end
  1229.     term.write(tostring(balance).." KST")
  1230.     term.setTextColor(32768)
  1231.     term.setCursorPos(19,5)
  1232.     term.write("Recipient:    ")
  1233.     term.write("                   ")
  1234.     term.setCursorPos(19,6)
  1235.     term.write("Amount (KST): ")
  1236.     term.write("                   ")
  1237.   elseif page == 4 then
  1238.     term.setCursorPos(19,2)
  1239.     term.write("Mining          Addresses")
  1240.     term.setTextColor(512)
  1241.     term.setCursorPos(19,3)
  1242.     term.write("Latest blocks   Address lookup")
  1243.     term.setCursorPos(19,4)
  1244.     term.write("Lowest hashes   Top balances")
  1245.     term.setCursorPos(19,5)
  1246.     --term.write("Lowest nonces   ")
  1247.     term.setTextColor(32768)
  1248.     term.setCursorPos(19,7)
  1249.     --term.write("Economy         Transactions")
  1250.     term.setTextColor(512)
  1251.     term.setCursorPos(19,8)
  1252.     --term.write("KST issuance    Latest transfers")
  1253.     term.setCursorPos(19,9)
  1254.     --term.write("KST distrib.    Largest transfers")
  1255.   elseif page == 5 then
  1256.     local blocks = readURL(readconfig("syncnode").."?blocks")
  1257.     local tx = 0
  1258.     ar = 0
  1259.     local height = string.sub(blocks,1,8)
  1260.     local blktime = {}
  1261.     blkpeer = {}
  1262.     local blkhash = {}
  1263.     height = tonumber(string.sub(blocks,1,8))
  1264.     blocks = string.sub(blocks,9)
  1265.     local today = string.sub(blocks,1,10)
  1266.     blocks = string.sub(blocks,11)
  1267.     repeat
  1268.       tx = tx + 1
  1269.       blktime[tx] = string.sub(blocks,1,8)
  1270.       blocks = string.sub(blocks,9)
  1271.       blkpeer[tx] = string.sub(blocks,1,10)
  1272.       blocks = string.sub(blocks,11)
  1273.       blkhash[tx] = string.sub(blocks,1,12)
  1274.       blocks = string.sub(blocks,13)
  1275.       if stpeer[tx] == subject then stval[tx] = 0 end
  1276.     until string.len(blocks) == 0
  1277.     term.setCursorPos(18,1)
  1278.     term.write("Height: "..tostring(height))
  1279.     term.setCursorPos(36,1)
  1280.     term.write("Date: "..today)
  1281.     term.setCursorPos(17,2)
  1282.     term.setBackgroundColor(256)
  1283.     term.write(" Time     Miner      Hash          ")
  1284.     ----------(" 00:00:00 0000000000 000000000000 ")
  1285.     term.setBackgroundColor(1)
  1286.     repeat
  1287.       ar = ar + 1
  1288.       term.setCursorPos(18,2+ar)
  1289.       term.write(blktime[ar])
  1290.       if blkpeer[ar] ~= "N/A(Burnt)" then term.setTextColor(512) end
  1291.       term.setCursorPos(27,2+ar)
  1292.       term.write(blkpeer[ar])
  1293.       term.setTextColor(32768)
  1294.       term.setCursorPos(38,2+ar)
  1295.       term.write(blkhash[ar])
  1296.     until ar == math.min(tx,17*(scroll+1))
  1297.   elseif page == 6 then
  1298.     term.setCursorPos(17,2)
  1299.     term.setBackgroundColor(256)
  1300.     term.write(" Time         Peer           Value ")
  1301.     term.setBackgroundColor(256)
  1302.     term.setCursorPos(17,19)
  1303.     term.write("                                   ")
  1304.     term.setCursorPos(17,19)
  1305.     term.setTextColor(32768)
  1306.     term.write(" Page    /")
  1307.     term.setCursorPos(32,19)
  1308.     term.setTextColor(128)
  1309.     term.write("First Prev Next Last")
  1310.     term.setBackgroundColor(1)
  1311.     term.setCursorPos(18,1)
  1312.     term.write("ADDRESS (click to edit)")
  1313.   elseif page == 7 then
  1314.     local blocks = readURL(readconfig("syncnode").."?richapi")
  1315.     local tx = 0
  1316.     ar = 0
  1317.     local height = string.sub(blocks,1,8)
  1318.     local blktime = {}
  1319.     blkpeer = {}
  1320.     local blkhash = {}
  1321.     repeat
  1322.       tx = tx + 1
  1323.       blkpeer[tx] = string.sub(blocks,1,10)
  1324.       blocks = string.sub(blocks,11)
  1325.       blktime[tx] = tonumber(string.sub(blocks,1,8))
  1326.       blocks = string.sub(blocks,9)
  1327.       blkhash[tx] = string.sub(blocks,1,11)
  1328.       blocks = string.sub(blocks,12)
  1329.     until string.len(blocks) == 0
  1330.     term.setCursorPos(18,1)
  1331.     term.write("Krist address rich list")
  1332.     term.setCursorPos(17,2)
  1333.     term.setBackgroundColor(256)
  1334.     term.write("R# Address     Balance First seen  ")
  1335.     term.setBackgroundColor(1)
  1336.     repeat
  1337.       ar = ar + 1
  1338.       term.setCursorPos(17,2+ar)
  1339.       if ar < 10 then term.write(" ") end
  1340.       term.write(ar)
  1341.       term.setCursorPos(20,2+ar)
  1342.       if blkpeer[ar] ~= "N/A(Burnt)" then term.setTextColor(512) end
  1343.       term.write(blkpeer[ar])
  1344.       term.setTextColor(32768)
  1345.       term.setCursorPos(39-string.len(tostring(math.abs(blktime[ar]))),2+ar)
  1346.       term.write(blktime[ar])
  1347.       term.setCursorPos(40,2+ar)
  1348.       term.write(blkhash[ar])
  1349.     until ar == 16
  1350.   elseif page == 8 then
  1351.     term.setCursorPos(19,2)
  1352.     term.write("Storage         Names")
  1353.     term.setTextColor(512)
  1354.     term.setCursorPos(19,3)
  1355.     term.write("Double vault    Register name")
  1356.     term.setCursorPos(19,4)
  1357.     term.write("Local vault")
  1358.     term.setCursorPos(19,5)
  1359.     --term.write("Disk vault      v1 SHA vault")
  1360.     term.setCursorPos(19,6)
  1361.     --term.write("SHA vault       v1 wallet")
  1362.   elseif page == 9 then
  1363.     term.setCursorPos(25,2)
  1364.     term.write("Double vault manager")
  1365.     term.setCursorPos(19,8)
  1366.     term.write("Using double vaults is a way to")
  1367.     term.setCursorPos(19,9)
  1368.     term.write("store your Krist under an extra")
  1369.     term.setCursorPos(19,10)
  1370.     term.write("layer of security. You can only")
  1371.     term.setCursorPos(19,11)
  1372.     term.write("access a double vault from your")
  1373.     term.setCursorPos(19,12)
  1374.     term.write("wallet (on any server) and then")
  1375.     term.setCursorPos(19,13)
  1376.     term.write("only after typing an extra pass")
  1377.     term.setCursorPos(19,14)
  1378.     term.write("code. Double wallets are wholly")
  1379.     term.setCursorPos(19,15)
  1380.     term.write("invisible to unauthorized users")
  1381.     term.setCursorPos(19,16)
  1382.     term.write("of your wallet; they can not be")
  1383.     term.setCursorPos(19,17)
  1384.     term.write("seen or opened without the pass")
  1385.     term.setCursorPos(19,18)
  1386.     term.write("code set by you.")
  1387.     term.setCursorPos(19,4)
  1388.     term.write("Pass code: ")
  1389.     term.setCursorPos(19,5)
  1390.     term.write("Amount (KST): ")
  1391.     term.setCursorPos(30,4)
  1392.     if string.len(doublekey) == 0 then
  1393.       term.setTextColor(256)
  1394.       term.write("(click to set)")
  1395.     else
  1396.       term.setTextColor(8192)
  1397.       term.write("Ready: "..balance2.." KST")
  1398.       if tonumber(amt) > 0 then
  1399.         term.setCursorPos(25,6)
  1400.         term.setTextColor(32768)
  1401.         term.setBackgroundColor(128)
  1402.         if tonumber(amt) <= balance then
  1403.           term.setBackgroundColor(2)
  1404.         end
  1405.         term.write(" Deposit ")
  1406.         term.setBackgroundColor(1)
  1407.         term.write(" ")
  1408.         term.setBackgroundColor(128)
  1409.         if tonumber(amt) <= balance2 then
  1410.           term.setBackgroundColor(2)
  1411.         end
  1412.         term.write(" Withdraw ")
  1413.         term.setBackgroundColor(1)
  1414.       end
  1415.     end
  1416.     term.setCursorPos(33,5)
  1417.     if amt == 0 then
  1418.       term.setTextColor(256)
  1419.       term.write("(click to set)")
  1420.     else
  1421.       term.setTextColor(32768)
  1422.       term.write(amt)
  1423.     end
  1424.     term.setTextColor(32768)
  1425.   elseif page == 10 then
  1426.     local blocks = readURL(readconfig("syncnode").."?blocks&low")
  1427.     local tx = 0
  1428.     ar = 0
  1429.     local blktime = {}
  1430.     blkpeer = {}
  1431.     local blkhash = {}
  1432.     repeat
  1433.       tx = tx + 1
  1434.       blktime[tx] = string.sub(blocks,1,6)
  1435.       blocks = string.sub(blocks,7)
  1436.       blkpeer[tx] = string.sub(blocks,1,6)
  1437.       blocks = string.sub(blocks,7)
  1438.       blkhash[tx] = string.sub(blocks,1,20)
  1439.       blocks = string.sub(blocks,21)
  1440.     until string.len(blocks) == 0
  1441.     term.setCursorPos(17,1)
  1442.     term.setBackgroundColor(256)
  1443.     term.write(" Date   Block# Hash                ")
  1444.     ----------(" Feb 28 000000 000000000000oooooooo")
  1445.     term.setBackgroundColor(1)
  1446.     repeat
  1447.       ar = ar + 1
  1448.       term.setCursorPos(18,1+ar)
  1449.       term.write(blktime[ar])
  1450.       term.setCursorPos(31-string.len(tostring(math.abs(tonumber(blkpeer[ar])))),1+ar)
  1451.       term.write(tonumber(blkpeer[ar]))
  1452.       term.setTextColor(256)
  1453.       term.setCursorPos(32,1+ar)
  1454.       term.write(blkhash[ar])
  1455.       term.setTextColor(32768)
  1456.       term.setCursorPos(32,1+ar)
  1457.       term.write(string.sub(blkhash[ar],1,12))
  1458.     until ar == math.min(tx,18)
  1459.   elseif page == 11 then
  1460.     local blocks = readURL(readconfig("syncnode").."?blocks&low&lownonce")
  1461.     local tx = 0
  1462.     ar = 0
  1463.     local blktime = {}
  1464.     blkpeer = {}
  1465.     local blkhash = {}
  1466.     repeat
  1467.       tx = tx + 1
  1468.       blktime[tx] = string.sub(blocks,1,6)
  1469.       blocks = string.sub(blocks,7)
  1470.       blkpeer[tx] = string.sub(blocks,1,6)
  1471.       blocks = string.sub(blocks,7)
  1472.       blkhash[tx] = string.sub(blocks,1,12)
  1473.       blocks = string.sub(blocks,13)
  1474.     until string.len(blocks) == 0
  1475.     term.setCursorPos(17,1)
  1476.     term.setBackgroundColor(256)
  1477.     term.write(" Date   Block# Nonce               ")
  1478.     ----------(" Feb 28 000000 000000000000")
  1479.     term.setBackgroundColor(1)
  1480.     repeat
  1481.       ar = ar + 1
  1482.       term.setCursorPos(18,1+ar)
  1483.       term.write(blktime[ar])
  1484.       term.setCursorPos(31-string.len(tostring(math.abs(tonumber(blkpeer[ar])))),1+ar)
  1485.       term.write(tonumber(blkpeer[ar]))
  1486.       term.setTextColor(32768)
  1487.       term.setCursorPos(32,1+ar)
  1488.       term.write(tonumber(blkhash[ar]))
  1489.     until ar == math.min(tx,18)
  1490.   elseif page == 12 then
  1491.     local blocks = readURL(readconfig("syncnode").."?blocks&low&highnonce")
  1492.     local tx = 0
  1493.     ar = 0
  1494.     local blktime = {}
  1495.     blkpeer = {}
  1496.     local blkhash = {}
  1497.     repeat
  1498.       tx = tx + 1
  1499.       blktime[tx] = string.sub(blocks,1,6)
  1500.       blocks = string.sub(blocks,7)
  1501.       blkpeer[tx] = string.sub(blocks,1,6)
  1502.       blocks = string.sub(blocks,7)
  1503.       blkhash[tx] = string.sub(blocks,1,12)
  1504.       blocks = string.sub(blocks,13)
  1505.     until string.len(blocks) == 0
  1506.     term.setCursorPos(17,1)
  1507.     term.setBackgroundColor(256)
  1508.     term.write(" Date   Block# Nonce               ")
  1509.     ----------(" Feb 28 000000 000000000000")
  1510.     term.setBackgroundColor(1)
  1511.     repeat
  1512.       ar = ar + 1
  1513.       term.setCursorPos(18,1+ar)
  1514.       term.write(blktime[ar])
  1515.       term.setCursorPos(31-string.len(tostring(math.abs(tonumber(blkpeer[ar])))),1+ar)
  1516.       term.write(tonumber(blkpeer[ar]))
  1517.       term.setTextColor(32768)
  1518.       term.setCursorPos(32,1+ar)
  1519.       term.write(tonumber(blkhash[ar]))
  1520.     until ar == math.min(tx,18)
  1521.   elseif page == 13 then
  1522.     balance3 = tonumber(readURL(readconfig("syncnode").."?getbalance="..addresslv))
  1523.     term.setCursorPos(25,2)
  1524.     term.write("Local vault manager")
  1525.     term.setCursorPos(19,8)
  1526.     term.write("Local vaults are a place to put")
  1527.     term.setCursorPos(19,9)
  1528.     term.write("Krist in the form of a file on")
  1529.     term.setCursorPos(19,10)
  1530.     term.write("a computer. Unlike traditional")
  1531.     term.setCursorPos(19,11)
  1532.     term.write("wallets, local vaults can only")
  1533.     term.setCursorPos(19,12)
  1534.     term.write("be accessed on the computer")
  1535.     term.setCursorPos(19,13)
  1536.     term.write("they were initially created on.")
  1537.     term.setCursorPos(19,14)
  1538.     term.write("If you do this, please ensure")
  1539.     term.setCursorPos(19,15)
  1540.     term.write("that this computer is never")
  1541.     term.setCursorPos(19,16)
  1542.     term.write("stolen or broken, as your money")
  1543.     term.setCursorPos(19,17)
  1544.     term.write("may be lost if you don't have a")
  1545.     term.setCursorPos(19,18)
  1546.     term.write("backup.")
  1547.     term.setCursorPos(19,4)
  1548.     term.write("KST put here: "..balance3)
  1549.     term.setCursorPos(19,5)
  1550.     term.write("Amount (KST): ")
  1551.     term.setCursorPos(33,5)
  1552.     if amt == 0 then
  1553.       term.setTextColor(256)
  1554.       term.write("(click to set)")
  1555.     else
  1556.       term.setTextColor(32768)
  1557.       term.write(amt)
  1558.     end
  1559.     if tonumber(amt) > 0 then
  1560.       term.setCursorPos(25,6)
  1561.       term.setTextColor(32768)
  1562.       term.setBackgroundColor(128)
  1563.       if tonumber(amt) <= balance then
  1564.         term.setBackgroundColor(2)
  1565.       end
  1566.       term.write(" Deposit ")
  1567.       term.setBackgroundColor(1)
  1568.       term.write(" ")
  1569.       term.setBackgroundColor(128)
  1570.       if tonumber(amt) <= balance3 then
  1571.         term.setBackgroundColor(2)
  1572.       end
  1573.       term.write(" Withdraw ")
  1574.       term.setBackgroundColor(1)
  1575.     end
  1576.   elseif page == 14 then
  1577.     term.setBackgroundColor(1)
  1578.     term.setCursorPos(19,2)
  1579.     term.write("Local settings")
  1580.     --deprecated for now
  1581.   elseif page == 15 then
  1582.     term.setBackgroundColor(1)
  1583.     term.setCursorPos(18,1)
  1584.     term.write(".KST domain name manager     [New]")
  1585.     term.setCursorPos(46,1)
  1586.     term.setBackgroundColor(32)
  1587.     term.setTextColor(1)
  1588.     term.write(" + NEW")
  1589.     term.setCursorPos(17,2)
  1590.     term.setBackgroundColor(256)
  1591.     term.setTextColor(32768)
  1592.     term.write(" Name                 Actions      ")
  1593.     term.setBackgroundColor(1)
  1594.     term.setCursorPos(18,3)
  1595.     local namelist = readURL(readconfig("syncnode").."?listnames="..address)
  1596.     local splitname = split(namelist, ";")
  1597.    
  1598.  
  1599.     if #splitname == 0 then
  1600.       term.setTextColor(256)
  1601.       term.write("No names to display!")
  1602.     else
  1603.       local namecount = 1
  1604.       repeat
  1605.                 local thisname = splitname[namecount]
  1606.                 --namelist:sub(0,namelist:find(";")-1)
  1607.         term.setTextColor(32768)
  1608.         term.setCursorPos(18,3+namecount)
  1609.         term.write(splitname[namecount]..".kst")
  1610.         term.setCursorPos(39,3+namecount)
  1611.         term.setTextColor(512)
  1612.         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
  1613.         term.write("Edit Send ")
  1614.         term.setTextColor(256)
  1615.         term.write("Go")
  1616.         namecount = namecount + 1
  1617.       until namecount == #splitname+1
  1618.     end
  1619.     --term.write("a.kst                Edit Send Go")
  1620.     term.setBackgroundColor(1)
  1621.   elseif page == 16 then
  1622.     term.setBackgroundColor(1)
  1623.     term.setCursorPos(20,2)
  1624.     term.write(".KST domain name registration")
  1625.     term.setCursorPos(19,4)
  1626.     term.write("Name: ")
  1627.     if name == "" then
  1628.       term.setTextColor(colors.lightGray)
  1629.       term.write("(click to set)")
  1630.     else
  1631.       term.write(name)
  1632.       term.setTextColor(colors.lightGray)
  1633.       term.write(".kst")
  1634.     end
  1635.     term.setTextColor(colors.black)
  1636.     term.setCursorPos(19,5)
  1637.     term.write("Cost: 500 KST")
  1638.     term.setCursorPos(19,7)
  1639.     --term.write("Available! [Register]")
  1640.     if name == "" then
  1641.       term.setTextColor(colors.blue)
  1642.       term.write("Please select a name!")
  1643.     elseif availability == 1 then
  1644.       term.setTextColor(colors.green)
  1645.       term.write("Available! ")
  1646.       --if balance >= 500 then
  1647.         term.setBackgroundColor(colors.green)
  1648.         term.setTextColor(colors.lime)
  1649.         term.write(" Register ")
  1650.         term.setBackgroundColor(colors.white)
  1651.       --end
  1652.     elseif availability == 2 then
  1653.       term.setTextColor(colors.yellow)
  1654.       term.write("Name registered!")
  1655.     else
  1656.       term.setTextColor(colors.red)
  1657.       term.write("Not available!")
  1658.     end
  1659.     term.setTextColor(colors.black)
  1660.     term.setCursorPos(19,9)
  1661.     term.write(".KST domain names are used on")
  1662.     term.setCursorPos(19,10)
  1663.     term.write("the KristScape browser. For")
  1664.     term.setCursorPos(19,11)
  1665.     term.write("more information, please see")
  1666.     term.setCursorPos(19,12)
  1667.     term.write("the Krist thread.")
  1668.     term.setCursorPos(19,14)
  1669.     term.write("All Krist spent on names will")
  1670.     term.setCursorPos(19,15)
  1671.     term.write("be added to the value of")
  1672.     term.setCursorPos(19,16)
  1673.     term.write("future blocks; essentially")
  1674.     term.setCursorPos(19,17)
  1675.     term.write("being \"re-mined.\"")
  1676.   elseif page == 17 then
  1677.     term.setBackgroundColor(1)
  1678.     term.setCursorPos(28,2)
  1679.     term.write(".KST zone file")
  1680.     term.setCursorPos(19,4)
  1681.     term.write("Name: "..subject)
  1682.     term.setTextColor(colors.lightGray)
  1683.     term.write(".kst")
  1684.     term.setTextColor(colors.black)
  1685.     term.setCursorPos(19,7)
  1686.     term.write("Your name's zone file is the")
  1687.     term.setCursorPos(19,8)
  1688.     term.write("URL of the site it is pointing")
  1689.     term.setCursorPos(19,9)
  1690.     term.write("to. When KristScape navigates")
  1691.     term.setCursorPos(19,10)
  1692.     term.write("to a name, it will make an HTTP")
  1693.     term.setCursorPos(19,11)
  1694.     term.write("get request to the above URL.")
  1695.     term.setCursorPos(19,12)
  1696.     term.write("The zone record should not")
  1697.     term.setCursorPos(19,13)
  1698.     term.write("include a protocol (http://)")
  1699.     term.setCursorPos(19,14)
  1700.     term.write("and shouldn't end with a")
  1701.     term.setCursorPos(19,15)
  1702.     term.write("slash. You can redirect a name")
  1703.     term.setCursorPos(19,16)
  1704.     term.write("to another name by making the")
  1705.     term.setCursorPos(19,17)
  1706.     term.write("first character of the record")
  1707.     term.setCursorPos(19,18)
  1708.     term.write("a dollar sign; e.g. $krist.kst")
  1709.     term.setTextColor(colors.black)
  1710.     term.setCursorPos(19,5)
  1711.     term.write("Zone: ")
  1712.     zone = readURL(readconfig("syncnode").."?a="..subject)
  1713.     if zone == "" then
  1714.       term.setTextColor(colors.lightGray)
  1715.       term.write("(click to set)")
  1716.     else
  1717.       term.write(zone)
  1718.     end
  1719.   elseif page == 18 then
  1720.     term.setBackgroundColor(1)
  1721.     term.setCursorPos(28,2)
  1722.     term.write("Name transfer")
  1723.     term.setCursorPos(19,4)
  1724.     term.write("Name: "..subject)
  1725.     term.setTextColor(colors.lightGray)
  1726.     term.write(".kst")
  1727.     term.setTextColor(colors.black)
  1728.     term.setCursorPos(19,5)
  1729.     term.write("Recipient: ")
  1730.   elseif page == 21 then
  1731.     term.setBackgroundColor(1)
  1732.     term.setCursorPos(4,6)
  1733.     term.write("Address - ")
  1734.     term.setTextColor(16384)
  1735.     term.write(address)
  1736.     term.setTextColor(32768)
  1737.     term.setCursorPos(4,7)
  1738.     term.write("Balance - ")
  1739.     term.setTextColor(1024)
  1740.     if tostring(balance) == 'nil' then balance = 0 end
  1741.     term.write(tostring(balance).." KST")
  1742.     term.setTextColor(32768)
  1743.     term.setCursorPos(3,9)
  1744.   end
  1745. end
  1746. boot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement