Files

front_end.src
  • blockchain = include_lib("/lib/blockchain.so")
  • if not blockchain then exit("Error: Missing blockchain.so library in the /lib")
  • print("WARNING: you should have a coin registered and a sub wallet too before using this script ")
  • print("if you dont you can pass the params '--setup coin_name coin_user coin_pass wallet_id wallet_pin' to create a coin and a subwallet or just the subwallet if the coins exists"+char(10))
  • if params.len == 0 then exit("registration_order wallet_id wallet_pass your_coin_name your_coin_user your_coin_password")
  • if params[0] == "--setup" then
  • coin = blockchain.get_coin(params[1], params[2], params[3])
  • if typeof(coin) != "coin" then
  • blockchain.create_coin(params[1], params[2], params[3])
  • coin = blockchain.get_coin(params[1], params[2], params[3])
  • end if
  • sub_wallet = [str(floor(99999 * rnd())), str(floor(99999 * rnd()))]
  • out = coin.create_subwallet(params[4], params[5], sub_wallet[0], sub_wallet[1])
  • print("user: "+sub_wallet[0])
  • print("pass: "+sub_wallet[1])
  • print("create subwallet out: "+out)
  • exit()
  • end if
  • wallet = login_wallet(params[0], params[1])
  • if typeof(wallet) == "string" then exit(wallet)
  • my_coin = blockchain.get_coin([params[2], params[3], params[4]])
  • if typeof(my_coin) == "string" then exit(my_coin)
  • my_coin_name = params[2]
  • wallet.cancel_pending_trade(my_coin_name)
  • pin_as_amount = ("1" + str(wallet.get_pin)).to_int
  • exit(pin_as_amount)
  • wallet.buy_coin(my_coin_name, pin, 0)
  • print(a)
frontEnd.src
  • blockchain = include_lib("/lib/blockchain.so")
  • if not blockchain then exit("Error: Missing blockchain.so library in the /lib")
  • YOUR_COIN = "1337coin" // edit this
  • OWNER_WALLET = "lock" // edit this
  • if params.len == 0 then
  • print("<b>this script requires the use of create coin you should delete your old coin, you can create it again later.</b>"+char(10))
  • print("<b>to register</b>")
  • print("coin_registration wallet_id wallet_pass")
  • print("<b>to delete your old coin</b>")
  • print("coin_registration --delete-my-old-coin coin_name coin_user coin_pass")
  • exit
  • end if
  • if params[0] == "--delete-my-old-coin" and params.len == 4 then
  • out = blockchain.delete_coin(params[1], params[2], params[3])
  • exit(out)
  • end if
  • wallet_id = params[0]
  • wallet_pass = params[1]
  • wallet = login_wallet(params[0], params[1])
  • if typeof(wallet) == "string" then exit(wallet)
  • // check for the back end
  • get_owner_offer = function()
  • offers = wallet.get_global_offers(YOUR_COIN)
  • if wallet.get_global_offers(YOUR_COIN).indexes.indexOf(OWNER_WALLET) == null then
  • return null
  • else
  • return offers[OWNER_WALLET][2]
  • end if
  • end function
  • last_flag = get_owner_offer
  • for i in range(0, 10)
  • wait(0.01)
  • flag = get_owner_offer
  • if flag != last_flag then break
  • if i == 10 then
  • exit("<color=red>back end is off</color>")
  • end if
  • end for
  • print("<color=yellow>back end is running</color>")
  • // register
  • if user_input("continue with the registration? [y/n]: ") == "n" then exit()
  • pin = wallet.get_pin
  • user = "admin"
  • pass = "admin"
  • out = blockchain.create_coin(pin, user, pass)
  • if typeof(out) == "string" then exit(out)
  • coin = blockchain.get_coin(pin, user, pass)
  • if typeof(coin) == "string" then exit(coin)
  • out = coin.create_subwallet(wallet_id, pin, "admin", "admin")
  • out = wallet.buy_coin(pin, 1, 1)
  • if typeof(out) == "string" and out.indexOf("pending until") == null then exit(out)
  • print("registration started do not kill the process")
  • wait(20)
  • blockchain.delete_coin(pin,user,pass)
  • print("registration finished")
backEnd.src
  • // you should have a sub wallet in your coin
  • blockchain = include_lib("/lib/blockchain.so")
  • if not blockchain then exit("Error: Missing blockchain.so library in the /lib")
  • wallet = login_wallet(params[0], params[1])
  • my_coin = blockchain.get_coin("1337coin", "Plu70", "w")
  • // set running flag
  • tick_control = false
  • tick = function()
  • if tick_control == true then
  • value = 999999
  • tick_control = false
  • else
  • value = 999998
  • tick_control = true
  • end if
  • wallet.cancel_pending_trade("1337coin")
  • out = wallet.sell_coin("1337coin", 1, value)
  • if typeof(out) == "string" and out.indexOf("pending until") == null then print(out)
  • wait(0.1)
  • wallet.cancel_pending_trade("1337coin")
  • tick
  • end function
  • // register users
  • while true
  • for coin_name in wallet.list_global_coins
  • tick
  • users = wallet.get_global_offers(coin_name).indexes
  • for user in users
  • out = my_coin.create_subwallet(user, coin_name, "sub"+user, "123")
  • if out == 1 then print("new account created: sub"+user+" 123")
  • end for
  • tick
  • end for
  • end while