Bitcoin Agent Fault Tolerance: Recovering Ambiguous Execution
Bitcoin Agent Fault Tolerance: Recovering Ambiguous Execution
Research question
A timeout after submission is an unknown outcome, not a failed payment. Recovery should preserve the original request identity and reconcile evidence before allowing another write.
Architecture and trust boundary
Treat model output and messages from other agents as untrusted proposals. Authenticate principals outside the model, keep BTC KEY in an isolated local executor, and separate authorization from execution. A request identifier is not authorization. Preserve the wallet's original signed fee law; distinguish sender total from recipient net amount.
Source implementation
1# SPDX-License-Identifier: 0BSD
2def next_action(state):
3 actions = {"prepared": "review_authorization", "submitted": "reconcile", "timeout": "reconcile", "confirmed": "close", "rejected": "review_failure"}
4 return actions.get(state, "manual_review")
5
6assert next_action("timeout") == "reconcile"
7assert next_action("submitted") == "reconcile"
8assert next_action("unknown") == "manual_review"
9assert next_action("confirmed") == "close"Integration with WAB ENGINE
A trusted executor can query POST /api/v5/btc/wallet/balance using X-BTC-KEY and JSON body {"net":"test","type":"segwit"}. The examples do not call this endpoint or implement SEND. A balance does not prove payment settlement. Any future write integration must persist the intent, approval, idempotency identity and execution evidence before allowing recovery or retries.
Limitations and failure handling
This state machine does not query the engine or retry a payment. Persist transitions before external calls; verify actual engine idempotency semantics and transaction evidence before enabling recovery writes.
The included assertions use synthetic data only. No live engine, model or blockchain connection was tested.
References
- https://thamer.org/api
- https://thamer.org/engine
- https://developer.bitcoin.org/devguide/transactions.html
Reference pointers only; external documentation was not reverified for this stage.
