Receipt

public struct Receipt
extension Receipt: Equatable
extension Receipt: Hashable

Represents a single “output” TxOut from a Transaction. Intended to be serialized and sent to the recipient of that TxOut. The recipient is able to use Receipt to validate that a particular TxOut was sent by whoever sent them the Receipt, assuming the public key of the Receipt and the TxOut in question are the same and various other validation checks pass. The Receipt also contains the necessary information to determine whether an expected, incoming TxOut‘s Tx has expired, in which case, if the TxOut is not in the ledger at that point, then the corresponding Tx is no longer eligible to be accepted into consensus.

Security

The Receipt contains the TxOutConfirmationNumber, which is used by the recipient as evidence that a particular party is the one who sent the corresponding TxOut that the Receipt represents. Therefore, care should be taken to ensure that only the sender and the recipient have access to the Receipt, otherwise the recipient could be tricked into misattributing which party sent them a particular TxOut.

  • Block index at which the transaction that produced this Receipt will no longer be considered valid for inclusion in the ledger by the consensus network.

    Declaration

    Swift

    public let txTombstoneBlockIndex: UInt64
  • Declaration

    Swift

    public init?(serializedData: Data)

    Return Value

    nil when the input is not deserializable.

  • Declaration

    Swift

    public var serializedData: Data { get }
  • Public key of the TxOut that this Receipt represents, in bytes.

    Declaration

    Swift

    public var txOutPublicKey: Data { get }
  • Validates whether or not Receipt is well-formed and matches accountKey, returning nil if either of these conditions are not met. Otherwise, returns the value of the TxOut represented by this Receipt.

    Note: Receipt does not provide enough information to distinguish between subaddresses of an accountKey, so this function only validates that the Receipt was addressed to a subaddress of the accountKey, but not which one.

    Declaration

    Swift

    @discardableResult
    public func validateAndUnmaskValue(accountKey: AccountKey) -> UInt64?