Coins

Coins
Source snapshot: 9b4f8a3 (2026-09-23); retained QMail clone, including M7.
Working = implemented in this snapshot, not a new runtime/test certification.
Partial = an identified implementation/exposure gap; obsolete = retained compatibility only.
Entry points and static functions are selected navigation anchors; full lexical index: function-index.txt.
Used by / Tests list selected source references (including callback registration), not a proven dynamic call graph.
Tests were inspected, not executed; use tools/test.ps1 with isolated scratch data.
Old paths come from docs/path-map.txt; absent mappings denote additions after the move.

Coin file I/O

Purpose
Read and write CloudCoin files; encode filenames, denomination values and last-known POWN state.
Files
src/coin/coin_file.c src/coin/coin_filename.c src/coin/coin_denom.c src/coin/coin_pown.c src/coin/folder_types.c
Old paths
vendor/core/src/coin_file.c -> src/coin/coin_file.c vendor/core/src/coin_filename.c -> src/coin/coin_filename.c vendor/core/src/coin_denom.c -> src/coin/coin_denom.c vendor/core/src/coin_pown.c -> src/coin/coin_pown.c vendor/core/src/folder_types.c -> src/coin/folder_types.c
Public header
include/core/cmd_pown.h include/core/coin_file.h include/core/coin_filename.h include/core/coin_utils.h include/core/folder_types.h
Entry points
src/coin/coin_file.c:331 :: coin_file_read() src/coin/coin_file.c:477 :: coin_file_write() src/coin/coin_denom.c:162 :: coin_denomination_to_microunits() src/coin/coin_filename.c:98 :: coin_filename_sanitize_tag() src/coin/coin_pown.c:17 :: coin_pown_encode_bytes() src/coin/folder_types.c:80 :: folder_type_to_name()
Important static functions
src/coin/coin_file.c:64 :: validate_header() src/coin/coin_file.c:121 :: t10_parse() src/coin/coin_filename.c:189 :: parse_value_microunits() src/coin/coin_filename.c:333 :: coin_filename_parse_task() src/coin/folder_types.c:63 :: strcasecmp_local()
Owns
Coin binary I/O, denomination conversion and folder labels.
Used by
src/app/client_inproc.c src/app/desktop_api_more.c src/coin/boot_encryption_check.c src/coin/encryption_key.c src/coin/health_manager.c src/coin/qmail_funding_runtime.c src/coin/qmail_locker_pool.c src/coin/t10_session.c
Side effects
Reads/writes coin files and transforms caller buffers; denomination arithmetic alone is pure.
Tests
tests/unit/coin/encryption_keys_wallet_test.c tests/unit/coin/make_change_budget_test.c tests/unit/coin/qmail_coin_select_test.c tests/unit/coin/qmail_funding_runtime_test.c tests/unit/coin/sdk/abi_check.c tests/unit/coin/sdk/link_check.c tests/unit/coin/sdk/rke_sdk_test.c tests/unit/coin/type10/t10_bulk_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Coin encryption session

Purpose
Keep the in-memory file key and export suppression state; derive Type 10 file encryption and select network encryption keys.
Files
src/coin/coin_crypto.c src/coin/type10_crypto.c src/coin/encryption_key.c src/coin/boot_encryption_check.c src/coin/crypto.c src/coin/sha256_util.c
Old paths
vendor/core/src/coin_crypto.c -> src/coin/coin_crypto.c vendor/core/src/type10_crypto.c -> src/coin/type10_crypto.c vendor/core/src/encryption_key.c -> src/coin/encryption_key.c vendor/core/src/boot_encryption_check.c -> src/coin/boot_encryption_check.c vendor/core/src/crypto.c -> src/coin/crypto.c vendor/core/src/sha256_util.c -> src/coin/sha256_util.c
Public header
include/core/boot_encryption_check.h include/core/coin_crypto.h include/core/crypto.h include/core/encryption_key.h include/core/sha256_util.h include/core/type10_crypto.h
Entry points
src/coin/coin_crypto.c:51 :: coin_crypto_init() src/coin/type10_crypto.c:23 :: t10_derive_key() src/coin/encryption_key.c:20 :: encryption_key_init() src/coin/boot_encryption_check.c:15 :: boot_encryption_check_clear() src/coin/crypto.c:41 :: crypto_aes128_ctr_crypt() src/coin/sha256_util.c:27 :: sha256_stream_free()
Important static functions
src/coin/encryption_key.c:269 :: build_wallet_search_list() src/coin/encryption_key.c:54 :: sn_is_excluded() src/coin/boot_encryption_check.c:21 :: scan_folder_encryption() src/coin/crypto.c:563 :: crypto_aes256_gcm_crypt_windows()
Owns
Session key lifetime and Type 10 crypto primitives.
Used by
src/app/desktop_api.c src/app/desktop_api_more.c src/coin/coin_file.c src/coin/drd_sync.c src/coin/header_v2.c src/coin/health_manager.c src/coin/protocol.c src/coin/qmail_funding_runtime.c
Side effects
Reads wallet keys, mutates synchronized encryption-session state and clears secret buffers; crypto helpers transform buffers.
Tests
tests/integ/hosting_adapter_test.c tests/integ/hosting_publication_test.c tests/integ/session_coordinator_test.c tests/integ/type9_gateway_test.c tests/live/large_send_live_probe.c tests/unit/long_path_transfer_test.c tests/unit/server_adapter_test.c tests/update/update_download_bundle_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working; Type 9 file crypto was removed; Content Server Type 9 is a separate protocol. Per-salt key cache remains future work per coin_crypto.h.

