feat: use AITBC CLI tool for wallet and transaction operations
Some checks failed
Documentation Validation / validate-docs (push) Has been cancelled
Some checks failed
Documentation Validation / validate-docs (push) Has been cancelled
- Update wallet creation to use 'aitbc wallet create' CLI command - Update transaction sending to use 'aitbc wallet send' CLI command - Replace complex Python scripts with simple CLI commands - Add wallet verification with 'aitbc wallet list' - Add transaction hash retrieval with 'aitbc wallet transactions' - Improve transaction monitoring with better progress tracking - Simplify user experience with intuitive CLI interface This makes the workflow more user-friendly and reduces complexity by using the dedicated CLI tool instead of manual Python scripts for wallet operations.
This commit is contained in:
@@ -259,12 +259,15 @@ fi
|
|||||||
### 5. Create Wallet on aitbc
|
### 5. Create Wallet on aitbc
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# On aitbc, create a new wallet using Python script (CLI not fully implemented)
|
# On aitbc, create a new wallet using AITBC CLI tool
|
||||||
ssh aitbc 'cd /opt/aitbc/apps/blockchain-node && /opt/aitbc/venv/bin/python scripts/keystore.py --name aitbc-user --create --password $(cat /var/lib/aitbc/keystore/.password)'
|
ssh aitbc 'source /opt/aitbc/venv/bin/activate && aitbc wallet create --name aitbc-user --password-file /var/lib/aitbc/keystore/.password'
|
||||||
|
|
||||||
# Note the new wallet address
|
# Note the new wallet address
|
||||||
WALLET_ADDR=$(ssh aitbc 'cat /var/lib/aitbc/keystore/aitbc-user.json | jq -r .address')
|
WALLET_ADDR=$(ssh aitbc 'cat /var/lib/aitbc/keystore/aitbc-user.json | jq -r .address')
|
||||||
echo "New wallet: $WALLET_ADDR"
|
echo "New wallet: $WALLET_ADDR"
|
||||||
|
|
||||||
|
# Verify wallet was created successfully
|
||||||
|
ssh aitbc "source /opt/aitbc/venv/bin/activate && aitbc wallet list --format json | jq '.[] | select(.name == \"aitbc-user\")'"
|
||||||
```
|
```
|
||||||
|
|
||||||
**🔑 Wallet Attachment & Coin Access:**
|
**🔑 Wallet Attachment & Coin Access:**
|
||||||
@@ -284,50 +287,34 @@ The newly created wallet on aitbc will:
|
|||||||
### 6. Send 1000 AIT from Genesis to aitbc Wallet
|
### 6. Send 1000 AIT from Genesis to aitbc Wallet
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# On aitbc1, send 1000 AIT using Python script (CLI not fully implemented)
|
# On aitbc1, send 1000 AIT using AITBC CLI tool
|
||||||
GENESIS_KEY=$(/opt/aitbc/venv/bin/python -c "
|
source /opt/aitbc/venv/bin/activate
|
||||||
import json, sys
|
|
||||||
from cryptography.hazmat.primitives.asymmetric import ed25519
|
|
||||||
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
|
||||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
|
||||||
from cryptography.hazmat.primitives import hashes
|
|
||||||
|
|
||||||
with open('/var/lib/aitbc/keystore/aitbc1genesis.json') as f:
|
# Send transaction from genesis wallet to aitbc wallet
|
||||||
ks = json.load(f)
|
aitbc wallet send \
|
||||||
|
--from aitbc1genesis \
|
||||||
|
--to $WALLET_ADDR \
|
||||||
|
--amount 1000 \
|
||||||
|
--password-file /var/lib/aitbc/keystore/.password \
|
||||||
|
--fee 10
|
||||||
|
|
||||||
# Decrypt private key
|
# Get transaction hash for verification
|
||||||
crypto = ks['crypto']
|
TX_HASH=$(aitbc wallet transactions --from aitbc1genesis --limit 1 --format json | jq -r '.[0].hash')
|
||||||
salt = bytes.fromhex(crypto['kdfparams']['salt'])
|
echo "Transaction hash: $TX_HASH"
|
||||||
kdf = PBKDF2HMAC(hashes.SHA256(), 32, salt, crypto['kdfparams']['c'])
|
|
||||||
key = kdf.derive('aitbc123'.encode())
|
|
||||||
aesgcm = AESGCM(key)
|
|
||||||
nonce = bytes.fromhex(crypto['cipherparams']['nonce'])
|
|
||||||
priv = aesgcm.decrypt(nonce, bytes.fromhex(crypto['ciphertext']), None)
|
|
||||||
print(priv.hex())
|
|
||||||
")
|
|
||||||
|
|
||||||
# Create and submit transaction
|
|
||||||
TX_JSON=$(cat << EOF
|
|
||||||
{
|
|
||||||
"sender": "$(cat /var/lib/aitbc/keystore/aitbc1genesis.json | jq -r .address)",
|
|
||||||
"recipient": "$WALLET_ADDR",
|
|
||||||
"value": 1000,
|
|
||||||
"fee": 10,
|
|
||||||
"nonce": 0,
|
|
||||||
"type": "transfer",
|
|
||||||
"payload": {}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
curl -X POST http://localhost:8006/sendTx \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$TX_JSON"
|
|
||||||
|
|
||||||
# Wait for transaction to be mined
|
# Wait for transaction to be mined
|
||||||
sleep 15
|
echo "Waiting for transaction to be mined..."
|
||||||
|
for i in {1..10}; do
|
||||||
|
sleep 2
|
||||||
|
BALANCE=$(ssh aitbc "curl -s \"http://localhost:8006/rpc/getBalance/$WALLET_ADDR\" | jq .balance")
|
||||||
|
if [ "$BALANCE" -gt "0" ]; then
|
||||||
|
echo "Transaction mined! Balance: $BALANCE AIT"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Check $i/10: Balance = $BALANCE AIT"
|
||||||
|
done
|
||||||
|
|
||||||
# Verify balance on aitbc
|
# Final balance verification
|
||||||
ssh aitbc "curl -s \"http://localhost:8006/rpc/getBalance/$WALLET_ADDR\" | jq ."
|
ssh aitbc "curl -s \"http://localhost:8006/rpc/getBalance/$WALLET_ADDR\" | jq ."
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user