Repository navigation
feat(server): implement /acceptance/checkNote endpoint (#51) - #70
Open
ocakciomursel-pixel wants to merge 1 commit into
Open
ocakciomursel-pixel wants to merge 1 commit into
ocakciomursel-pixel wants to merge 1 commit into
Conversation
This was referenced Nov 1, 2026
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.
Fixes #51
Summary
Implements
POST /api/v1/acceptance/checkNoteinchaincash_serverso callers can submit a JSON-encoded ChainCash note and check whether the server accepts it under its configured[acceptance]predicates (Whitelist,Blacklist,Collateral, and recursiveOr), returning{"accepted": true|false}.Key Design Details
Supported JSON Note Formats
NoteWithHistoryJSON (exact round-trip output ofGET /api/v1/notes/walletandGET /api/v1/notes/byPubkey/:pubkey).ErgoBoxJSON (validated viachaincash_offchain::boxes::Note::from_box, enriching commitment history automatically when the box is already indexed inChainCashStore).ErgoBox+ Explicit Ownership History JSON ({"ergo_box": ..., "history": [...]}or{"box": ..., "history": [...]}): validates the note box contract/registers, reconstructsNoteHistory(supporting both 65-byte hex and byte-array Schnorr signatures), verifies the reconstructed AVL+ digest matches registerR4, and cryptographically verifies every reserve signature againstblake2b256(note_id_bytes || amount_be_bytes)when the reserve owner pubkey is known.NoteContextJSON ({"owner", "issuer", "nanoerg", "liabilities"}).R4AVL digests, or invalid reserve signatures return400 Bad Request.Gold-to-NanoErg Valuation & Monotone Oracle Short-Circuiting
gold_amount_mg), whereas reserve values are stored innanoErg.Collateralpredicates, note and liability amounts are converted tonanoErgusing either a storedDenominationrow (whendenomination_idis present) or the ChainCash Gold Oracle box (R4 / 1_000_000nanoErgper mg of gold, matchingTransactionService::redeem_note).Whitelist,Blacklist,Collateral,Or) are monotone with respect to collateral backing,checkNotefirst evaluates predicates against a zero-collateral provider and short-circuits immediately whenWhitelist/Blacklist/Orbranches already accept—avoiding unnecessary Ergo node HTTP calls.Accurate
CollateralAccounting & Split-Change Preservationergo_box_idforErgoBoxpayloads, or at most one matching stored row forNoteWithHistorypayloads) so stored notes are never double-counted while sibling split-change notes sharing the samenote_idtoken identifier remain properly counted inissuer_note_tally.Blacklistevaluation so unresolved/emptyissueror historicalsignerpubkeys cannot falsely passIssuerorHistoricalblacklist checks, and fixes a nested SQLite pool checkout inNoteRepository::get_by_box_id.Verification
cargo fmt --all -- --checkcargo clippy --all-featurescargo test(34 passed, 0 failed — including 10 new end-to-end asyncacceptance::testscovering wallet JSON round-trip, rawErgoBox, cryptographic Schnorr signature +R4AVL verification, Gold Oracle conversion, split-change note accounting, intermediate historical signer collateralization, offline-oracleOrshort-circuiting, and400 Bad Requestvalidation)