Skip to content

Save a transaction secret reported after the file exists - #735

Open
j0ntz wants to merge 1 commit into
masterfrom
jon/monero-tx-key
Open

Save a transaction secret reported after the file exists#735
j0ntz wants to merge 1 commit into
masterfrom
jon/monero-tx-key

Conversation

@j0ntz

@j0ntz j0ntz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

A transaction's secret lives in its metadata file and nowhere else: setupNewTxMetadata writes txFile.secret, and combineTxWithFile reads txSecret back from file.secret alone. That file is written once, the first time the core sees a transaction, so a secret an engine learns any later than that was simply dropped, and a transaction already on file could never gain one.

Monero is where this bites. A Monero wallet only knows a transaction key once it has built the transaction, and it can report keys for transactions the core saved back when the engine reported none. The key is the sender's only proof of a payment, and it cannot be recovered from the seed, so dropping it is permanent.

saveTxSecret saves such a secret onto the existing file:

  • It runs ahead of the unchanged-transaction check, because mergeTx does not carry the secret: a transaction that gained one still compares as unchanged and would be skipped. For the same reason it reports the transactions it saved itself, so a listener does not keep holding one with no secret.
  • It reads the file from disk when fileNames lists it but files does not. Transaction files only load when somebody asks for the transactions, so the old transactions this exists for normally have no file in memory.
  • It writes to disk before reporting the file as changed, so a failed write cannot leave the in-memory copy claiming a secret that never landed, which would make every later report skip the transaction.
  • An existing secret is never replaced. Only the wallet that built a transaction can produce its secret, so a disagreement means the stored one is no less trustworthy, and overwriting would let a re-sync of bad data destroy a good key.

withTxFile serializes the load-modify-write cycles over a single transaction file, shared with updateCurrencyWalletTxMetadata. Both writers rewrite the whole file from a snapshot, so interleaved they could each drop the other's change.

Companion fix in the Monero engine: EdgeApp/edge-currency-accountbased#1086

Asana: https://app.asana.com/0/1215088146871429/1216965258637021

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e7b193b0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/currency/wallet/currency-wallet-files.ts Outdated
Comment thread src/core/currency/wallet/currency-wallet-files.ts Outdated
Comment thread src/core/currency/wallet/currency-wallet-callbacks.ts
@j0ntz
j0ntz force-pushed the jon/monero-tx-key branch 2 times, most recently from 64c17ee to 92ca08d Compare August 12, 2026 02:33

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 92ca08d. Configure here.

Comment thread src/core/currency/wallet/currency-wallet-files.ts Outdated
Comment thread src/core/currency/wallet/currency-wallet-files.ts Outdated
Comment thread src/core/currency/wallet/currency-wallet-callbacks.ts Outdated
A transaction's secret lives in its metadata file and nowhere else, and
that file is written once, when the transaction is first seen. An engine
that learns a secret later had no way to hand it over: the merged
transaction drops the secret, so a transaction that gained one compares as
unchanged and is skipped.

Save the secret before that check, and never replace one already on file.
@j0ntz
j0ntz force-pushed the jon/monero-tx-key branch from 92ca08d to 81eaea0 Compare August 12, 2026 02:45
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.

1 participant