xrpl
    Preparing search index...

    Function validateSponsorship

    • Validates a transaction's sponsorship (Sponsor + SponsorFlags) against any Sponsorship ledger entry between the sponsor and sponsee.

      This should be called before submitting any sponsored transaction, whether pre-funded (no SponsorSignature) or co-signed by the sponsor. Whenever a Sponsorship ledger entry exists for the sponsor/sponsee pair, rippled's checkReserve/getFeePayer always validate against its budget -- FeeAmount, MaxFee, RemainingOwnerCount -- regardless of whether the transaction is also co-signed (XLS-68 section 8.3.2/8.3.3; rippled's Transactor::checkSponsor only skips the existence check for a co-signed transaction, not the budget checks in checkReserve/getFeePayer). If no Sponsorship entry exists, a sponsor signature alone is sufficient authorization (matching rippled), and this only validates that one is present.

      For reserve sponsorship, this only checks that RemainingOwnerCount is at least 1 (i.e. the transaction consumes exactly one reserve unit, matching rippled's checkReserve). It does not account for transactions that may consume more than one reserve unit, nor does it check the sponsor account's own XRP balance against its own reserve requirement (rippled checks that too, but only server-side).

      Parameters

      • client: Client

        The XRPL client to use for querying the ledger.

      • tx: Transaction

        The transaction to validate sponsorship for.

      • OptionalestimatedFee: string

        Optional estimated fee in drops. If not provided, uses tx.Fee.

      Returns Promise<SponsorshipValidationResult>

      A promise that resolves to the validation result.

      const result = await validateSponsorship(client, payment, '100')
      if (!result.valid) {
      console.error(`Sponsorship validation failed: ${result.error}`)
      }