// 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") if params.len == 0 then exit("usage: backend wallet_id wallet_pass OR backend reset wallet_id wallet_pass") my_coin = blockchain.get_coin("coin", "user", "pass") SUBWALLET_PREPEND = "sub" // this should match with the front end SUBWALLET_PASS = "123" // this should match with the front end // delete all the wallets if params[0] == "reset" then //for subwallet in my_coin.get_subwallets() //print(subwallet) //print(subwallet.get_info) //end for wallet = login_wallet(params[1], params[2]) my_coin.delete_subwallet(SUBWALLET_PREPEND+params[1]) my_coin.create_subwallet(params[1], wallet.get_pin, SUBWALLET_PREPEND+params[1], SUBWALLET_PASS) my_coin.get_subwallet(SUBWALLET_PREPEND+params[1]).add_coins(1) exit end if wallet = login_wallet(params[0], params[1]) // set running flag tick_control = [false] tick = function() if tick_control[0] == true then value = 999999 tick_control[0] = false else value = 999998 tick_control[0] = true end if wallet.cancel_pending_trade("coin") out = wallet.sell_coin("coin", 1, value) if typeof(out) == "string" and out.indexOf("pending until") == null then exit("<color=red>"+out+" you may use the reset param to setup</color>") wait(0.1) wallet.cancel_pending_trade("coin") end function // register users while true tick for coin_name in wallet.list_global_coins users = wallet.get_global_offers(coin_name).indexes for user in users //if coin_name.len != 5 then continue sub_wallet = my_coin.create_subwallet(user, coin_name, SUBWALLET_PREPEND+user, SUBWALLET_PASS) if sub_wallet == 1 then print("new account created: sub"+user+" 123") else //print("<color=red>"+sub_wallet+"</color> "+user+" "+coin_name) end if end for end for end while