File-Unpacker

Purpose
Detect coin containers and split supported multi-coin/legacy input into single-coin files.
Files
src/coin/commands/cmd_unpack.c
Old paths
vendor/core/src/commands/cmd_unpack.c -> src/coin/commands/cmd_unpack.c
Public header
include/core/cmd_unpack.h
Entry points
src/coin/commands/cmd_unpack.c:229 :: unpack_file() src/coin/commands/cmd_unpack.c:307 :: unpack_import_folder() src/coin/commands/cmd_unpack.c:49 :: unpack_detect_file_type()
Important static functions
src/coin/commands/cmd_unpack.c:145 :: sn_index_load_folder() src/coin/commands/cmd_unpack.c:37 :: ensure_dir()
Owns
Unpack dispatch and per-coin output.
Used by
src/coin/commands/cmd_deposit.c
Side effects
Reads input files and writes single-coin output under wallet import processing.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
partial; ZIP and PNG extraction explicitly return not-implemented warnings in cmd_unpack.c; do not advertise full archive/image import.

Pown and Detect

Purpose
Authenticate coins across RAIDA and update ownership results.
Files
src/coin/commands/cmd_pown.c src/coin/commands/cmd_detect.c src/coin/commands/cmd_detect_hash.c
Old paths
vendor/core/src/commands/cmd_pown.c -> src/coin/commands/cmd_pown.c vendor/core/src/commands/cmd_detect.c -> src/coin/commands/cmd_detect.c vendor/core/src/commands/cmd_detect_hash.c -> src/coin/commands/cmd_detect_hash.c
Public header
include/core/cmd_detect.h include/core/cmd_detect_hash.h include/core/cmd_pown.h
Entry points
src/coin/commands/cmd_pown.c:425 :: pown_execute() src/coin/commands/cmd_pown.c:596 :: pown_execute_single() src/coin/commands/cmd_detect.c:242 :: detect_execute() src/coin/commands/cmd_detect.c:250 :: detect_execute_ex() src/coin/commands/cmd_pown.c:40 :: pown_generate_pans() src/coin/commands/cmd_detect.c:31 :: detect_build_body() src/coin/commands/cmd_detect_hash.c:33 :: detect_hash_compute_proof()
Important static functions
src/coin/commands/cmd_pown.c:104 :: build_pown_body() src/coin/commands/cmd_pown.c:149 :: build_pown_sum_body() src/coin/commands/cmd_detect.c:226 :: detect_body_builder() src/coin/commands/cmd_detect_hash.c:134 :: detect_hash_body_builder() src/coin/commands/cmd_detect.c:129 :: detect_primary_key() src/coin/commands/cmd_detect_hash.c:144 :: detect_hash_get_challenge()
Owns
POWN/Detect command bodies and result collection.
Used by
src/coin/health_manager.c src/coin/commands/cmd_convert.c src/coin/commands/cmd_deposit.c src/coin/commands/cmd_heal.c
Side effects
Command entry points can authenticate/change coins over RAIDA and write or move wallet files; file/crypto helpers also mutate buffers/session state.
Tests
tests/unit/coin/type10/detect_hash_test.c tests/unit/coin/type8/type8_detect_integration_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Grader

