fix(onchain): return canonical txid for already-known raw broadcasts#123
Open
coreyphillips wants to merge 2 commits into
Open
fix(onchain): return canonical txid for already-known raw broadcasts#123coreyphillips wants to merge 2 commits into
coreyphillips wants to merge 2 commits into
Conversation
broadcast_raw_tx now computes the transaction's canonical txid locally and returns it on success. Electrum "already known / already in mempool / already in block chain" responses are treated as success and return that same txid, so apps that broadcast separately from Trezor signing can complete funding bookkeeping when retrying after an ambiguous network failure, without relying on a signer-provided txid. Duplicate-response classification is a focused, case-insensitive helper that does not turn relay-policy or invalid-transaction rejections into success. Connectivity failures, unrelated broadcast rejections, invalid hex, and invalid transaction data keep their existing typed BroadcastError variants. There is no FFI signature change. Refs #122
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Collaborator
Author
|
Release created for testing here. |
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.
Summary
Retrying an already-accepted raw broadcast previously could not recover the txid.
broadcast_raw_txnow computes the transaction's canonical txid locally and returns it on success. When Electrum reports the transaction is already known (already in a block, in the mempool, or otherwise accepted), that response is treated as success and the same locally computed txid is returned.This lets the native apps complete Blocktank funding bookkeeping after an ambiguous network failure without relying on
TrezorSignedTx.txid, which is intentionally unset during pure hardware signing. The change is self-contained in the onchain module, has no dependency on trezor-connect-rs, and makes no FFI API shape change.Changes
decode_and_compute_txid: decodes hex, validates the transaction, and computes the canonical txid (returns the txid, never the wtxid).is_already_known_broadcast_error: a focused, case-insensitive classifier for duplicate/already-accepted Electrum responses. It does not turn relay-policy or invalid-transaction rejections into success.broadcast_raw_txto return the locally computed txid on a fresh broadcast and on an already-known response. Connectivity failures, unrelated broadcast rejections, invalid hex, and invalid transaction data keep their existing typedBroadcastErrorvariants.Handled already-known responses (case-insensitive):
already in block chain,already in blockchain,already in mempool,already-in-block-chain,already-in-mempool,txn-already-known,transaction already exists.Tests
cargo test,cargo clippy, andcargo fmtpass.Related