Skip to main content

async nano library for easy account management

Project description

NanoWallet Library

nanowallet_py is a Python library that provides an easy-to-use interface for interacting with Nano nodes. This library allows you to manage your Nano account inside a wallet. It allows you to send and receive transactions, and interact with the Nano network using the NanoRpcTyped client.

Installation

You can install NanoWallet using pip:

pip install nanowallet

Usage

Here's a basic example of how to use the NanoWallet library:

import asyncio
from nanorpc.client import NanoRpcTyped
from nanowallet import NanoWallet

async def main():
    # Replace with your RPC endpoint
    rpc = NanoRpcTyped(url='http://localhost:7076')
    seed = '4f2dd...'  # Replace with your seed
    index = 0

    wallet = NanoWallet(rpc, seed, index)
    await wallet.reload()  # Optional - loads all account data
    print(wallet.account)
    print(wallet.receivable_blocks)

    response = await wallet.receive_all()
    if response.success:
        print(response.value)  # list of received block hashes

asyncio.run(main())

Features

  • Create and manage Nano wallets
  • Send and receive Nano transactions
  • Check account balance and pending blocks
  • Use work peers for PoW (Proof of Work) generation.
  • Handle errors with a robust error handling system
  • Seamlessly reload wallet state.

Available Methods

  • reload():
    Loads the current state of the wallet, including balance, receivable blocks, account info, and more.

  • send(destination_account: str, amount: float):
    Sends a specified amount of Nano to the destination account. Returns the hash of the sent block.

  • receive_by_hash(block_hash: str):
    Receives a specific receivable block by its hash. Returns the hash of the received block.

  • sweep(destination_account: str):
    Sends all available funds from the current wallet to the specified destination account.

  • receive_all(threshold: float = None):
    Receives all pending receivable blocks. Optionally, a threshold can be set to only receive blocks with amounts greater than the threshold.

  • list_receivables(threshold: float = None):
    Lists all receivable blocks, sorted by the amount in descending order. A threshold can be used to filter the results.

  • refund_first_sender():
    Receives all receivable blocks and sends the entire funds back to the first sender (i.e., the account opener or eldest unreceived block).

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or create an issue for any bugs or feature requests.

License

This project is licensed under an open-source license that allows free use and modification for both commercial and private use. For more details, please see the LICENSE file in the repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanowallet-0.0.14.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

nanowallet-0.0.14-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file nanowallet-0.0.14.tar.gz.

File metadata

  • Download URL: nanowallet-0.0.14.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for nanowallet-0.0.14.tar.gz
Algorithm Hash digest
SHA256 44070f4ac879adc58b023622be5c7dd214dbe95c7d8987c7c8873b879a9d92bc
MD5 fa76543dd04d0254df4146efd683bb10
BLAKE2b-256 2cb418904db80a6648aed9b0e5b46ac829119f9e3d2d3fc2262d349461963a51

See more details on using hashes here.

File details

Details for the file nanowallet-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: nanowallet-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for nanowallet-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 beea8bd42a2b56f98cfc1b9db0cea92d1338c5d1c15682bd5b78dfe7b27409d8
MD5 dfea9f53551b9bc46739a13f8c64b40f
BLAKE2b-256 0f92f4685a55785fb1e563daa77b165da3146dc5d4b6f650f39f12d541603350

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page