Skip to main content

Voucher

Struct Voucher 

Source
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: u64

Cumulative payment in token base units.

§bytes_delivered: u64

Cumulative 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: u64

The 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

Source

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.

Trait Implementations§

Source§

impl Clone for Voucher

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Voucher

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Voucher

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Voucher

Source§

impl PartialEq for Voucher

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Voucher

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Voucher

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.