Designing Bitcoin Wallet Creation and Restoration SDKs
Research status: Theoretical SDK design. Examples are illustrative and have not been built or tested against the live engine.
Provisioning as a workflow
A wallet SDK should expose creation as a deliberate operation, not a constructor side effect. The factory issues identity and the permanent fee law; the engine imports the identity. These are separate trust domains and may have separate URLs. A factory success followed by an engine failure is not a reason to create another wallet. Persist the authorized recovery material securely before attempting import, and resume from the last known step.
The application must present the actual fee terms and collect explicit consent before creation. A library must not silently supply consent on behalf of a user or an agent. The birth law remains authoritative after restoration; a client version upgrade does not alter it.
Proposed Python workflow
def provision(factory, engine, consent, vault):
identity = factory.create(consent=consent)
vault.store(identity) # protected storage, not logging
engine.restore(identity)
return identity.public_idThese are proposed interfaces, not wire fields. The vault and adapters must be implemented separately. A lost factory response leaves issuance uncertain; do not assume that creation is replay-safe. A storage failure must stop the workflow and trigger secure recovery handling rather than discard the only credentials.
Restoration and readiness
Model identity import and balance readiness separately. A successful restore may precede chain reconciliation. A warming response must not become a zero balance. Bind each client to an explicit credential context and engine origin. Avoid importing a second identity into a shared context without checking isolation. Recovery material must never appear in an exception, published fixture or ordinary return value exposed to an AI tool.
Acceptance plan
Use dedicated test identities. Exercise explicit consent, factory rejection, successful issuance, failed import, resumed import and warming state. Verify identity continuity and eventual balance against the engine. Simulate vault failure and ambiguous factory response with mocks; do not deliberately lose real recovery material. Confirm that no secret appears in logs. The SDK cannot promise recovery when required credentials or underlying data are unavailable.
Primary reference
https://thamer.org/api
Related reading in this series
https://thamer.org/docs/wab-sdk-designing-bitcoin-sdk
https://thamer.org/docs/wab-sdk-api-engine-application-boundaries
https://thamer.org/docs/wab-sdk-wallet-identity-management
https://thamer.org/docs/wab-sdk-cross-language-interfaces
https://thamer.org/docs/wab-sdk-typed-json-contracts
https://thamer.org/docs/wab-sdk-authentication-credential-management
https://thamer.org/docs/wab-sdk-receive-address-interfaces
https://thamer.org/docs/wab-sdk-balance-utxo-management
https://thamer.org/docs/wab-sdk-transaction-execution
https://thamer.org/docs/wab-sdk-idempotency-retry-strategies
https://thamer.org/docs/wab-sdk-wallet-recovery-local-lifecycle
