Example #1
0
async def return_spare(walletID, depositAddress):
    balanceraw = await get_balance(depositAddress)
    balanceint = int(balanceraw) / 10**29
    if balanceint == 0:
        return None
    else:
        print("\nThe temporary deposit address still has " + str(balanceint) +
              "ban remaining!")
        while Validations.get_banano_address(returnAddr) is not None:
            returnAddr = input(
                "Enter the banano address you would like to return the spare to \n"
            )
            returnAddr = Validations.get_banano_address(returnAddr)
            if Validations.validate_address(returnAddr) is True:
                print("Sending remaining bans to: " + returnAddr)
                break
            else:
                print(returnAddr + " is not a valid account")
        try:
            await send_payment(walletID, depositAddress, returnAddr,
                               balanceraw)
        except Exception as e:
            print(e)
            print(
                "Publishing block failed. Funds remain in distribution address\n"
            )
Example #2
0
async def send_funds(walletID, source):
    valid_addresses = []
    async with aiofiles.open("addresses.txt") as file:
        async for line in file:
            if Validations.get_banano_address(line) is not None:
                account = Validations.get_banano_address(line)
                if Validations.validate_address(account) is True:
                    valid_addresses.append(account)
                else:
                    print(account + " is not a valid account")
            else:
                print(account + " does not fit the form of an address")
    num_addresses = len(valid_addresses)
    sourcebal = await get_balance(source)
    sourcebal = int(sourcebal) / 10**29
    remainder = sourcebal % num_addresses
    banperacc = (sourcebal - remainder) / num_addresses
    print("Sending " + str(banperacc) + "ban to " + str(num_addresses) +
          " accounts!")
    for account in valid_addresses:
        account = account.strip()
        print("Sending " + str(banperacc) + "ban to " + account)
        await send_payment(walletID, source, account,
                           str(int(banperacc) * 10**29))