Repository navigation
Speak the @bsv/sdk 4.1.1 wallet wire and JSON - #20
Merged
Merged
Conversation
…terparties createHMAC keys HMAC-SHA256 with the minimal-length X coordinate, as @bsv/sdk 4.1.1 and earlier TypeScript SDKs do. verifyHMAC also accepts tags made with the 32-byte padded key, so earlier Swift and Go tags stay valid. AES-GCM keeps the 32-byte key (COMP-064). The counterparty linkage proof writes z as 32 bytes, and revealSpecificKeyLinkage accepts self and anyone and returns the resolved key.
TypeScript wallets and apps are the 1Sat wallet's peers, so the binary
wallet wire now follows @bsv/sdk 4.1.1 where pinned Go v1.3.3 differs:
- createAction and signAction results use the TypeScript layout with
display-order txids; the txid and signable transaction may be absent
- list totals count every match and records run to the end of the frame
- listOutputs totalOutputs is UInt64 for BRC-112 balance baskets
- the optional spendable listOutputs extension
- abortAction refusal is error code 8
- false verifications, unknown calls (including the call-29 probe) and
malformed requests are answered in-band with the TypeScript messages
- maps arrive in any order, omitted booleans and counterparties use the
TypeScript sentinels, empty list entries have length 0
- discovery seekPermission defaults to true; JSON errors carry code 1
- JSON keyring {} reads as no keyring
Go-oracle tests now record the Go differences instead of pinning them.
Tools/Conformance/TSOracle/generate.sh runs the real @bsv/sdk transceiver against its own processor with Bun and records every frame. The opt-in WalletWireTypeScriptOracleTests replays those frames against the Swift processor and transceiver.
COMP-045, 046, 048 and 050 now say why the wire follows @bsv/sdk 4.1.1 and what still differs from pinned Go. COMP-064 replaces the HMAC part of COMP-002.
WalletWireResultRejection gets an errorDescription a wallet can show. The message keeps the exact @bsv/sdk wire text and description keeps both for logs.
COMP-064 is taken by the interpreter Chronicle rules ruling.
@bsv/sdk 4.1.1 writes certificate fields sorted with localeCompare (auth/certificates/Certificate.ts:290), so cardholder comes before cardNumber. The decoder rejected that as out of order, which lost whole acquireCertificate, listCertificates and discovery results from TS wallets. It now reads any order and still rejects a repeated name. Swift keeps writing byte order.
- Accept createAction noSendChange without noSend, as TS does. - Keep ABI and certificate errors as they are, so the error frame says which value was wrong instead of "unsupported wallet action value". - Log processor decode and encode failures with full detail (dev.opl.swift-sdk, BSVWallet) and send the peer a fixed short text for errors the codecs do not describe. - Refuse list and discovery results longer than the request's limit with the TS text, and read certificate pages only up to that limit. - Store an empty certificate keyring as absent and write flag 0. - Use the TS wording for false relinquishCertificate and waitForAuthentication, page totals, non-UTF-8 originators, a bad identityKey flag and a call-29 probe with trailing data. - Keep the underlying error in resolvedCounterparty. - Add the review cases to the TS oracle and fixed vectors from it.
# Conflicts: # Documentation/Compatibility/Rulings.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: the BRC-100 wallet wire and JSON followed Go v1.3.3 rulings, so TS 4.1.1 apps and wallets got errors or wrong values from a Swift wallet (txid byte order, totals, certificate field order, HMAC tags, error frames) and the reverse.
After: the Swift wallet processor and transceiver interoperate with @bsv/sdk 4.1.1 in both directions. A TS oracle with 104 live 4.1.1 cases and the Go oracle both pass.
How: wire and JSON codecs, ProtoWallet and the key deriver follow the TS source; rulings COMP-045/046/048/050 are rewritten (TS wallets and apps are the 1Sat wallet's peers) and COMP-065 covers the HMAC key. A Bun-based TS oracle lives in
Tools/Conformance/TSOracle.Behaviour and API changes
WalletListOutputsResult.totalOutputsisUInt64(also in JSON); balance baskets follow BRC-112.WalletCreateActionResult/WalletSignActionResultmay have no txid or transaction.knownTxidsandsendWithare in display order on the wire.WalletWireProcessor.transmitreturns an error frame instead of throwing for malformed requests and unknown calls; call 29 gets the exact frame TS uses to fall back to plain calls; false verify results are code-1 frames; error texts match TS.noSendChangeno longer requiresnoSend, as in TS.Certificate(binary:)reads fields in any order (TS writeslocaleCompareorder) and still rejects duplicates;fieldsNotInCanonicalOrderis no longer thrown.tagsoptional; JSONkeyring: {}and an empty keyring read as no keyring.privileged/forSelfwritten as absent; discoveryseekPermissiondefaults to true;revealSpecificKeyLinkageacceptsselfandanyone; remote message limit 4096 bytes; redacting mapper default text "Wallet operation failed".WalletWireListOutputsEncoding,listOutputsEncoding:/request:parameters (defaulted),WalletWireDecodedActionRequest.listOutputsEncoding,WalletWireResultRejection,walletIsBalanceBasket(_:),WalletKeyDeriver.resolvedCounterparty(_:).WalletLog(os Logger,dev.opl.swift-sdk/BSVWallet); the peer gets fixed short text.Still open, as a follow-up: signing wallet certificates in
localeCompareorder (Swift still writes byte order; TS reads either).Testing
swift testin swift:6.1 (Linux) after merging main: 925 tests passed, XCTest 155 passed, 0 failures; only opt-in tests skipped. TS 4.1.1 and Go v1.3.3 oracles: 43 tests passed.