Purpose
Route by last-known POWN: 13 failed => Counterfeit; 25 authentic => Bank; 13 authentic => Fracked; otherwise Limbo.
Files
src/coin/commands/cmd_grade.c
Old paths
vendor/core/src/commands/cmd_grade.c -> src/coin/commands/cmd_grade.c
Public header
include/core/cmd_grade.h
Entry points
src/coin/commands/cmd_grade.c:69 :: grade_calculate() src/coin/commands/cmd_grade.c:85 :: grade_to_folder() src/coin/commands/cmd_grade.c:46 :: grade_count_pown()
Important static functions
src/coin/commands/cmd_grade.c:114 :: remove_coin_duplicates()
Owns
grade_calculate and grade_to_folder are the grading rule owners.
Used by
src/coin/health_manager.c src/mail/qmail_payment_claim.c src/mail/service/qmail_service.c src/coin/commands/cmd_convert.c src/coin/commands/cmd_deposit.c src/coin/commands/cmd_find.c src/coin/commands/cmd_heal.c src/coin/commands/cmd_pown.c
Side effects
Computes grades and moves processed coin files to the selected wallet folder.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Change-Maker

Purpose
Break a coin into ten smaller coins and obtain serial ranges.
Files
src/coin/commands/cmd_make_change.c src/coin/commands/cmd_get_sns.c
Old paths
vendor/core/src/commands/cmd_make_change.c -> src/coin/commands/cmd_make_change.c vendor/core/src/commands/cmd_get_sns.c -> src/coin/commands/cmd_get_sns.c
Public header
include/api/api_rest.h include/core/cmd_get_sns.h include/core/cmd_make_change.h
Entry points
src/coin/commands/cmd_make_change.c:367 :: cmd_make_change() src/coin/commands/cmd_get_sns.c:45 :: core_get_available_sns() src/coin/commands/cmd_make_change.c:49 :: make_change_result_init()
Important static functions
src/coin/commands/cmd_make_change.c:94 :: build_make_change_body() src/coin/commands/cmd_make_change.c:131 :: make_change_body_builder() src/coin/commands/cmd_get_sns.c:28 :: get_sns_build_body()
Owns
Change request construction and quorum result processing.
Used by
src/coin/qmail_locker_pool.c src/mail/qmail_coin_select.c src/mail/service/qmail_service.c src/coin/commands/cmd_export.c src/coin/commands/cmd_join.c src/coin/commands/cmd_wallet.c
Side effects
Command entry points can authenticate/change coins over RAIDA and write or move wallet files; file/crypto helpers also mutate buffers/session state.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working; Reachable from cmd_export.c, qmail_locker_pool.c, qmail_coin_select.c and qmail_service.c; no separate GUI action required.

Join

Purpose
Combine coins using the RAIDA join command.
Files
src/coin/commands/cmd_join.c
Old paths
vendor/core/src/commands/cmd_join.c -> src/coin/commands/cmd_join.c
Public header
include/core/cmd_join.h
Entry points
src/coin/commands/cmd_join.c:69 :: core_join_coins()
Important static functions
src/coin/commands/cmd_join.c:32 :: join_build_body()
Owns
Join wire body and response handling.
Used by
No external C symbol reference identified; see target/script membership and integration notes.
Side effects
Sends RAIDA join requests and fills the caller result; no desktop invocation found.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
partial; core_join_coins has a public declaration and compiled implementation; no production call site found in this clone. Desktop exposure uncertain.

Fix and healing

Purpose
Repair fracked coins, obtain tickets and resolve uncertain ownership.
Files
src/coin/commands/cmd_heal.c src/coin/commands/cmd_fix.c src/coin/commands/cmd_fix_encryption.c src/coin/commands/cmd_fix_protocol.c src/coin/commands/cmd_get_ticket.c src/coin/commands/cmd_find.c src/coin/health_manager.c
Old paths
vendor/core/src/commands/cmd_heal.c -> src/coin/commands/cmd_heal.c vendor/core/src/commands/cmd_fix.c -> src/coin/commands/cmd_fix.c vendor/core/src/commands/cmd_fix_encryption.c -> src/coin/commands/cmd_fix_encryption.c vendor/core/src/commands/cmd_fix_protocol.c -> src/coin/commands/cmd_fix_protocol.c vendor/core/src/commands/cmd_get_ticket.c -> src/coin/commands/cmd_get_ticket.c vendor/core/src/commands/cmd_find.c -> src/coin/commands/cmd_find.c vendor/core/src/health_manager.c -> src/coin/health_manager.c
Public header
include/core/cmd_find.h include/core/cmd_fix.h include/core/cmd_fix_encryption.h include/core/cmd_fix_protocol.h include/core/cmd_get_ticket.h include/core/cmd_heal.h include/core/health_manager.h
Entry points
src/coin/commands/cmd_heal.c:145 :: heal_wallet_fracked() src/coin/commands/cmd_fix.c:65 :: fix_fracked_coins() src/coin/commands/cmd_fix_encryption.c:42 :: get_encrypt_ticket_build_body() src/coin/commands/cmd_fix_protocol.c:32 :: fix_build_body() src/coin/commands/cmd_get_ticket.c:32 :: get_ticket_build_body() src/coin/commands/cmd_find.c:220 :: find_execute() src/coin/health_manager.c:48 :: health_set_skip_unprocessed_sweep()
Important static functions
src/coin/commands/cmd_fix.c:28 :: collect_fracked_sns() src/coin/commands/cmd_fix_protocol.c:112 :: fix_exec_body_builder() src/coin/commands/cmd_fix_protocol.c:124 :: fix_parse_response() src/coin/commands/cmd_get_ticket.c:157 :: ticket_batch_body_builder() src/coin/commands/cmd_find.c:63 :: find_body_builder() src/coin/commands/cmd_find.c:122 :: find_parse_response() src/coin/health_manager.c:72 :: health_select_helper_excluding_batch() src/coin/commands/cmd_heal.c:44 :: heal_try_reseat_helper()
Owns
Repair sequencing and wallet health checks.
Used by
src/app/desktop_api.c src/mail/qmail_transfer_manager.c src/mail/service/qmail_service.c src/coin/commands/cmd_deposit.c src/coin/commands/cmd_upgrade.c
Side effects
Command entry points can authenticate/change coins over RAIDA and write or move wallet files; file/crypto helpers also mutate buffers/session state.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Deposit

