Commit Graph
70 Commits
Author SHA1 Message Date
j-berman ed461a6dde FCMP++: output_to_pre_leaf_tuple 2026-07-21 02:36:01 -07:00
j-berman 99bda32d0f FCMP++: output_to_tuple {output pubkey, commitment} -> {O,I,C}
- Function to convert an {output pubkey, commitment} to an output
tuple {O,I,C} in prepartion to insert the output tuple into the
curve tree.
- O = torsion cleared valid output pubkey checked for identity.
- I = key image generator.
- C = torsion cleared valid Commitment checked for identity.
- None of {O,I,C} should have torsion nor == identity.
- Introduces the OutputPair variant, which can either be Legacy
or Carrot V1 types. Legacy outputs are not checked for torsion
at consensus, and use the legacy biased hash to point fn to derive
the key image generator (I). Carrot V1 outputs **are** checked for
torsion at consensus, and use the unbiased hash to point to derive
the key image generator (I).
2026-07-21 02:35:55 -07:00
0afd50cc51 crypto: derive key image generator & separate {un}biased hash to ec
https://github.com/monero-project/research-lab/issues/142

Co-authored-by: Jeffro <jeffro256@tutanota.com>
Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
2026-07-15 10:34:42 -07:00
j-berman b61c750029 crypto: ed25519 -> Wei conversion 2026-07-08 06:34:40 -07:00
j-berman 79a996be02 crypto: torsion clearing for FCMP++ 2026-07-07 14:32:13 -07:00
j-berman 13db615bb8 Daemon RPC: /getblocks.bin incremental pool fetch even when no new blocks 2026-06-30 12:15:22 -07:00
j-berman 9f52166804 crypto: fe_reduce_vartime 2026-06-29 16:18:03 -07:00
j-bermanandJeffro 4f2a8a4270 crypto: fast fe_batch_invert using Montgomery's trick
https://iacr.org/archive/pkc2004/29470042/29470042.pdf 2.2

Also includes:
- fe_equals function
- breaks out fe_from_bytes_vartime function

Co-authored-by: Jeffro <jeffro256@tutanota.com>
2026-06-29 12:41:39 -07:00
j-bermanandNavid Rahimi 1aea9cc256 tx_pool: track sensitive flag per-tx in added_txs_by_id
Replace the plain time_t map value with an added_tx_info struct that
stores both receive_time and a sensitive flag. Thread the flag through
all add_tx_to_transient_lists call sites so incremental RPC queries
can skip sensitive transactions.

Reported-by: selsta
2026-05-21 20:37:59 +01:00
j-berman ea14a60854 daemon: on exit, stop the payload handler before closing cxns 2026-04-29 11:43:16 -07:00
j-berman a46154e6a8 p2p: cleaner connection close() 2026-04-28 22:22:09 -07:00
j-berman 17ce9ac0df p2p: wait_for on shutdown instead of indefinite wait 2026-04-28 16:20:44 -07:00
j-berman d29ffb9616 tx_pool: notify txpool event when stem bumps to fluff 2026-04-24 09:02:45 -07:00
j-berman b4ba1ec69c cryptonote_protocol: cleanup_handle_incoming_blocks on scope exit 2026-04-21 12:07:59 -07:00
j-berman 94089a8788 cryptonote_basic: pruned hash return bool 2026-04-21 12:04:31 -07:00
j-berman 0150d45e39 connection: try-catch handles 2026-04-21 12:00:56 -07:00
j-berman 742c62928a p2p: fix hanging shutdown 2026-03-25 13:27:44 -07:00
j-berman 247af5e8a3 cryptonote_core: try-catch in prepare same as cleanup 2026-03-18 23:02:33 -07:00
j-berman ede4d7faef RingCT crypto: 6x faster zero commit 2026-02-17 15:40:55 -08:00
j-berman 7d1f779530 p2p: connection patches
- Make sure the server sends a complete response when the client
includes the "Connection: close" header.
- Make sure the server terminates in `m_strand` to avoid
concurrent socket closure and ops processing.
2026-01-15 22:30:43 -08:00
j-berman ab9bc6499c wallet2: fix edge case where tx's ki's remain marked unspent
If a tx is marked as failed (because it never shows up in the
daemon's pool), its key images get reset back to unspent so they
can be used in future txs.

If the tx re-enters the daemon's pool (e.g. it's removed from the
pool and then relayed back), then the wallet incorrectly maintains
that the tx's key images are unspent.

