# 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:
```python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/gr0vity-dev/nanowallet_py",
"name": "nanowallet",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "gr0vity",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/2c/b4/18904db80a6648aed9b0e5b46ac829119f9e3d2d3fc2262d349461963a51/nanowallet-0.0.14.tar.gz",
"platform": null,
"description": "# NanoWallet Library\n\n\n**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.\n\n## Installation\n\nYou can install NanoWallet using pip:\n\n```\npip install nanowallet\n```\n\n## Usage\n\nHere's a basic example of how to use the NanoWallet library:\n\n```python\nimport asyncio\nfrom nanorpc.client import NanoRpcTyped\nfrom nanowallet import NanoWallet\n\nasync def main():\n # Replace with your RPC endpoint\n rpc = NanoRpcTyped(url='http://localhost:7076')\n seed = '4f2dd...' # Replace with your seed\n index = 0\n\n wallet = NanoWallet(rpc, seed, index)\n await wallet.reload() # Optional - loads all account data\n print(wallet.account)\n print(wallet.receivable_blocks)\n\n response = await wallet.receive_all()\n if response.success:\n print(response.value) # list of received block hashes\n\nasyncio.run(main())\n```\n\n## Features\n\n- Create and manage Nano wallets\n- Send and receive Nano transactions\n- Check account balance and pending blocks\n- Use work peers for PoW (Proof of Work) generation.\n- Handle errors with a robust error handling system\n- Seamlessly reload wallet state.\n\n## Available Methods\n\n- `reload()`: \n Loads the current state of the wallet, including balance, receivable blocks, account info, and more.\n\n- `send(destination_account: str, amount: float)`: \n Sends a specified amount of Nano to the destination account. Returns the hash of the sent block.\n\n- `receive_by_hash(block_hash: str)`: \n Receives a specific receivable block by its hash. Returns the hash of the received block.\n\n- `sweep(destination_account: str)`: \n Sends all available funds from the current wallet to the specified destination account.\n\n- `receive_all(threshold: float = None)`: \n Receives all pending receivable blocks. Optionally, a threshold can be set to only receive blocks with amounts greater than the threshold.\n\n- `list_receivables(threshold: float = None)`: \n Lists all receivable blocks, sorted by the amount in descending order. A threshold can be used to filter the results.\n\n- `refund_first_sender()`: \n Receives all receivable blocks and sends the entire funds back to the first sender (i.e., the account opener or eldest unreceived block).\n\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request or create an issue for any bugs or feature requests.\n\n## License\n\nThis 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.\n",
"bugtrack_url": null,
"license": null,
"summary": "async nano library for easy account management",
"version": "0.0.14",
"project_urls": {
"Homepage": "https://github.com/gr0vity-dev/nanowallet_py"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0f92f4685a55785fb1e563daa77b165da3146dc5d4b6f650f39f12d541603350",
"md5": "dfea9f53551b9bc46739a13f8c64b40f",
"sha256": "beea8bd42a2b56f98cfc1b9db0cea92d1338c5d1c15682bd5b78dfe7b27409d8"
},
"downloads": -1,
"filename": "nanowallet-0.0.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dfea9f53551b9bc46739a13f8c64b40f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7670,
"upload_time": "2024-11-06T08:23:05",
"upload_time_iso_8601": "2024-11-06T08:23:05.864607Z",
"url": "https://files.pythonhosted.org/packages/0f/92/f4685a55785fb1e563daa77b165da3146dc5d4b6f650f39f12d541603350/nanowallet-0.0.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2cb418904db80a6648aed9b0e5b46ac829119f9e3d2d3fc2262d349461963a51",
"md5": "fa76543dd04d0254df4146efd683bb10",
"sha256": "44070f4ac879adc58b023622be5c7dd214dbe95c7d8987c7c8873b879a9d92bc"
},
"downloads": -1,
"filename": "nanowallet-0.0.14.tar.gz",
"has_sig": false,
"md5_digest": "fa76543dd04d0254df4146efd683bb10",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11399,
"upload_time": "2024-11-06T08:23:07",
"upload_time_iso_8601": "2024-11-06T08:23:07.477218Z",
"url": "https://files.pythonhosted.org/packages/2c/b4/18904db80a6648aed9b0e5b46ac829119f9e3d2d3fc2262d349461963a51/nanowallet-0.0.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-06 08:23:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gr0vity-dev",
"github_project": "nanowallet_py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "nanowallet"
}