// SPDX-License-Identifier: MIT pragma solidity >=0.7.6 <0.9; /** * @custom:name IPayment * @custom:id 0x01 * @custom:supported BTC, DOGE, XRP * @author Flare * @notice A relay of a transaction on an external chain that is considered a payment in a native currency. * Various blockchains support different types of native payments. For each blockchain, it is specified how a payment * transaction should be formed to be provable by this attestation type. * The provable payments emulate traditional banking payments from entity A to entity B in native currency with an * optional payment reference. * @custom:verification The transaction with `transactionId` is fetched from the API of the blockchain node or * relevant indexer. * If the transaction cannot be fetched or the transaction is in a block that does not have a sufficient * [number of confirmations](/specs/attestations/configs.md#finalityconfirmation), the attestation request is rejected. * * Once the transaction is received, the payment summary is computed according to the rules for the source chain. * If the summary is successfully calculated, the response is assembled from the summary. * `blockNumber` and `blockTimestamp` are retrieved from the block if they are not included in the transaction data. * For Bitcoin and Dogecoin, `blockTimestamp` is mediantime of the block. * For XRPL, `blockTimestamp` is close time of the ledger converted to UNIX time. * * If the summary is not successfully calculated, the attestation request is rejected. * @custom:lut `blockTimestamp` * @custom:lutlimit `0x127500`, `0x127500`, `0x127500` */ interface IPayment { /** * @notice Toplevel request * @param attestationType ID of the attestation type. * @param sourceId ID of the data source. * @param messageIntegrityCode `MessageIntegrityCode` that is derived from the expected response. * @param requestBody Data defining the request. Type (struct) and interpretation is determined * by the `attestationType`. */ struct Request { bytes32 attestationType; bytes32 sourceId; bytes32 messageIntegrityCode; RequestBody requestBody; } /** * @notice Toplevel response * @param attestationType Extracted from the request. * @param sourceId Extracted from the request. * @param votingRound The ID of the State Connector round in which the request was considered. * @param lowestUsedTimestamp The lowest timestamp used to generate the response. * @param requestBody Extracted from the request. * @param responseBody Data defining the response. The verification rules for the construction * of the response body and the type are defined per specific `attestationType`. */ struct Response { bytes32 attestationType; bytes32 sourceId; uint64 votingRound; uint64 lowestUsedTimestamp; RequestBody requestBody; ResponseBody responseBody; } /** * @notice Toplevel proof * @param merkleProof Merkle proof corresponding to the attestation response. * @param data Attestation response. */ struct Proof { bytes32[] merkleProof; Response data; } /** * @notice Request body for Payment attestation type * @param transactionId ID of the payment transaction. * @param inUtxo For UTXO chains, this is the index of the transaction input with source address. * Always 0 for the non-utxo chains. * @param utxo For UTXO chains, this is the index of the transaction output with receiving address. * Always 0 for the non-utxo chains. */ struct RequestBody { bytes32 transactionId; uint256 inUtxo; uint256 utxo; } /** * @notice Response body for Payment attestation type * @param blockNumber Number of the block in which the transaction is included. * @param blockTimestamp The timestamp of the block in which the transaction is included. * @param sourceAddressHash Standard address hash of the source address. * @param sourceAddressesRoot The root of the Merkle tree of the source addresses. * @param receivingAddressHash Standard address hash of the receiving address. * The zero 32-byte string if there is no receivingAddress (if `status` is not success). * @param intendedReceivingAddressHash Standard address hash of the intended receiving address. * Relevant if the transaction is unsuccessful. * @param spentAmount Amount in minimal units spent by the source address. * @param intendedSpentAmount Amount in minimal units to be spent by the source address. * Relevant if the transaction status is unsuccessful. * @param receivedAmount Amount in minimal units received by the receiving address. * @param intendedReceivedAmount Amount in minimal units intended to be received by the receiving address. * Relevant if the transaction is unsuccessful. * @param standardPaymentReference Standard payment reference of the transaction. * @param oneToOne Indicator whether only one source and one receiver are involved in the transaction. * @param status Succes status of the transaction: 0 - success, 1 - failed by sender's fault, * 2 - failed by receiver's fault. */ struct ResponseBody { uint64 blockNumber; uint64 blockTimestamp; bytes32 sourceAddressHash; bytes32 sourceAddressesRoot; bytes32 receivingAddressHash; bytes32 intendedReceivingAddressHash; int256 spentAmount; int256 intendedSpentAmount; int256 receivedAmount; int256 intendedReceivedAmount; bytes32 standardPaymentReference; bool oneToOne; uint8 status; } }