This change ensures the wallet re-marks the tx's key images as
spent if the tx re-appears in the node's pool.
2025-12-12 09:15:48 -08:00
j-berman d7c5f95704 p2p: fix race causing dropped connections during sync
Without this commit:
1) read height from DB
2) add block to chain in separate thread
3) read chain for block id's and request them from peer
4) ERR in handle_response_chain_entry, peer's first block is the
one that was added to the chain, which has block idx=height from
step 1.

This commit reads the chain for height and highest block id's
in one go while holding the m_blockchain_lock to avoid the race.
2025-12-11 21:36:42 -08:00
j-berman 1fd6f275da Daemon: relay empty fluffy block on found block 2025-11-11 16:37:36 -08:00
j-berman a378b59628 tx pool: only increment m_txpool_weight for newly added pool txs
Otherwise we can end up double counting txs towards the weight,
which can over-state the pool weight. E.g. relay tx to node in
stem phase, add its weight to pool weight, then receive tx
from another node, then bump the pool weight again. That double
counts the tx towards the pool weight.

If the weight exceeds the max, the node will "prune" txs from the
pool. Thus, over-counting is probably a cause of, but perhaps
not the only cause of:
https://github.com/seraphis-migration/monero/issues/148
2025-11-11 16:31:01 -08:00
j-berman c01e1fa288 Fix logging deadlock 2025-11-11 10:43:39 -08:00
j-berman 4a2d6eb3da Daemon RPC: getblocks.bin block_ids_exclusive req param
When the request includes block_ids, the daemon uses
find_blockchain_supplement to identify the highest block hash
passed in block_ids that the daemon also knows about, and then
serves subsequent blocks contiguous to that block.

When block_ids_skip_exclusive is false (default current
behavior), the daemon includes the highest block requested in the
response, in addition to contiguous blocks after it.

When block_ids_skip_exclusive is true (new param), the daemon
serves blocks starting from the block 1 higher than the highest
known block included in block_ids. Thus, the daemon skips the
common block known to the client and daemon. Clients can make sure
the daemon is serving expected contiguous blocks to its highest
known block by checking the first block's prev_id included in the
response, and making sure it is equivalent to the block the client
already knows about that was included in block_ids. This avoids
the daemon serving 1 extra block it does not need to serve to the
client, since the client should already know about that block.

bl
2025-10-10 01:21:52 -07:00
j-berman 292c053280 Cleaner validation (faster and saner) 2025-10-06 12:51:16 -07:00
j-berman be79b83b4e Daemon RPC: fix on_getblockhash error return on too high height 2025-09-25 16:18:22 -07:00
j-berman 1dbb4a7928 wallet2: warn instead of throw when RingDB doesn't include spend
A reorg can end up causing an output's position in the chain to
move. Since the wallet doesn't update the RingDB on reorg, it
may refer to the output's stale position in the chain.

This seems a reasonable solution rather than introducing complex
logic to update the stale ring member's value on rerog, since
RingDB can be deprecated with FCMP++.
2025-09-17 15:21:46 -07:00
j-berman daded36823 wallet: identify spends in pool when scanning
- Make sure to mark identified spends in the pool as spends. The
wallet might not know these have been spent if it wasn't the wallet
that relayed the tx to the daemon, or the wallet was cleared via
rescan_bc.
- Make sure to add spends to m_unconfirmed_txs if not present.
- Make sure to process the entire pool again if refreshing for
the first time. The wallet fetches pool and blocks at the same
time. The wallet scans blocks first, then pool. If the wallet
identifies received outputs in the chain, then it may have spent
those received outputs in the pool. So we make sure to re-process
the entire pool again after scanning the chain for the first time.
- Multisig wallets that know about spent key images can now detect
spend txs in the pool. Update tests for that.
2025-09-15 14:14:50 -07:00
j-berman a8959f2c9b Daemon RPC: rm high_height_ok field from getblocks.bin
Since current behavior on release is to ban clients with too
high a height included in the request, it seems reasonably
justified to modify that behavior to instead return a successful
response that includes the chain height and top block hash.
2025-08-06 12:45:49 -07:00
Justin Bermanandnahuhh 6e26e4477e wallet: improve lookahead logic & make rpc persistent 2025-07-07 22:16:09 +00:00
j-berman 3b64d1f558 functional tests: fix race in restore wallet refresh 2025-01-23 11:37:48 -08:00
j-berman 98decee8ac wallet2: remove refresh() from scan_tx
Fixes #9354
2025-01-14 13:37:46 -08:00
j-bermanandjeffro256 e866a192dd wallet2: move wallet error on RPC resp handling to wallet_errors file
Co-authored-by: jeffro256 <jeffro256@tutanota.com>
2024-10-29 10:56:11 -07:00
j-berman df54d8b3d4 Daemon RPC: add max_block_count field to /getblocks.bin 2024-10-29 10:40:46 -07:00
j-berman 9f83e7434d Daemon RPC: /getblocks.bin return chain's top_block_hash in resp 2024-06-24 17:58:20 -07:00
j-berman 6c28bdb856 wallet2: move get_rpc_status func to RPC server definition file 2024-06-24 17:44:23 -07:00
j-berman 356829a198 Daemon RPC: high_height_ok req boolean field /getblocks.bin
Behavior before: when start_height > chain tip, response fails

