54 Commits

Author SHA1 Message Date
Alan Szepieniec
edf7800a88 security: Add attack binary
Add a binary that deploys a flooding attack.

Also, add a binary that periodically queries a random URL from the website. This
scraper will be used to measure whether the attack (or its countermeasure) is
effective.
2025-10-09 18:32:51 +02:00
sword-smith
ec6d99e9d0 refactor: Change supply return type from f64 to i32
On the request of some aggregator that allegedly wanted the number in
total number of coins, not in the atomic units.
2025-10-03 00:13:08 +02:00
sword-smith
349f0705d3 chore: Update neptune-cash dependency 2025-10-03 00:03:01 +02:00
sword_smith
21bb64a276
feat: Add endpoint for total supply
Total supply is defined as liquid supply plus timelocked supply.
2025-10-02 17:29:04 +02:00
sword_smith
d22fe50de6
feat: Add endpoint for circulating supply 2025-10-02 15:57:38 +02:00
sword_smith
552923ae40
chore: Update neptune-core dependency
Also: format imports.
2025-10-02 15:56:49 +02:00
Alan Szepieniec
817835302b fix(RPC): Encode hashmap as list for transmission
In commit 1096a293 on neptune-core, the return type of RPC endpoint
`addition_records_for_block` changes from `HashMap` to `Vec`. This
commit applies the matching change on the side of the client,
including building the original hashmap from the transmitted list.

These commits (the present one and the one referenced) fix the issue
that transparent transaction info could not be transferred across the
RPC layer.
2025-08-23 10:31:34 +02:00
Alan Szepieniec
847e4f1e3d feat: Add link to source code
Co-authored-by: Thorkil Schmidiger <thor@neptune.cash>
2025-08-22 16:40:26 +02:00
Alan Szepieniec
1de0c69405 chore(README.md): Clarify roles of site name and domain 2025-08-22 16:38:30 +02:00
Alan Szepieniec
e7c7fcc91f deps: Point to github and not local disk 2025-08-22 16:38:30 +02:00
Alan Szepieniec
863433cb77 style: Simplify mock logic in UTXO RPC relayer
Ignore the "MOCK" environment flag. Use the cache only if the node
does not know the UTXO and the "mock" feature flag is set. It is safe
to rely on node's response when the feature flag is not set because
the only case in which the cache contains an entry that the node does
not know about is when it was imagined previously, which can only
happen if mocking is enabled.
2025-08-22 16:38:30 +02:00
Alan Szepieniec
e2740b05ee feat: Show and link confirming and spending blocks 2025-08-22 16:38:30 +02:00
Alan Szepieniec
35506534f7 fix: Copy cache pointer on RPC client reset
The disappearing cache was the result of creating a new smart pointer
to a new cache every time the RPC client was switched. Fixed by
cloning the smart pointer to the cache whenever the RPC client gets
reset.

No need for persistence.
2025-08-22 16:38:30 +02:00
Alan Szepieniec
c7be96a52c chore: Add TransparentUtxoTuple
Used for caching.
2025-08-22 16:38:30 +02:00
Alan Szepieniec
55b9b8792c feat: Cache transparent UTXOs
Whenever an `Announcement` is parsed as transparent transaction info, we obtain
information about the UTXOs involved in that transaction. It would be nice to
display this information when we look up the UTXO, but there is no way to query
it from neptune-core.

This commit caches that information in order to display it.

Specifically, it extends `AppState` with a (smart pointer to) vector of
`TransparentUtxoInfo` (a new type). The vector, or its existing entries, are
extended with new information when it becomes available.

At this point the vector is rather silly because it is not persisted, and the
app reboots more often than not, resulting in a clear cache. A future commit
will persist this data.
2025-08-22 16:38:30 +02:00
Alan Szepieniec
d840347b0f style: Do not show inputs or outputs table if empty 2025-08-22 16:38:30 +02:00
Alan Szepieniec
86698687a8 feat: Add Announcement viewer
Every transaction can have zero or more announcements, which are essentially
messages that must be included across all future mergers and updates.
Announcements are typically used for transmitting information related to
receiving UTXOs, encrypted. However, a new use case is that of *transparent
transaction info*, which is an announcement containing the UTXOs and the
commitment randomnesses needed to reproduce the transaction's inputs and
outputs. With such a transparent transaction info announcement, third parties
can transparently audit transactions.

This commit adds a page for viewing announcements, and if the announcement can
be parsed as a transparent transaction info type announcement then it is
rendered as such, complete with native currency amounts and linkable UTXOs
(where possible).

