Skip to content

feat: phase 4 wallet integration -- BRC-100 substrates, include flags, WireFormat, AuthFetch issuance (#445)#454

Merged
sgbett merged 11 commits intomasterfrom
feat/445-phase4-wallet-integration
Apr 15, 2026
Merged

feat: phase 4 wallet integration -- BRC-100 substrates, include flags, WireFormat, AuthFetch issuance (#445)#454
sgbett merged 11 commits intomasterfrom
feat/445-phase4-wallet-integration

Conversation

@sgbett
Copy link
Copy Markdown
Owner

@sgbett sgbett commented Apr 15, 2026

Summary

  • Add BSV::WireFormat module for shared camelCase/snake_case key conversion, refactoring duplicated code from AuthMiddleware and SimplifiedFetchTransport (F8.11)
  • Honour include flags (include_labels, include_inputs, include_outputs, etc.) in list_actions and list_outputs with post-fetch field stripping (F8.12)
  • Add BRC-100 HTTP substrates: HTTPWalletJSON (JSON-over-HTTP), HTTPWalletWire (binary wire transport), WalletWireTransceiver (Interface adapter) (F8.2)
  • Add substrate: constructor parameter to WalletClient for remote wallet communication (F8.2)
  • Replace plain Net::HTTP with AuthFetch for BRC-104 authenticated certificate issuance (F8.16)

Test plan

  • All specs pass (bundle exec rake) -- 4902 examples, 0 failures
  • RuboCop clean (bundle exec rubocop) -- 377 files, 0 offences
  • WireFormat round-trip tests verify deep key conversion
  • Include flag specs verify each flag individually with defaults-to-false behaviour
  • Substrate specs verify HTTP delegation for all 28 Interface methods
  • AuthFetch issuance specs verify mutual authentication during certificate acquisition

Sub-issues

Closes #445

sgbett and others added 9 commits April 15, 2026 17:23
Plan covers F8.2 (BRC-100 substrates), F8.11 (WireFormat translator),
F8.12 (list_actions/list_outputs include flags), and F8.16 (AuthFetch
certificate issuance).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…448)

Add post-fetch field stripping in WalletClient#list_actions and
#list_outputs. Two new private methods (strip_action_fields,
strip_output_fields) remove fields when the corresponding include flag
is absent or false, matching the TS SDK's BooleanDefaultFalse
behaviour. Stripping is non-destructive (dup before delete).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nce (#453)

Replace plain Net::HTTP::Post in acquire_via_issuance with BSV::Auth::AuthFetch
so certificate issuance participates in the BRC-103/104 mutual authentication
and 402 payment flows. Add lazy auth_fetch_client helper (memoised on first
call). Update certificate_spec to mock AuthFetch#fetch instead of mock_http.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rsion (#447)

- Add `BSV::WireFormat` with `to_wire`, `from_wire`, `snake_to_camel`, `camel_to_snake`
- Deep conversion recurses into nested hashes and arrays; only keys are converted
- Lookup table covers BRC-100/BRC-103 keys including acronyms (protocolID, keyID, inputBEEF)
- Refactor AuthMiddleware: remove 4 private conversion methods, delegate to WireFormat
- Refactor SimplifiedFetchTransport: remove 2 constants + 4 private methods, delegate to WireFormat

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rt (#450)

Adds BSV::Wallet::Substrates::HTTPWalletWire — a single-method wire transport
that parses call codes from binary frames, maps them to camelCase URL paths,
and POSTs octet-stream payloads to a remote wallet endpoint via Net::HTTP.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#449)

Implements BSV::Wallet::Substrates::HTTPWalletJSON — a full WalletInterface
implementation that delegates all 28 BRC-100 methods to a remote wallet server
via POST #{base_url}/#{camelCaseMethodName} with JSON bodies. Uses
BSV::WireFormat for deep key conversion at JSON boundaries, and maps structured
error codes (5/6/7) to the correct Ruby exception subclasses.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ansport (#451)

Implements BSV::Wallet::Substrates::WalletWireTransceiver — a full BRC-100
Interface implementation that serialises all 28 method calls via
Wire::Serializer, transmits binary frames through a duck-typed wire transport
(e.g. HTTPWalletWire), and deserialises the response. Error frames raise
WalletError. Originator may be set at construction and overridden per-call.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mote wallet communication (#452)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use receive_messages instead of multiple stubs
- Move local variable inside example to avoid leaky scope
- Add expectation to endpoint routing examples

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

sgbett and others added 2 commits April 15, 2026 19:53
Deep conversion via WireFormat.to_wire/from_wire recurses into nested
hashes, mangling base64 certificate type identifiers in
requested_certificates.types (e.g. "dHlwZUFBQQ==" becomes
"d_hlw_z_u_f_b_q_q=="). The old AuthMiddleware and
SimplifiedFetchTransport code used shallow (top-level only) conversion.

Add shallow_to_wire/shallow_from_wire methods that convert only
top-level keys, preserving nested user-data keys unchanged. Switch
both auth handshake paths to use the shallow variants.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…flags

- HTTPWalletJSON: add comment explaining why per-call originator is
  ignored (matches TS SDK — HTTP substrates identify by connection,
  not per call; wire substrates encode originator per message)
- HTTPWalletJSON: let JSON::ParserError propagate on 2xx responses
  instead of silently returning {}. Error responses still degrade
  gracefully when body is unparseable.
- strip_action_fields: combine input sub-field stripping into a single
  pass instead of iterating twice when both source_locking_script and
  unlocking_script flags are false

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sgbett sgbett merged commit 7b0f712 into master Apr 15, 2026
9 checks passed
@sgbett sgbett deleted the feat/445-phase4-wallet-integration branch April 21, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HLR] Wallet integration — BRC-100 substrates, include flags, AuthFetch certificate issuance (F8.2/F8.12/F8.16)

1 participant