Wallet API Cookbook
Set shared vars:
export WALLET_API_URL="http://127.0.0.1:8070"
export WALLET_API_KEY="strong-password"
1) Create wallet
curl -s -X POST "$WALLET_API_URL/wallet/create" \
-H "X-API-KEY: $WALLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"demo.wallet","password":"wallet-pass","daemonHost":"127.0.0.1","daemonPort":11898,"daemonSSL":false}'
2) Open wallet
curl -s -X POST "$WALLET_API_URL/wallet/open" \
-H "X-API-KEY: $WALLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"demo.wallet","password":"wallet-pass","daemonHost":"127.0.0.1","daemonPort":11898,"daemonSSL":false}'
3) Check status and balance
curl -s -H "X-API-KEY: $WALLET_API_KEY" "$WALLET_API_URL/status"
curl -s -H "X-API-KEY: $WALLET_API_KEY" "$WALLET_API_URL/balance"
curl -s -H "X-API-KEY: $WALLET_API_KEY" "$WALLET_API_URL/addresses"
4) Send transaction (basic)
curl -s -X POST "$WALLET_API_URL/transactions/send/basic" \
-H "X-API-KEY: $WALLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"destination":"<address>","amount":1000000}'
5) Prepare then send transaction
curl -s -X POST "$WALLET_API_URL/transactions/prepare/basic" \
-H "X-API-KEY: $WALLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"destination":"<address>","amount":1000000}'
Use returned hash:
curl -s -X POST "$WALLET_API_URL/transactions/send/prepared" \
-H "X-API-KEY: $WALLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"transactionHash":"<prepared-transaction-hash>"}'
6) Query transactions
curl -s -H "X-API-KEY: $WALLET_API_KEY" "$WALLET_API_URL/transactions"
curl -s -H "X-API-KEY: $WALLET_API_KEY" "$WALLET_API_URL/transactions/unconfirmed"
curl -s -H "X-API-KEY: $WALLET_API_KEY" "$WALLET_API_URL/transactions/hash/<tx-hash>"
7) Export and save
curl -s -X POST "$WALLET_API_URL/export/json" \
-H "X-API-KEY: $WALLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"wallet-export.json"}'
curl -s -X PUT "$WALLET_API_URL/save" -H "X-API-KEY: $WALLET_API_KEY"
8) Reset and refresh
curl -s -X PUT "$WALLET_API_URL/reset" \
-H "X-API-KEY: $WALLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"scanHeight":0}'
curl -s -X PUT "$WALLET_API_URL/sync/refresh" -H "X-API-KEY: $WALLET_API_KEY"
9) Close wallet
curl -s -X DELETE "$WALLET_API_URL/wallet" -H "X-API-KEY: $WALLET_API_KEY"