The path for accessing announcements is any of
 - `/announcement/digest/<hex-string>/<index>`
 - `/announcement/tip/<index>`
 - `/announcement/genesis/<index>`
 - `/announcement/height/<height>/<index>`
 - `/announcement/height_or_digest/<height-or-diges>/index/<index>`.
The last bullet point exists to support the quick lookup functionality, which is
also new. A `AnnouncementSelector` has display and from-string methods relating
these path formats to the relevant object. A suite of (prop)tests verifies
parsing.

Also, this commit enables mocking, which is useful when the neptune-core node
the explorer is connected to is outdated, unsynced, or for whatever reason does
not serve the desired data. The RPC client call is intercepted, and if it fails
and mocking is enabled, an imagined (pseudorandom) resource of the requested
type is returned. To enable mocking, compile with the "mock" feature flag and
set the "MOCK" environment variable.
2025-08-22 16:38:30 +02:00
Thorkil Værge
8fa76ec8a3
Merge pull request #14 from Neptune-Crypto/pow-puzzle-endpoint
Pow puzzle endpoint
2025-08-21 09:33:17 +02:00
sword-smith
5c81a94487 Add endpoint for providing a PoW solution 2025-08-21 09:10:40 +02:00
sword-smith
1d8aa52902 Add endpoint for fetching address-specific pow puzzle 2025-08-21 08:48:39 +02:00
Alan Szepieniec
67962a5d12 chore: Upgrade to neptune-core v0.3.0 2025-08-05 22:29:11 +02:00
aszepieniec
df61019183
feat: Display block size (in # BFieldElements) 2025-03-24 13:04:30 +01:00
Alan Szepieniec
e80a89d601 feat: Display block size (in # BFieldElements) 2025-03-24 13:03:21 +01:00
danda
8694e03357 feat: return 401 Unauthorized for rpc auth error 2025-01-22 22:20:51 -08:00
danda
8a79c578c2 refactor: implement rpc authentication
closes #8

neptune-core RPC methods now require an authentication token.

This implements auth support in neptune-explorer.
2025-01-22 21:00:11 -08:00
danda
af5496ed11 feat: monitor for stalled chain and send alert
closes #7.

adds a blockchain watchdog that checks every hour if the tip height has
advanced or not.  Sends alert email if height is less or equal to
height at the last check and enters a warning mode.  In warning mode
it waits until the height is greater than previous, and then sends a
recovery alert and switches to normal mode.
2024-12-31 17:39:11 -08:00
danda
dd7e80298d feat: display coinbase amount, other misc
Closes #5
Addresses #6

changes:
 * field Mining Reward --> Coinbase. (actual reward)
 * add field Expected Coinbase  (expected/calced reward)
     this field only displays if different from actual coinbase.
 * add field Cumulative Proof-of-Work
 * change tooltip 🛈   -->  ⓘ .  for mobile devices. (hopefully)
 * css: make tooltip text bold, so the ⓘ  is stronger.
2024-12-20 21:58:59 +08:00
danda
f293d4e6bb feat: display links to sibling blocks, if any
closes #2
2024-12-18 14:17:22 +08:00
danda
ebcfdb947c feat: display if block in canonical chain or not
Adds a 'Canonical' field to the /block page.

note: this requires updating neptune-core in order to obtain the field
from neptune-core's /block_info rpc endpoint.

it was also necessary to change 'use neptune_core::<x>" statements to
'use neptune_cash::<x>'
2024-12-18 12:15:38 +08:00
danda
0bc81d2382 chore: update for neptune-core betanet
updates some deps and one minor code change since uncle
blocks no longer occur.
2024-11-23 00:47:36 +00:00
danda
508f6ecc28 feat: add --smtp-port
Enables changing the smtp-port for alert emails.

Also enables two additional smtp modes: opportunistic and plaintext.
2024-05-28 15:39:46 -07:00
danda
938f12a943 docs: add note about pkg-config and libssl-dev 2024-05-28 13:06:59 -07:00
danda
ea2a21596d style: change logo image
Now uses neptune-logo-circle-small.png, which appears much cleaner
especially on dark theme.
2024-05-28 08:58:46 -07:00
danda
c2fe657e04 perf: replace RwLock with ArcSwap
ArcSwap is lock-free and optimized for our use-case of lots of
concurrent reads and infrequent updates.

So it is pretty close to a shared-nothing architecture.

Some small changes were necessary, but its mostly a drop-in
replacement for RwLock.
2024-05-27 17:24:01 -07:00
danda
71cf752b41 feat: add neptune-core rpc connection watchdog
closes #1

Implements a background watchdog task that:
1. calls neptune-core /network rpc every N seconds (default: 10)
2. emits log message on any state change
3. sends detailed email alert to admin on any state change

Changes:
* AppState now has internal Arc<RwLock<AppStateInner>> to permit
  watchdog task to mutate the rpc_client field.
* adjust application to AppState changes (use locks)
* not_found functions no longer accept state arg
* move state initialization into AppState::init()
* add optional alert parameters: admin-email, smtp-*
* add neptune_rpc module with watchdog task
* add alert_email module
* simplify main()
* log warnings if alert parameters not set
* add chrono dep
* add lettre dep
2024-05-25 19:16:36 -07:00
danda
d99fe3ff84 feat: add --listen-port and rename --port
Changes:
 * adds --listen-port for specifying http port to listen on.
 * renames --port to --neptune-rpc-port which is clearer
 * updates README accordingly
2024-05-22 19:41:21 -07:00
danda
e4fda1a806 refactor: add anyhow, remove unwrap/expect
converts unwrap and expect calls in main.rs into anyhow .with_context()
calls to provide better error messages
2024-05-22 19:39:46 -07:00
danda
7dfe9366be doc: add README.md 2024-05-22 17:46:42 -07:00
danda
01906060ab doc: update and move design notes 2024-05-22 17:18:51 -07:00
danda
0c54b50b83 refactor: use wildcard paths, remove dup handlers
We use axum route wildcards to merge duplicate page routes and handlers
into a single route and handler.

This makes the routes simpler/cleaner as well as the handlers, as there
is now just one of each for each html page.

Previous:
   .route("/block/:selector", get(block_page))
   .route("/block/:selector/value", get(block_page_with_value))

New:
   .route("/block/*selector", get(block_page))

This is achieved by replacing PathBlockSelector with
BlockSelectorExtended which wraps BlockSelector to provide parsing for
height_or_digest/value.  (which is needed for javascript-free input
form)

Changes:
 * merge dup handlers for each of block, block_digest, block_info
 * merge routes for same
 * add BlockSelectorExtended and HeightOrDigest
 * remove PathBlockSelector
2024-05-22 17:18:51 -07:00
danda
6fedadab47 style: blue logo edges, better for dark theme
Previously the logo looked very jagged against a dark background.

This makes it look smooth for dark theme. However it is a bit blurry
against white background.

Hopefully can replace with a higher quality graphic soon.
2024-05-22 17:18:51 -07:00
danda
29834dbe50 feat: get rid of all javascript
implements a generic solution to redirect query strings generated by
forms to path based URIs that can be handled by existing routes.

This eliminates the need for javascript that was doing the equivalent
client-side.
2024-05-22 17:18:51 -07:00
danda
22f06180ae style: make text fit aqua color scheme
Uses a dark aqua for light theme and aqua for dark theme.
2024-05-22 17:18:51 -07:00
danda
df14092d61 feat: make site name configurable
Changes:
 + add Config::site_name, which defaults to "Neptune Explorer"
 + remove HeaderHtml::site_name
 + use Config::site_name in the html templates
2024-05-22 17:18:51 -07:00
danda
48966fa69d chore: include head html component in all pages
Moves common <head>..</head> tags into componenents/head.html and
includes it from all pages.

Common elements include: css files, favicon, meta tag(s)
2024-05-22 17:18:51 -07:00
danda
faf303bbdd feat: integrate team feedback
Changes:
 + present not-found page for unhandled uri paths, eg /stuff
 + display the tip-height on front page
 + add favicon and neptune logo to front page
 + use ServerDir instead of ServeFile for /image and /css
 + add help tooltips for fields on front page
 + use monospace font for digests
2024-05-22 17:18:51 -07:00
danda
d7d1778fea fix: add missing files 2024-05-22 17:18:51 -07:00
danda
ac27329bda chore: update to neptune-core tip
adapts to some changes in neptune-core.

BlockInfo and BlockSelector location changed.
2024-05-22 17:18:50 -07:00
danda
0f9cbdf0b4 feat: pico css styling and not-found page.
Changes:

 1. integrates pico minimal responsive css framework for light/dark
    themes and overall better looks.

 2. adds a not-found page for bad url queries.

 3. catches axum/serde deserialization errors of user input and routes
    them to the not-found page with a helpful hint (parse error msg)
2024-05-22 17:18:50 -07:00
danda
e53d80d9fa chore: move src/web --> templates/web 2024-05-22 17:18:50 -07:00