Cashu-TS - v4.13.0
    Preparing search index...

    Class PaymentRequest

    Index

    Constructors

    Properties

    amount?: Amount
    description?: string
    id?: string
    mints?: string[]
    mintsPreferred?: boolean
    nut10?: NUT10Option
    singleUse: boolean = false
    supportedMethods?: SupportedMethod[]
    unit?: string

    Accessors

    • get isMintListStrict(): boolean | undefined

      Resolves the NUT-18 mint list strictness per spec.

      • undefined if no mint list is set (mp SHOULD be ignored)
      • true if the list is strict (mp absent or false)
      • false if the list is preferred/advisory (mp === true)

      Returns boolean | undefined

    Methods

    • The total amount to send from mint: the requested amount plus feesFor.

      Parameters

      • mint: string

        The mint URL the payer will send from.

      • OptionalmeltMethods: string[]

        The methods the mint can melt the request unit via (its NUT-05 melt methods, matched against sm); omit if unknown.

      Returns Amount

      If the request has no amount (use feesFor instead), or no unit (invalid per NUT-18).

    • Serializes the default NUT-18 payment payload for this request.

      Parameters

      • mint: string

        The mint the proofs are from.

      • proofs: Proof[]

        The proofs to send (eg the send half of a send flow).

      • Optionalopts: { memo?: string; unit?: string }
        • Optionalmemo?: string

          Optional memo for the payee.

        • Optionalunit?: string

          Unit when the request has none (default 'sat').

      Returns string

      Use this, not plain JSON.stringify, which writes proof amounts as quoted strings. Proofs must come from mint and net the request amount. Send it as the POST body or Nostr DM content.

      If the request has a strict mint list and mint is not in it.

    • The per-method fee (mf) the payer must add when paying from mint: 0 if mint is in the mint list, otherwise the lowest fee among the sm methods that meltMethods says the mint supports (NUT-18).

      Parameters

      • mint: string

        The mint URL the payer will send from.

      • OptionalmeltMethods: string[]

        The methods the mint can melt the request unit via (its NUT-05 melt methods, matched against sm); omit if unknown (prices as 0).

      Returns Amount

      For amountless requests, add the result to the payer-chosen amount. Prices only; does not check admissibility (eg a strict mint list, or a mint supporting none of sm).

      If the request sets a or sm without u (invalid per NUT-18).

    • Whether mintUrl is in the request's mint list, compared after URL normalization.

      Parameters

      • mintUrl: string

      Returns boolean

      Foreign requests may carry non-normalized or unparsable entries; those fall back to a raw string comparison. false when the request has no mint list.

    • Encodes the payment request to creqA format (CBOR).

      Returns string

      A base64 encoded payment request string with 'creqA' prefix.

    • Experimental

      Encodes the payment request to creqB format (TLV + bech32m).

      Returns string

      A bech32m encoded payment request string with 'CREQB' prefix.

    • Converts this request's nut10 locking option into the P2PKOptions accepted by the .asP2PK() builder, so a payer can produce proofs locked to exactly the spending condition the payee requested.

      Supports P2PK (NUT-11) and HTLC (NUT-14) only. Returns undefined when there is no nut10 option or its kind is not one we can build.

      Returns P2PKOptions | undefined

      If the option is missing its data field, or carries malformed NUT-10 tags — invalid lock semantics must not be silently dropped.

    • Parses a default NUT-18 payment payload received from a payer.

      Parameters

      • json: string

        Raw payload text (POST body or Nostr DM content).

      Returns PaymentRequestPayload

      Validates payload shape only, accepting proof amounts as JSON numbers or canonical decimal strings. Matching the payload to the request (id, mint, amount) is the payee's job. Imposes no size limit of its own: cap the raw text at the transport (POST body, DM) before decoding.

      CTSError If the text is not valid JSON or not payload-shaped.