Ejemplo n.º 1
0
def create_trashbag():
    kcl = kmd.KMDClient(params.kmd_token, params.kmd_address)
    acl = algod.AlgodClient(params.algod_token, params.algod_address)

    petitionWallet = "Petitions"
    petitionWalletPassword = "******"

    # get the wallet ID
    wallets = kcl.list_wallets()

    petitionWalletID = None
    for w in wallets:
        if w["name"] == petitionWallet:
            petitionWalletID = w["id"]
            break

    # if it doesn't exist, create the wallet and get its ID
    if not petitionWalletID:
        petitionWalletID = kcl.create_wallet(petitionWallet,
                                             petitionWalletPassword)["id"]

    # get a handle for the wallet
    handle = kcl.init_wallet_handle(petitionWalletID, petitionWalletPassword)
    # generate account with account and check if it's valid
    private_key_1, address_1 = account.generate_account()
    # import generated account into the wallet
    kcl.import_key(handle, private_key_1)
    """Creates trash bag account for all petitions."""
    petition = Petition(name="Trash Bag Account",
                        publicKey=address_1,
                        masterAccount=address_1,
                        yesCount=0)
    db.session.add(petition)
    db.session.commit()
Ejemplo n.º 2
0
def kmd_client(context):
    data_dir_path = os.environ["NODE_DIR"] + "/"
    kmd_folder_name = os.environ["KMD_DIR"] + "/"
    kmd_token = open(data_dir_path + kmd_folder_name + "kmd.token",
                     "r").read().strip("\n")
    kmd_address = "http://" + open(data_dir_path + kmd_folder_name + "kmd.net",
                                   "r").read().strip("\n")
    context.kcl = kmd.KMDClient(kmd_token, kmd_address)
Ejemplo n.º 3
0
def kmd_client(context):
    home = os.path.expanduser("~")
    data_dir_path = home + "/node/network/Node/"
    kmd_folder_name = os.environ["KMD_DIR"] + "/"
    kmd_token = open(data_dir_path + kmd_folder_name + "kmd.token",
                     "r").read().strip("\n")
    kmd_address = "http://" + open(data_dir_path + kmd_folder_name + "kmd.net",
                                   "r").read().strip("\n")
    context.kcl = kmd.KMDClient(kmd_token, kmd_address)
Ejemplo n.º 4
0
 def setUpClass(cls):
     cls.acl = algod.AlgodClient(params.algod_token, params.algod_address)
     cls.kcl = kmd.KMDClient(params.kmd_token, params.kmd_address)
     w = wallet.Wallet(wallet_name, wallet_pswd, cls.kcl)
     keys = w.list_keys()
     max_balance = 0
     cls.account_0 = ""
     for k in keys:
         account_info = cls.acl.account_info(k)
         if account_info["amount"] > max_balance:
             max_balance = account_info["amount"]
             cls.account_0 = k
Ejemplo n.º 5
0
# Example: using the Wallet class

import tokens
from algosdk import kmd
from algosdk.wallet import Wallet

# create a kmd client
kcl = kmd.KMDClient(tokens.kmd_token, tokens.kmd_address)

# create a wallet object
wallet = Wallet("wallet_name", "wallet_password", kcl)

# get wallet information
info = wallet.info()
print("Wallet name:", info["wallet"]["name"])

# create an account
address = wallet.generate_key()
print("New account:", address)

# delete the account
delete = wallet.delete_key(address)
print("Account deleted:", delete)
Ejemplo n.º 6
0
import params
from algosdk import kmd, mnemonic

# create a kmd client
kcl = kmd.KMDClient(params.kmd_token, params.kmd_address)

# get the master derivation key from the mnemonic
backup = "alpha worry field wait hobby artist grape engine sponsor broccoli scare thing bean kind say royal inmate hood situate lock benefit omit index about usual"
mdk = mnemonic.to_master_derivation_key(backup)

# recover the wallet by passing mdk when creating a wallet
new_wallet = kcl.create_wallet("wallet40",
                               "testpassword",
                               master_deriv_key=mdk)
print("New Wallet:", new_wallet)

walletid = new_wallet.get("id")
print(walletid)

wallethandle = kcl.init_wallet_handle(walletid, "testpassword")
accounts = kcl.list_keys(wallethandle)
print("Accounts:", accounts)

# if there were accounts previously generated in this wallet, then generate_key() will regenerate them
address = kcl.generate_key(wallethandle)
print("New account:", address)
Ejemplo n.º 7
0
def kmd_client(context):
    kmd_address = "http://localhost:" + str(kmd_port)
    context.kcl = kmd.KMDClient(token, kmd_address)
Ejemplo n.º 8
0
 def make_kmd_client(self):
     env = self._get_env()
     return kmd.KMDClient(env.kmd_token, env.kmd_address)
Ejemplo n.º 9
0
    return txinfo


def get_private_key_from_mnemonic(mn):
    private_key = mnemonic.to_private_key(mn)
    return private_key


algod_address = sys.argv[1]
algod_token = sys.argv[2]
kmd_address = sys.argv[3]
kmd_token = sys.argv[4]
wallet_name = sys.argv[5]
wallet_pwd = sys.argv[6]

kmd = kmd.KMDClient(kmd_token, kmd_address)
wallet = wallet.Wallet(wallet_name, wallet_pwd, kmd)
client = algod.AlgodClient(algod_token, algod_address)

# define creator
creator = sys.argv[7]
creator_private_key = wallet.export_key(creator)

# get node suggested parameters
params = client.suggested_params()
# comment out the next two (2) lines to use suggested fees
params.flat_fee = True
params.fee = int(sys.argv[8])

# create unsigned transaction
approval_program = compile_program(client, sys.argv[9])