Ejemplo n.º 1
0
def wallet_selector(new_wallet_number=None):
    """
    Changes the current wallet.
    """

    all_wallets = list(get_saved_wallet())
    if not len(all_wallets) == 0:

        while True:
            try:
                if new_wallet_number is None:
                    new_wallet = input("Please select wallet: ")
                else:
                    new_wallet = new_wallet_number
                if int(new_wallet) in list(range(len(all_wallets))):
                    change_wallet(int(new_wallet))
                    print("New Wallets:")
                    print_wallets()
                    break
                else:
                    print("There is no such wallet")
                    if not new_wallet_number is None:
                        break
            except:
                print("This is not a number")
    else:
        print("There is no wallet")
Ejemplo n.º 2
0
def menu():
    """
    The main structure of the cli mode, this function prints the menu, 
    listens to the entries, makes the directions.
    """

    animation = [
        "[■□□□□□□□□□]", "[■■□□□□□□□□]", "[■■■□□□□□□□]", "[■■■■□□□□□□]",
        "[■■■■■□□□□□]", "[■■■■■■□□□□]", "[■■■■■■■□□□]", "[■■■■■■■■□□]",
        "[■■■■■■■■■□]", "[■■■■■■■■■■]"
    ]

    for i in range(len(animation)):
        time.sleep(0.1)
        sys.stdout.write("\r" + animation[i])
        sys.stdout.flush()

    while True:
        show_menu()
        choices_input = question_maker(mode="main")

        if choices_input == "pw":
            print_wallets()

        if choices_input == "w":
            wallet_selector()

        if choices_input == "cw":
            create_a_wallet()

        if choices_input == "dw":
            if "y" == input("Are you sure ? (y or n): "):
                delete_current_wallet()
        if choices_input == "sc":
            send_the_coin(input("Please write receiver adress: "),
                          input("Coin Amount (ex. 1.0): "),
                          getpass("Password: "******"gb":
            print_balance()
        if choices_input == "help":
            show_menu()
        if choices_input == "ndstart":
            ndstart(str(input("ip: ")), int(input("port: ")))
        if choices_input == "ndstop":
            ndstop()
        if choices_input == "ndconnect":
            ndconnect(str(input("node ip: ")), int(input("node port: ")))

        if choices_input == "ndconnectmixdb":
            ndconnectmixdb()
        if choices_input == "ndnewunl":
            save_new_unl_node(input("Please write ID of the node: "))
        if choices_input == "ndid":
            print(ndid())
        if choices_input == "testmodeon":
            test_mode(True)
        if choices_input == "testmodeoff":
            test_mode(False)
        if choices_input == "debugmodeon":
            debug_mode(True)
        if choices_input == "debugmodeoff":
            debug_mode(False)

        if choices_input == "exptrcsv":
            if export_the_transactions():
                print(
                    f"CSV file created in {MY_TRANSACTION_EXPORT_PATH} directory"
                )
            else:
                print("You have not a transaction")

        if choices_input == "returntrs":
            PrintTransactions()

        if choices_input == "getblock":
            if the_settings()["test_mode"]:
                CreateBlock()
            else:
                GetBlockFromOtherNode()

        if choices_input == "status":
            print(Status())

        if choices_input == "0":
            exit()
Ejemplo n.º 3
0
def arguments():
    parser = argparse.ArgumentParser(
        description=
        "This is an open source decentralized application network. In this network, you can develop and publish decentralized applications. Use the menu (-m) or GUI to gain full control and use the node, operation, etc."
    )

    parser.add_argument('-pw',
                        '--printwallet',
                        action='store_true',
                        help='Print Wallets')

    parser.add_argument('-w', '--wallet', type=int, help='Change Wallet')

    parser.add_argument('-cw', '--createwallet', help='Create wallet')

    parser.add_argument('-dw',
                        '--deletewallet',
                        action='store_true',
                        help='Delete wallet')

    parser.add_argument('-gb',
                        '--getbalance',
                        action='store_true',
                        help='Get Balance')

    parser.add_argument('-ndnunl',
                        '--ndnewunl',
                        type=str,
                        help='Add new UNL node')

    parser.add_argument('-ndid',
                        '--ndid',
                        action='store_true',
                        help='Print my id')

    parser.add_argument('-tmon',
                        '--testmodeon',
                        action='store_true',
                        help='Test Mode On')
    parser.add_argument('-tmoff',
                        '--testmodeoff',
                        action='store_true',
                        help='Test Mode Off')

    parser.add_argument('-dmon',
                        '--debugmodeon',
                        action='store_true',
                        help='Debug Mode On')
    parser.add_argument('-dmoff',
                        '--debugmodeoff',
                        action='store_true',
                        help='Debug Mode Off')

    parser.add_argument('-exptrcsv',
                        '--exporttransactioncsv',
                        action='store_true',
                        help='Exports the transaction as csv')

    parser.add_argument('-returntrans',
                        '--returntransactions',
                        action='store_true',
                        help='Exports the transaction as csv')

    parser.add_argument('-st',
                        '--status',
                        action='store_true',
                        help='Exports the transaction as csv')

    parser.add_argument('-m',
                        '--menu',
                        action='store_true',
                        help='An optional boolean for open the menu.')

    args = parser.parse_args()

    if len(sys.argv) < 2:
        parser.print_help()

    if args.printwallet:
        print_wallets()

    if not args.wallet is None:
        wallet_selector(args.wallet)

    if not args.createwallet is None:
        create_a_wallet(args.createwallet)

    if args.deletewallet:
        delete_current_wallet()

    if args.getbalance:
        print_balance()

    if not args.ndnewunl is None:
        save_new_unl_node(args.ndnewunl)

    if args.ndid:
        print(ndid())

    if args.testmodeon:
        test_mode(True)
    if args.testmodeoff:
        test_mode(False)
    if args.debugmodeon:
        debug_mode(True)
    if args.debugmodeoff:
        debug_mode(False)

    if args.exporttransactioncsv:
        if export_the_transactions():
            print(
                f"CSV file created in {MY_TRANSACTION_EXPORT_PATH} directory")
        else:
            print("You have not a transaction")

    if args.returntransactions:
        PrintTransactions()

    if args.status:
        print(Status())

    if args.menu:
        menu()
Ejemplo n.º 4
0
def delete_wallets_page():
    delete_current_wallet()
    return jsonify(print_wallets())
Ejemplo n.º 5
0
def create_wallet_page(password):
    create_a_wallet(password)
    return jsonify(print_wallets())
Ejemplo n.º 6
0
def wallet_change_page(number):
    wallet_selector(number)
    return jsonify(print_wallets())
Ejemplo n.º 7
0
def print_wallets_page():
    return jsonify(print_wallets())