- Rust 100%
The MintPayment trait in 0.16.0 drops the `unit: &CurrencyUnit` param from create_incoming_payment_request, which already matches our impl. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
cdk-ehash
A MintPayment processor for Hashpool mining-share rewards, built on
the Cashu Development Kit (CDK).
Miners submit a valid proof-of-work share (identified by its header_hash).
Once Hashpool validates the share it calls pay_ehash_quote() on the
processor, which marks the corresponding quote as paid so the miner can
mint ecash tokens.
Overview
The mint flow has four steps:
-
Quote — the miner's wallet calls
POST /v1/mint/quote/ehashwith{"amount": N, "unit": "ehash", "extra": {"header_hash": "<64-char hex>"}}. The mint returns a quote ID. -
Validate — the miner submits the share to Hashpool. Hashpool verifies proof-of-work and calls
EhashPaymentProcessor::pay_ehash_quote(header_hash, amount). -
Poll — the wallet polls
GET /v1/mint/quote/ehash/<id>until"state": "PAID". -
Mint — the wallet calls
POST /v1/mint/ehashwith the quote ID and blinded messages to receive ecash tokens.
Wiring into Hashpool's mint binary
cdk-ehash plugs into CDK via MintBuilder::add_payment_processor. No
cdk-mintd dependency is needed — Hashpool builds its own mint binary:
use std::sync::Arc;
use cdk::mint::{MintBuilder, MintMeltLimits};
use cdk::nuts::{CurrencyUnit, PaymentMethod};
use cdk_ehash::EhashPaymentProcessor;
let unit = CurrencyUnit::Custom("ehash".to_string());
let processor = Arc::new(EhashPaymentProcessor::new(unit.clone()));
let mut builder = MintBuilder::new(localstore.clone());
builder
.add_payment_processor(
unit,
PaymentMethod::Custom("ehash".to_string()),
MintMeltLimits::new(1, 1_000_000),
processor.clone(),
)
.await?;
let mint = builder
.with_name("Hashpool Mint".to_string())
// ... other configuration ...
.build_with_seed(localstore, &seed)
.await?;
// Keep `processor` alive — call this when a share is validated:
// processor.pay_ehash_quote(&header_hash, amount).await?;
The cdk-axum router auto-generates all custom-method endpoints
(/v1/mint/quote/ehash, /v1/mint/ehash, etc.) from the registered
processor — no extra routing code required.
Dependency note
cdk-ehash targets CDK's upstream main branch. The hashed_derivation_index
method for custom currency units landed in CDK 0.15.0 and is available in all
current published releases. However, extra_json persistence for mint quotes
(needed to survive mint restarts) was fixed in CDK PR #1742 and is targeted for
the 0.16.0 release. Until that lands, patch the published crates with upstream:
[patch.crates-io]
cashu = { git = "https://github.com/cashubtc/cdk" }
cdk = { git = "https://github.com/cashubtc/cdk" }
cdk-common = { git = "https://github.com/cashubtc/cdk" }
cdk-http-client = { git = "https://github.com/cashubtc/cdk" }
cdk-signatory = { git = "https://github.com/cashubtc/cdk" }
cdk-sql-common = { git = "https://github.com/cashubtc/cdk" }
cdk-sqlite = { git = "https://github.com/cashubtc/cdk" }
Once CDK 0.16.0 is published this patch section (and the one in cdk-ehash's
own Cargo.toml) can be dropped and the version deps bumped to "0.16.0".
License
MIT — same as upstream CDK.