Behavior after: when req.high_height_ok is true && req.start_height
> chain tip, server rerturns a successful response that includes
chain height
2024-06-24 16:47:06 -07:00
j-berman e71c8bf190 wallet: background sync with just the view key
- When background syncing, the wallet wipes the spend key
from memory and processes all new transactions. The wallet saves
all receives, spends, and "plausible" spends of receives the
wallet does not know key images for.
- When background sync disabled, the wallet processes all
background synced txs and then clears the background sync cache.
- Adding "plausible" spends to the background sync cache ensures
that the wallet does not need to query the daemon to see if any
received outputs were spent while background sync was enabled.
This would harm privacy especially for users of 3rd party daemons.
- To enable the feature in the CLI wallet, the user can set
background-sync to reuse-wallet-password or
custom-background-password and the wallet automatically syncs in
the background when the wallet locks, then processes all
background synced txs when the wallet is unlocked.
- The custom-background-password option enables the user to
open a distinct background wallet that only has a view key saved
and can be opened/closed/synced separately from the main wallet.
When the main wallet opens, it processes the background wallet's
cache.
- To enable the feature in the RPC wallet, there is a new
`/setup_background_sync` endpoint.
- HW, multsig and view-only wallets cannot background sync.
2024-05-24 23:11:58 -07:00
j-berman 427ba7702f wallet2: ensure transfers and sweeps use same fee calc logic rnd2
Looks like the logic from #8882 was accidentally removed in #8861
(regressing to the behavior noted in the #8882 description).
This commit brings that logic back.
2024-03-22 14:05:17 -07:00
j-berman 47042ce808 wallet2: call on_reorg callback in handle_reorg 2023-09-26 20:37:11 -07:00
j-berman 759293de08 wallet2: fix version check at hf version 1 2023-08-17 13:29:46 -07:00
j-bermanandwoodser f7fb5c7faa scan_tx: fix custom comparator for == case; fixes #8951
Co-authored-by: woodser <woodser@protonmail.com>
2023-07-19 07:48:29 -07:00
j-berman e6b86af931 wallet2: fix rescanning tx via scan_tx
- Detach & re-process txs >= lowest scan height
- ensures that if a user calls scan_tx(tx1) after scanning tx2,
the wallet correctly processes tx1 and tx2
- if a user provides a tx with a height higher than the wallet's
last scanned height, the wallet will scan starting from that tx's
height
- scan_tx requires trusted daemon iff need to re-process existing
txs: in addition to querying a daemon for txids, if a user
provides a txid of a tx with height *lower* than any *already*
scanned txs in the wallet, then the wallet will also query the
daemon for all the *higher* txs as well. This is likely
unexpected behavior to a caller, and so to protect a caller from
revealing txid's to an untrusted daemon in an unexpected way,
require the daemon be trusted.
2023-06-15 02:21:29 -07:00
j-berman a8d2a58190 wallet2: ensure transfers and sweeps use same fee calc logic
Ensures both transfers and sweeps use a fee that's calculated
from the tx's weight. Using different logic could theoretically
enable distinguishability between the two types of txs. We don't
want that.
2023-05-27 07:27:54 -07:00
j-bermanandrbrunner7 c4af33eded Enforce restricted # pool txs served via RPC + optimize chunked reqs
- `/getblocks.bin` respects the `RESTRICTED_TX_COUNT` (=100) when
returning pool txs via a restricted RPC daemon.
- A restricted RPC daemon includes a max of `RESTRICTED_TX_COUNT` txs
in the `added_pool_txs` field, and returns any remaining pool hashes
in the `remaining_added_pool_txids` field. The client then requests
the remaining txs via `/gettransactions` in chunks.
- `/gettransactions` no longer does expensive no-ops for ALL pool txs
if the client requests a subset of pool txs. Instead it searches for
the txs the client explicitly requests.
- Reset `m_pool_info_query_time` when a user:
  (1) rescans the chain (so the wallet re-requests the whole pool)
  (2) changes the daemon their wallets points to (a new daemon would
      have a different view of the pool)
- `/getblocks.bin` respects the `req.prune` field when returning
pool txs.
- Pool extension fields in response to `/getblocks.bin` are optional
with default 0'd values.
2023-03-07 20:35:45 +01:00
j-bermanandBotoX 6c73dc742e properly terminate interrupted TCP connection. fixes #8685 2023-02-04 22:03:51 +01:00
j-berman 1a3ae18ef9 p2p: fix back ping to discover healthy peers to connect to 2022-11-14 16:54:45 -08:00
j-berman cac5083427 wallet2: fix create view-only wallet from existing wallet 2022-10-18 13:48:43 -05:00
j-berman e9ce347f83 wallet2: fail to establish daemon cxn == "Disconnected" cxn status 2022-09-21 21:54:57 -06:00
j-berman b8271ab881 wallet2: check wallet compatibility with daemon's hard fork version 2022-09-12 21:24:24 -06:00
j-berman eca7f6ae98 Fix segfault restoring encrypted multisig seed 2022-09-07 17:24:03 -06:00
j-bermanandwoodser 76a5b54d58 Fix missing semi-colon in error message
Co-authored-by: woodser <woodser@protonmail.com>
2022-09-06 18:41:16 -06:00
j-berman f713c3c335 Require user ack multisig is experimental to restore 2022-09-06 11:59:28 -06:00
j-berman 564a7a31e8 multisig: fix #8537 seed restore (suggestions by @UkoeHB)
- spend secret key is no longer the sum of multisig key shares;
no need to check that is the case upon restore.
- restoring a multisig wallet from multisig info means that the
wallet must have already completed all setup rounds. Upon restore,
set the number of rounds completed accordingly.
2022-09-06 11:59:25 -06:00
j-bermanandmoneromooo-monero 1e912ecd8a wallet2: fixes for export/import output flow
- only allow offline wallets to import outputs
- don't import empty outputs
- export subaddress indexes when exporting outputs
2022-08-16 14:22:42 +00:00
j-berman 04a1e2875d ledger support for hf 15 (BP+, view tags) 2022-08-06 15:00:49 -07:00
j-berman 1fc60cac58 Publish submitted txs via zmq 2022-07-21 11:36:00 -07:00
j-berman cf3be9926f Template hash func to fix compiler error on < gcc-6 2022-07-13 22:44:43 -07:00
j-berman a82fba4b7b address PR comments 2022-07-08 15:10:03 -07:00
j-berman bd1e7c5635 wallet2: prevent crash when reading tx w/fewer outputs than expected 2022-07-05 21:39:59 -07:00
j-berman 628fdcdd49 continue pool pruning even if a tx can't be found 2022-07-01 09:44:58 -07:00
j-berman 8460fcc32b Revert "Merge pull request #7937"
This reverts commit 50410d1f7d, reversing
changes made to d054def63f.
2022-06-13 18:44:09 +01:00
j-berman 2dab31f62f Don't exclusively drop tor/i2p outgoing cxns in idle loop 2022-05-18 09:54:21 -07:00
j-berman b9d2c788bc fix backoff delay logic when re-relaying txs 2022-05-12 08:39:51 -07:00
j-berman bae4a1ad8f Don't send peerlist larger than max allowed 2022-05-11 18:41:24 -07:00
j-berman 7d6c7489a7 Set hf v15 testnet fork heights 2022-05-09 14:38:54 -07:00
j-berman 5d388eb74d Bump ring size to 16 for v15 & remove set default in wallet cli 2022-04-18 14:36:28 -07:00
j-berman ea87b30f89 Add view tags to outputs to reduce wallet scanning time
Implements view tags as proposed by @UkoeHB in MRL issue
https://github.com/monero-project/research-lab/issues/73

At tx construction, the sender adds a 1-byte view tag to each
output. The view tag is derived from the sender-receiver
shared secret. When scanning for outputs, the receiver can
check the view tag for a match, in order to reduce scanning
time. When the view tag does not match, the wallet avoids the
more expensive EC operations when deriving the output public
key using the shared secret.
2022-04-18 00:49:53 -07:00