fibercrypto / fibercrypto/skyxcommons
Sign API endpoint
- Dominant language
- No language data
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Implement [POST] api/sign
```
[POST] /api/sign
Should sign given transaction with the given private key Body:
{
// Private keys, which were returned by the
// [POST] /api/wallets. Multiple keys can be used
// for transactions with multiple inputs
"privateKeys": [
"string" ],
// The transaction context in the blockchain
// specific format
// [POST] /api/transactions or [PUT] /api/transactions
"transactionContext": "string"
}
Response:
{
// Signed transaction, which will be used to broadcast
// the transaction
// [PUT] /api/transactions/broadcast
“signedTransaction”: “string”
}
```
Python implementation
```py
@api.route('/sign', methods=['POST'])
def post_sign():
"""
Sign transacction with private key
"""
if not request.json:
return make_response(jsonify(build_error('Invalid Input Format', error_codes.badFormat)), 400)
if "privateKeys" not in request.json:
return make_response(jsonify(build_error('Invalid Input Parameters', error_codes.missingParameter)), 400)
if "transactionContext" not in request.json:
return make_response(jsonify(build_error('Invalid Input Parameters', error_codes.missingParameter)), 400)
private_keys = request.json['privateKeys']
signedHashHex = request.json['transactionContext']
for secKey in private_keys:
signedHashHex = sign_hash(signedHashHex, secKey)
return signedHashHex
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.