submitFundingTransactions()
We should create an API and library function that allows users to submit an array of transactions and get confirmation back that we have validated the funding, fees and any other transactional metadata and will now be automating settlement of that contract.
-
It starts with the developer calling register() to get information on what a funding transaction has to look like.
-
Then they coordinate to create one or more transactions that matches the funding requirement such that:
-
- Every contract funding output and associated service fee output are in the same transaction
-
- Each transaction may contain any number of unrelated outputs
-
The developer then sends a raw transaction, or array of raw transactions using the
submitFundingTransactions()
function -
This function calls the API for the default service domain and port
-
The API iterates through the transactions and...
-
- Checks each output to find a matching contract or service fee
-
- Checks that both the service fee amount is paid correctly
-
- Checks that the funding amount matches the contract correctly.
-
- Checks any other sanity checks...
-
Then reports back an array of errors or commitent results where:
-
- In the case of errors, sets an error code, name and description
-
- In the case of correctly completed funding, the API broadcasts the transaction
-
- If successfully broadcast, signs a payment receipt with the funding TXID and contract address which acts as our commitment to automate settlement.
-
The developer will check the response and broadcast the funding TXID in order to provide the best UX.