Purpose
Run staged coin deposit through unpack, authentication, repair and grading.
Files
src/coin/commands/cmd_deposit.c
Old paths
vendor/core/src/commands/cmd_deposit.c -> src/coin/commands/cmd_deposit.c
Public header
include/core/cmd_deposit.h
Entry points
src/coin/commands/cmd_deposit.c:1046 :: deposit_execute() src/coin/commands/cmd_deposit.c:1114 :: deposit_execute_import() src/coin/commands/cmd_deposit.c:1675 :: deposit_recover_task() src/coin/commands/cmd_deposit.c:66 :: deposit_mutex_lock()
Important static functions
src/coin/commands/cmd_deposit.c:1746 :: recovery_mutex_init() src/coin/commands/cmd_deposit.c:1752 :: recovery_mutex_lock()
Owns
Deposit phase orchestration; writes wallet folders and receipts.
Used by
src/app/desktop_api.c src/coin/health_manager.c src/mail/service/qmail_service.c src/coin/commands/cmd_convert.c src/coin/commands/cmd_make_change.c src/coin/commands/cmd_upgrade.c
Side effects
Command entry points can authenticate/change coins over RAIDA and write or move wallet files; file/crypto helpers also mutate buffers/session state.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Export

Purpose
Select and write exported coins, using change when necessary, and record transaction activity.
Files
src/coin/commands/cmd_export.c src/coin/commands/transaction_log.c
Old paths
vendor/core/src/commands/cmd_export.c -> src/coin/commands/cmd_export.c vendor/core/src/commands/transaction_log.c -> src/coin/commands/transaction_log.c
Public header
include/core/cmd_export.h include/core/transaction_log.h
Entry points
src/coin/commands/cmd_export.c:704 :: cmd_export_coins() src/coin/commands/cmd_export.c:574 :: export_select_coins() src/coin/commands/transaction_log.c:186 :: transaction_log_add() src/coin/commands/cmd_export.c:98 :: export_locations_load()
Important static functions
src/coin/commands/transaction_log.c:92 :: build_tx_path() src/coin/commands/transaction_log.c:97 :: parse_csv_field() src/coin/commands/cmd_export.c:49 :: ensure_dir_exists() src/coin/commands/cmd_export.c:90 :: get_export_locations_path()
Owns
Export file preparation and transaction log append.
Used by
src/coin/commands/cmd_wallet_wrappers.c
Side effects
Command entry points can authenticate/change coins over RAIDA and write or move wallet files; file/crypto helpers also mutate buffers/session state.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Legacy conversion and upgrade

Purpose
Identify and convert earlier coin formats and run the upgrade command.
Files
src/coin/commands/cmd_convert.c src/coin/commands/cmd_convert_credit.c src/coin/commands/cmd_upgrade.c
Old paths
vendor/core/src/commands/cmd_convert.c -> src/coin/commands/cmd_convert.c vendor/core/src/commands/cmd_convert_credit.c -> src/coin/commands/cmd_convert_credit.c vendor/core/src/commands/cmd_upgrade.c -> src/coin/commands/cmd_upgrade.c
Public header
include/core/cmd_convert.h include/core/cmd_convert_credit.h include/core/cmd_upgrade.h
Entry points
src/coin/commands/cmd_convert.c:241 :: legacy_cc1_denomination() src/coin/commands/cmd_convert_credit.c:103 :: convert_txn_init() src/coin/commands/cmd_upgrade.c:111 :: count_files_in_folder()
Important static functions
src/coin/commands/cmd_convert.c:206 :: parse_json_string() src/coin/commands/cmd_convert.c:637 :: get_sns_convert_build_body() src/coin/commands/cmd_convert_credit.c:44 :: credit_status_has_body() src/coin/commands/cmd_convert_credit.c:207 :: authenticate_build_body() src/coin/commands/cmd_upgrade.c:305 :: upgrade_write_stack_file() src/coin/commands/cmd_upgrade.c:65 :: ensure_dir()
Owns
Legacy file detection and conversion.
Used by
src/app/desktop_api.c src/coin/commands/cmd_deposit.c src/coin/commands/cmd_unpack.c
Side effects
Command entry points can authenticate/change coins over RAIDA and write or move wallet files; file/crypto helpers also mutate buffers/session state.
Tests
No direct symbol-reference test identified; indirect integration coverage is uncertain.
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
partial; Core conversion is implemented; desktop legacy_scan is an inventory path, not evidence that all legacy inputs are upgraded by the GUI.

Lockers and funding

Purpose
Fund sends from lockers and select exact microunit coin amounts under wallet funding locks.
Files
src/coin/commands/cmd_locker.c src/coin/qmail_locker_pool.c src/coin/qmail_locker_pool_partial.c src/coin/qmail_funding_runtime.c src/coin/wallet_funding_lock.c src/mail/qmail_coin_select.c
Old paths
vendor/core/src/commands/cmd_locker.c -> src/coin/commands/cmd_locker.c vendor/core/api_src/qmail_locker_pool.c -> src/coin/qmail_locker_pool.c vendor/core/api_src/qmail_locker_pool_partial.c -> src/coin/qmail_locker_pool_partial.c vendor/core/api_src/qmail_funding_runtime.c -> src/coin/qmail_funding_runtime.c vendor/core/api_src/wallet_funding_lock.c -> src/coin/wallet_funding_lock.c vendor/core/src/qmail/qmail_coin_select.c -> src/mail/qmail_coin_select.c
Public header
include/core/cmd_locker.h include/core/wallet_funding_lock.h include/qmail/qmail_coin_select.h include/qmail/qmail_funding_runtime.h include/qmail/qmail_locker_pool.h
Entry points
src/coin/commands/cmd_locker.c:71 :: core_locker_derive_code() src/coin/qmail_locker_pool.c:45 :: qmail_pool_generate_key() src/coin/qmail_locker_pool_partial.c:29 :: qmail_pool_stamp_file_guid() src/coin/qmail_funding_runtime.c:105 :: qmail_funding_prepare_locked() src/coin/wallet_funding_lock.c:30 :: wallet_funding_lock_init() src/mail/qmail_coin_select.c:187 :: qmail_select_coins_for_units()
Important static functions
src/coin/commands/cmd_locker.c:163 :: download_get_raida_key() src/coin/commands/cmd_locker.c:172 :: put_locker_build_body() src/mail/qmail_coin_select.c:89 :: qcs_coin_read_first() src/coin/qmail_locker_pool.c:91 :: scan_breakable_denominations() src/coin/qmail_locker_pool.c:125 :: ensure_scan_cb() src/coin/qmail_funding_runtime.c:23 :: funding_files() src/coin/qmail_funding_runtime.c:71 :: funding_file_state() src/coin/wallet_funding_lock.c:71 :: funding_lock_acquire()
Owns
Canonical funding lock discipline, locker pool and funding reservation lifecycle.
Used by
src/app/desktop_api.c src/coin/qmail_parent_funding.inc src/mail/qmail_parent_send.c src/mail/qmail_payment_claim.c src/mail/qmail_payment_send.c src/mail/qmail_tell_retry.c src/mail/qmail_transfer_manager.c src/mail/qmail_upload_orchestrator.c
Side effects
Command entry points can authenticate/change coins over RAIDA and write or move wallet files; file/crypto helpers also mutate buffers/session state.
Tests
tests/unit/coin/qmail_coin_select_test.c tests/unit/coin/qmail_funding_runtime_test.c tests/unit/coin/wallet_funding_lock_test.c tests/unit/mail/qmail_parent_send_test.c tests/unit/mail/qmail_tell_retry_test.c tests/unit/mail/qmail_transfer_reconcile_test.c tests/unit/mail/qmail_transfer_resume_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working