Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign API endpoint #4

Closed
cbermudez97 opened this issue Feb 22, 2019 · 0 comments
Closed

Sign API endpoint #4

cbermudez97 opened this issue Feb 22, 2019 · 0 comments
Assignees

Comments

@cbermudez97
Copy link
Collaborator

cbermudez97 commented Feb 22, 2019

Original Issue: fibercrypto/skyxcommons#5

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

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants