Skip to content

Commit

Permalink
Added txout ordering to the api call
Browse files Browse the repository at this point in the history
  • Loading branch information
chiguireitor committed Jan 8, 2021
1 parent 74a457d commit 5248d35
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions counterpartylib/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,18 @@ def search_raw_transactions(address, unconfirmed=True):
return backend.search_raw_transactions(address, unconfirmed=unconfirmed)

@dispatcher.add_method
def get_unspent_txouts(address, unconfirmed=False, unspent_tx_hash=None):
return backend.get_unspent_txouts(address, unconfirmed=unconfirmed, unspent_tx_hash=unspent_tx_hash)
def get_unspent_txouts(address, unconfirmed=False, unspent_tx_hash=None, order_by=None):
results = backend.get_unspent_txouts(address, unconfirmed=unconfirmed, unspent_tx_hash=unspent_tx_hash)
if order_by is None:
return results
else:
order_key = order_by
reverse = False
if order_key.startswith('-'):
order_key = order_key[1:]
reverse = True
return sorted(results, key=lambda x: x[order_key], reverse=reverse)


@dispatcher.add_method
def getrawtransaction(tx_hash, verbose=False, skip_missing=False):
Expand Down

0 comments on commit 5248d35

Please sign in to comment.