blockchain = include_lib("/lib/blockchain.so") if not blockchain then exit("Error: Missing blockchain.so library in the /lib") YOUR_COIN = "coin" // edit this OWNER_WALLETS = ["lock", "000111"] // these are the users that can run the backend server if you edit it you need to match the it with back end DEFAULT_CREDENTIALS = "admin" // you may edit this too SUBWALLET_PREPEND = "sub" // this should match with the back end SUBWALLET_PASS = "123" // this should match with the back end 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") print("<b>to delete the coin created by this script in case you did interrupted the script</b>") print("coin_registration --reset wallet_id wallet_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 if params[0] == "--reset" and params.len == 3 then wallet = login_wallet(params[1], params[2]) for coin_name in wallet.list_global_coins out = blockchain.delete_coin(coin_name, DEFAULT_CREDENTIALS, DEFAULT_CREDENTIALS) print(out) end for exit 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(OWNER_WALLET) offers = wallet.get_global_offers(YOUR_COIN) //print(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 backend_active = [false] get_backend_status = function() for OWNER_WALLET in OWNER_WALLETS last_flag = get_owner_offer(OWNER_WALLET) for i in range(0, 5) wait(0.05) flag = get_owner_offer(OWNER_WALLET) if flag != last_flag then backend_active[0] = true break end if end for if backend_active[0] == true then break end for end function while true get_backend_status if backend_active[0] == false then print("<color=red>back end is off</color>") else print("<color=yellow>back end is running</color>") break end if end while // check if you have a subwallet already has_subwallet = function(wallet) out = wallet.buy_coin(YOUR_COIN, 1,99999) if out.indexOf("You need to be registered") != null then return false else return true end if wallet.cancel_pending_trade(YOUR_COIN) end function if has_subwallet(wallet) == true then print("<color=red>you already have a subwallet in this coin</color>") exit else end if // register if user_input("continue with the registration? [y/n]: ") == "n" then exit() pin = wallet.get_pin user = DEFAULT_CREDENTIALS pass = DEFAULT_CREDENTIALS print("created coin: " + pin + " " + user + " " + pass) 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) random_subwallet = str(floor(rnd * 99999)) out = coin.create_subwallet(wallet_id, pin, random_subwallet, "admin") if typeof(out) == "string" then exit(out) out = wallet.buy_coin(pin, 1, 1) print(wallet_id + " " + pin) if typeof(out) == "string" and out.indexOf("pending until") == null then exit(out) print("registration started do not kill the process") for i in range(0,10) wait(0.9) if has_subwallet(wallet) == true then print("<color=yellow>Account created sub_wallet_id: "+SUBWALLET_PREPEND+wallet_id+" password: "+SUBWALLET_PASS+"</color>") blockchain.delete_coin(pin,user,pass) exit end if end for print("<color=red>Account not created for some reason</color>") blockchain.delete_coin(pin,user,pass)