Open main menu
Posts
Gists
Guilds
Users
Decipher
Docs
Open user menu
Log in
Sign up
Create a new gist
Posts
Gists
Guilds
Users
Decipher
Docs
Files
frontEnd.src
backEnd.src
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
OWNER_WALLET
S = [
"lock"
, "000111"] // you can edit this but it will break the script
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()
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
last_flag = get_owner_offer
for i in range(0,
10)
wait(0.0
1)
flag = get_owner_offer
if flag != last_flag then break
if i
==
10
then
exi
t("<color=red>back end is off</color>")
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.0
5)
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
prin
t("<color=red>back end is off</color>")
else
print("<color=yellow>back end is running</color>")
break
end if
end
for
print("<color=yellow>back end is running</color>")
end
while
// register
//
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
register
ed") != 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 =
"admin"
pass =
"admin"
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)
out = coin.create_subwallet(wallet_id, pin,
"admin"
, "admin")
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")
wait(
20
)
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)
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")
if params.len == 0 then exit("usage: backend wallet_id wallet_pass OR backend reset wallet_id wallet_pass")
my_coin = blockchain.get_coin("1337coin", "Plu70", "f")
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])
my_coin = blockchain.get_coin("1337coin", "Plu70", "w")
// set running flag
tick_control = false
tick_control =
[
false
]
tick = function()
if tick_control == true then
if tick_control
[0]
== true then
value = 999999
tick_control = false
tick_control
[0]
= false
else
value = 999998
tick_control = true
tick_control
[0]
= 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
)
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("1337coin")
tick
end function
// register users
while true
tick
for coin_name in wallet.list_global_coins
tick
users = wallet.get_global_offers(coin_name).indexes
for user in users
ou
t = my_coin.create_subwallet(user, coin_name,
"sub"
+user,
"123"
)
if
ou
t == 1 then
print("new account created: sub"+user+" 123")
for user in users
//if coin_name.len != 5 then continue
sub_walle
t = my_coin.create_subwallet(user, coin_name,
SUBWALLET_PREPEND
+user,
SUBWALLET_PASS
)
if
sub_walle
t == 1 then
print("new account created: sub"+user+" 123")
else
//print("<color=red>"+sub_wallet+"</color> "+user+" "+coin_name)
end if
end for
tick
end for
end while