pub struct Voucher {
pub signature: Vec<u8>,
pub amount: u64,
pub bytes_delivered: u64,
pub chain_root: [u8; 32],
pub chunk_price: u64,
}Expand description
Payer → node cumulative payment voucher (ADR 005 §Voucher wire format).
The wire carries {signature, amount, bytes_delivered, chain_root, chunk_price}; the receiver reconstructs the full EIP-712 typed data
{poolId, signer, provider, amount, bytesDelivered, chainRoot, chunkPrice}
from stream context (poolId/signer/provider fixed for the stream) plus
the self-described fields. There is no nonce: amount is the sole ordering
and replay key — a voucher whose amount is no greater than the highest
accepted is stale. bytes_delivered is an additional signed, monotone
cumulative that must not regress below the highest accepted; it is what the
node verifies against (rather than reconstructing) so same-lane vouchers
settle independent of arrival order. Both are u64 cumulative totals
matching the contract’s on-chain uint64 Lane/LaneVoucher storage; the
node zero-extends them to uint256 to reconstruct the EIP-712 signature.
amount is the settlement anchor, and chain_root heads the optional
hash chain that advances it between signatures (ADR 003 §Hash-chain metering
(PayWord)). Redemption resolves both with one formula:
claimed = amount + chain_index × chunk_price.
Fields§
§signature: Vec<u8>EOA secp256k1 EIP-712 signature (r‖s‖v, exactly VOUCHER_SIG_LEN).
amount: u64Cumulative payment in token base units.
bytes_delivered: u64Cumulative bytes delivered. Signed by the client and transmitted so the node verifies against exactly what was signed, independent of same-lane stream ordering.
chain_root: [u8; 32]Head of the hash chain this voucher opens: keccak^MAX_CHAIN_LENGTH of
the payer’s per-lane seed. All-zero seals the voucher at exactly
amount — no value that hashes to zero is findable, so no index above 0
can redeem against it (ADR 003 §The sealed voucher (zero-hash root)).
chunk_price: u64The price one chunk of delivery adds over amount, in token base units.
Signed so the claim arithmetic is fixed at signing time. A metering
voucher MUST carry the node’s quoted rate_per_mb (CHUNK_BYTES == MB_BYTES, so a chunk costs exactly one MB); a sealed voucher meters no
chunk and MUST carry 0. The node rejects otherwise with
VoucherRejectReason::ChunkPriceMismatch (ADR 003 §Chunk Cadence).
Implementations§
Source§impl Voucher
impl Voucher
Sourcepub const fn validate(&self) -> Result<(), MessageValidationError>
pub const fn validate(&self) -> Result<(), MessageValidationError>
Validate the wire-level signature length (VOUCHER_SIG_LEN). The
cryptographic checks (recovery, monotonicity, deposit bound) happen in
decdn_incentive once the typed data is reconstructed.