buildSourceAccountAuthPayloadHash

suspend fun buildSourceAccountAuthPayloadHash(entry: SorobanAuthorizationEntryXdr, address: SCAddressXdr, nonce: Int64Xdr, expirationLedger: UInt, networkPassphrase: String, useUpgradedAuth: Boolean = true): ByteArray

Builds the authorization payload hash for source_account credentials.

This is used when converting source_account (Void) credentials to fresh address-bearing credentials, typically for relayer fee sponsoring. The payload uses the provided address, nonce, and expiration since there are no existing address credentials yet.

useUpgradedAuth selects the credential arm the signature is built for, and with it the preimage type. The upgraded ADDRESS_V2 arm hashes the address-bound ENVELOPE_TYPE_SOROBAN_AUTHORIZATION_WITH_ADDRESS preimage:

HashIdPreimage::SorobanAuthorizationWithAddress {
networkId: SHA256(networkPassphrase as UTF-8),
nonce: provided nonce,
signatureExpirationLedger: expirationLedger,
address: provided address,
invocation: entry.rootInvocation
}
hash = SHA256(XDR_encode(payload))

The legacy ADDRESS arm hashes the ENVELOPE_TYPE_SOROBAN_AUTHORIZATION preimage, which carries the same fields except the address. address is still the address of the credentials the signature is attached to in both arms; the legacy preimage simply does not include it. Selection is delegated to Auth.buildHashIDPreimage.

The host reconstructs the preimage from the submitted credential arm, so the arm chosen here must match the arm the signature is attached to.

Return

The 32-byte SHA-256 hash of the authorization payload

Parameters

entry

The authorization entry with source_account credentials

address

The address carried by the new credentials

nonce

The nonce to use for the new credentials

expirationLedger

The ledger number at which the signature expires

networkPassphrase

The network passphrase

useUpgradedAuth

True (the default) hashes the ADDRESS_V2 address-bound preimage; false hashes the legacy ADDRESS preimage.

Throws