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 #5

Open
olemis opened this issue Feb 21, 2019 · 0 comments
Open

Sign API endpoint #5

olemis opened this issue Feb 21, 2019 · 0 comments
Assignees

Comments

@olemis
Copy link
Contributor

olemis commented Feb 21, 2019

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
@cbermudez97 cbermudez97 self-assigned this Feb 25, 2019
cbermudez97 pushed a commit to uhsimelo/skyxcommons that referenced this issue Feb 25, 2019
cbermudez97 pushed a commit to uhsimelo/skyxcommons that referenced this issue Feb 28, 2019
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