fibercrypto / fibercrypto/skyxcommons

[api] Many-outputs tx

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Description

[POST] /api/transactions/many-outputs

Should build not signed transaction with many outputs. If the transaction with the specified `operationId` has already been built by one of the `[POST] /api/transactions/*` call, it should be ignored and regular response (as in the first request) should be returned. Fee should be added to the specified amount.

Request

```js
{
// Operation ID
“operationId”: “guid”,
// Source address
“fromAddress”: “string”,
// Destinations
“outputs”: [
{
// Destination address
“toAddress”: “string”,
// Amount to transfer to the toAddress .
// Integer as string, aligned
// to the asset accuracy. Actual value can be
// calculated as
// x = amount / (10 ^ asset.Accuracy)
“amount”: “string”
} ],
// Asset ID to transfer, defaults to SKY
“assetId”: “string”
}
```

Response:

```js
{
// Error code.
// Can be empty.
// Should be non empty if an error that match one of the
// listed code is occured. For other errors use HTTP
// status codes.
// enum values:
// - amountIsTooSmall : amount is too small to execute
// transaction
// - notEnoughBalance : transaction can’t be executed due
// to balance insufficiency on the source address.
"errorCode": "enum",
// The transaction context in the blockchain
// specific format, which will be passed to the
// [POST] /api/sign.
// Should be not empty when result is successful.
“transactionContext”: “string”
}
```

Python implementation

```py

@api.route('/api/transactions/many-outputs', methods=['POST'])
def transactions_many_outputs():
if not request.json:
return make_response(jsonify(build_error("Input format error")), 400)
params = {'operationId', 'fromAddress', 'fromAddressContext', 'outputs', 'assetId'}
if all(x not in params for x in request.json):
return make_response(jsonify(build_error("Input data error")), 400)
tx = add_many_outputs_tx(request.json)
if tx:
result = transaction_many_outputs(request.json)
if "transactionContext" in result:
return jsonify(result)
if app.config['DEBUG']:
logging.debug("Transaction: %s", request.args.get('operationId'))
return jsonify({"status": 500, "error": "Invalid response"})

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.