licence added, flask app started, delete/create wallet improvements

This commit is contained in:
0ceanSlim 2023-12-19 09:49:29 -05:00
parent ac16a24b7c
commit a6a02bd6b5
7 changed files with 98 additions and 7 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) [2023] [OceanSlim]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -20,6 +20,18 @@ Just run the `cli.exe` in the root directory of this repository. The program wil
If you are on Linux or MacOS, you will need python installed before you can run cli.py If you are on Linux or MacOS, you will need python installed before you can run cli.py
You can download Python [Here](https://www.python.org/downloads/) You can download Python [Here](https://www.python.org/downloads/)
## Flask App Development
First install the requirements with
```bash
pip install -r requirements.txt
```
Then from the root directory, run:
```bash
python -m flask --app .\app\app.py run
```
This will start the app @ http://127.0.0.1:5000
## License ## License
This repository is provided under the MIT License. Feel free to use, modify, and distribute these scripts as needed. Contributions and improvements are welcome. ❤️ This repository is provided under the MIT License. Feel free to use, modify, and distribute these scripts as needed. Contributions and improvements are welcome. ❤️
See the [LICENSE](LICENSE) file for details.

0
app/__init__.py Normal file
View File

7
app/app.py Normal file
View File

@ -0,0 +1,7 @@
from flask import Flask
app = Flask(__name__)
@app.route("/")
def home():
return "hello world"

View File

@ -1,2 +1,3 @@
python-bitcoinrpc python-bitcoinrpc
mnemonic mnemonic
flask

View File

@ -21,11 +21,16 @@ try:
rpc_connection.createwallet(wallet_name) rpc_connection.createwallet(wallet_name)
print(f"Wallet '{wallet_name}' created successfully.") print(f"Wallet '{wallet_name}' created successfully.")
# Generate HD seed # Prompt the user for seed phrase length preference
mnemonic = Mnemonic("english") seed_length = input("Choose seed phrase length (12 or 24 words): ")
seed_words = mnemonic.generate(256) # 256 bits entropy for BIP39 if seed_length == '12' or seed_length == '24':
print("Write down these seed words:") entropy_bits = 128 if seed_length == '12' else 256
print(seed_words) mnemonic = Mnemonic("english")
seed_words = mnemonic.generate(entropy_bits)
print("Write down these seed words:")
print(seed_words)
else:
print("Invalid choice. Please choose 12 or 24.")
# You might want to save or display these seed words securely for the user # You might want to save or display these seed words securely for the user

45
src/deleteWallet.py Normal file
View File

@ -0,0 +1,45 @@
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from util.rpcHandler import read_rpc_config, create_rpc_connection
# Read the RPC configuration from the configuration file
rpc_host, rpc_port, rpc_user, rpc_password = read_rpc_config()
try:
rpc_connection = AuthServiceProxy(
f"http://{rpc_user}:{rpc_password}@{rpc_host}:{rpc_port}"
)
# List available wallets
wallet_list = rpc_connection.listwallets()
if wallet_list:
print("Available wallets:")
for index, wallet in enumerate(wallet_list):
print(f"{index + 1}. {wallet}")
# Prompt for wallet selection to delete
selection = input("Enter the number of the wallet to delete (or 0 to cancel): ")
if selection.isdigit():
selection = int(selection)
if 0 < selection <= len(wallet_list):
wallet_to_delete = wallet_list[selection - 1]
confirm_deletion = input(f"Are you sure you want to delete '{wallet_to_delete}'? (yes/no): ")
if confirm_deletion.lower() == "yes":
rpc_connection.unloadwallet(wallet_to_delete)
print(f"Wallet '{wallet_to_delete}' has been deleted.")
else:
print("Deletion cancelled.")
elif selection == 0:
print("Operation cancelled.")
else:
print("Invalid selection.")
else:
print("Invalid input.")
else:
print("No wallets found.")
except JSONRPCException as json_exception:
print("A JSON RPC Exception occurred: " + str(json_exception))
except Exception as general_exception:
print("An Exception occurred: " + str(general_exception))