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

[api] Get history to address #12

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

[api] Get history to address #12

olemis opened this issue Feb 24, 2019 · 0 comments

Comments

@olemis
Copy link
Contributor

olemis commented Feb 24, 2019

[GET] /api/transactions/history/to/{address}?take=integer&[afterHash=string]

Should return completed transactions that transfer fund to the address and that were broadcasted
after the transaction with the hash equal to the afterHash.
If afterHash is empty, transactions should be read from the beginning.
Should include all transactions broadcasted even those not going through /transaction/broadcast/* API endpoints.
If there are no transactions to return, empty array should be returned.
Amount of the returned transactions should not exceed take.

Response:

[
{
// Operation ID.
// Can be empty.
// Should be not empty for transactions that
// broadcasted using this Blockchain.Api
“operationId”: “guid”,

// Transaction moment as ISO 8601 in UTC
“timestamp”: “datetime”,

// Source address
“fromAddress”: “string”,

// Destination address
“toAddress”: “string”,

// Asset ID e.g. SKY
“assetId”: “string”

// ​ Amount without fee. Is integer as string, aligned
// to the asset accuracy. Actual value can be
// calculated as
// x = sourceAmount * (10 ^ asset.Accuracy)
“amount”: “string”,

// Transaction hash as base64 string
“hash”: “string”
}
]

Python implementation

@api.route('/transactions/history/to/<string:address>', methods=['GET'])
def get_history_to_address(address):
    """
    Returns completed transactions that transfer fund to the address 
    """
    
    if not exists_address_transfer_observation_to(address):
        return make_response(jsonify(build_error('No content: transactions to the address are not observed')), 204)
    
    take = request.args.get('take')
    if take is None:
        take = 0
    else:
        take = int(take)
    
    afterhash = request.args.get('afterHash'.lower())
    if afterhash is None:
        afterhash = ''
       
    update_index() 
    items = get_transactions_to(address, take, afterhash)

    response = items if take == 0 else items[0:take]

   return jsonify(response)
adriantpaez pushed a commit to uhsimelo/skyxcommons that referenced this issue Feb 27, 2019
adriantpaez added a commit to uhsimelo/skyxcommons that referenced this issue Mar 4, 2019
adriantpaez added a commit to uhsimelo/skyxcommons that referenced this issue Mar 4, 2019
@adriantpaez adriantpaez removed their assignment Nov 17, 2022
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