-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
Replace the ElectrumX network layer with direct bitmarkd RPC calls to enable the wallet to:
- Query address balances
- Fetch transaction history
- Broadcast signed transactions
This is a temporary backend for Stage 1 PoC. Stage 2 will migrate to proper ElectrumX protocol.
Architecture
Current (broken):
┌─────────────┐ ┌─────────────┐
│ Electrum │ ───? │ ElectrumX │ (no server exists)
│ Wallet │ │ Server │
└─────────────┘ └─────────────┘
Stage 1 Target:
┌─────────────┐ ┌─────────────┐
│ Electrum │ RPC │ bitmarkd │
│ Wallet │ ───► │ (local) │
└─────────────┘ └─────────────┘
bitmarkd RPC Methods Required
| Wallet Function | bitmarkd RPC Call |
|---|---|
| Get balance | getreceivedbyaddress or listunspent |
| Get UTXOs | listunspent |
| Get tx history | listtransactions / gettransaction |
| Broadcast tx | sendrawtransaction |
| Get fee estimate | estimatefee |
| Verify address | validateaddress |
| Get block height | getblockcount |
Implementation Plan
1. Create RPC Client Module
New file: electrum/bitmarkd_rpc.py
class BitmarkdRPC:
def __init__(self, host='127.0.0.1', port=9266, user=None, password=None):
self.url = f'http://{host}:{port}'
self.auth = (user, password) if user else None
async def call(self, method, *params):
"""Make RPC call to bitmarkd"""
pass
async def get_balance(self, address):
"""Get confirmed balance for address"""
pass
async def list_unspent(self, addresses):
"""Get UTXOs for addresses"""
pass
async def broadcast_transaction(self, raw_tx):
"""Broadcast signed transaction"""
pass2. Create Network Adapter
New file: electrum/network_rpc.py
Implement the same interface as network.py but using bitmarkd RPC:
class BitmarkdNetwork:
"""Drop-in replacement for Network class using bitmarkd RPC"""
async def get_address_history(self, address):
pass
async def get_address_balance(self, address):
pass
async def broadcast_transaction(self, tx):
pass3. Modify Wallet Initialization
In electrum/daemon.py or startup code:
- Add config option:
--rpc-host,--rpc-port,--rpc-user,--rpc-password - Or read from
~/.bitmark/bitmark.conf
4. Configuration
Read bitmarkd credentials from ~/.bitmark/bitmark.conf:
rpcuser=bitmarkrpc
rpcpassword=yourpassword
rpcport=9266Or allow command-line override:
./run_electrum gui --rpc-host=127.0.0.1 --rpc-port=9266Files to Modify
| File | Changes |
|---|---|
electrum/bitmarkd_rpc.py |
NEW - RPC client |
electrum/network_rpc.py |
NEW - Network adapter |
electrum/daemon.py |
Add RPC config options |
electrum/network.py |
May need interface changes |
electrum/synchronizer.py |
May need to use new adapter |
Testing
- Unit tests for RPC client
- Integration test with running bitmarkd:
# Start bitmarkd bitmarkd -daemon # Test wallet ./run_electrum getbalance -w test_wallet
Limitations (Stage 1)
- Requires local bitmarkd node (not lightweight)
- No SPV verification (trusts the node)
- Single server (no redundancy)
These limitations are addressed in Stage 2 with ElectrumX.
References
- bitmarkd RPC documentation
- Bitcoin RPC API (bitmarkd follows similar pattern)
- Current Electrum network.py implementation
Acceptance Criteria
- Wallet can connect to local bitmarkd
- Balance displays correctly for addresses with funds
- Transaction history shows past transactions
- Can send BTM to another address
- Error handling for RPC connection failures
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels