add filtering options for listrequests
This commit is contained in:
parent
21f505a62c
commit
cbcb799eec
|
@ -33,6 +33,7 @@ import bitcoin
|
||||||
from bitcoin import is_address, hash_160_to_bc_address, hash_160, COIN
|
from bitcoin import is_address, hash_160_to_bc_address, hash_160, COIN
|
||||||
from transaction import Transaction
|
from transaction import Transaction
|
||||||
import paymentrequest
|
import paymentrequest
|
||||||
|
from paymentrequest import PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED
|
||||||
|
|
||||||
known_commands = {}
|
known_commands = {}
|
||||||
|
|
||||||
|
@ -518,7 +519,6 @@ class Commands:
|
||||||
return self.wallet.decrypt_message(pubkey, encrypted, self.password)
|
return self.wallet.decrypt_message(pubkey, encrypted, self.password)
|
||||||
|
|
||||||
def _format_request(self, out):
|
def _format_request(self, out):
|
||||||
from paymentrequest import PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED
|
|
||||||
pr_str = {
|
pr_str = {
|
||||||
PR_UNKNOWN: 'Unknown',
|
PR_UNKNOWN: 'Unknown',
|
||||||
PR_UNPAID: 'Pending',
|
PR_UNPAID: 'Pending',
|
||||||
|
@ -543,9 +543,20 @@ class Commands:
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
@command('w')
|
@command('w')
|
||||||
def listrequests(self):
|
def listrequests(self, pending=False, expired=False, paid=False):
|
||||||
"""List the payment requests you made."""
|
"""List the payment requests you made."""
|
||||||
return map(self._format_request, self.wallet.get_sorted_requests(self.config))
|
out = self.wallet.get_sorted_requests(self.config)
|
||||||
|
if pending:
|
||||||
|
f = PR_UNPAID
|
||||||
|
elif expired:
|
||||||
|
f = PR_EXPIRED
|
||||||
|
elif paid:
|
||||||
|
f = PR_PAID
|
||||||
|
else:
|
||||||
|
f = None
|
||||||
|
if f:
|
||||||
|
out = filter(lambda x: x.get('status')==f, out)
|
||||||
|
return map(self._format_request, out)
|
||||||
|
|
||||||
@command('w')
|
@command('w')
|
||||||
def addrequest(self, requested_amount, memo='', expiration=60*60, force=False):
|
def addrequest(self, requested_amount, memo='', expiration=60*60, force=False):
|
||||||
|
@ -610,8 +621,10 @@ command_options = {
|
||||||
'account': (None, "--account", "Account"),
|
'account': (None, "--account", "Account"),
|
||||||
'memo': ("-m", "--memo", "Description of the request"),
|
'memo': ("-m", "--memo", "Description of the request"),
|
||||||
'expiration': (None, "--expiration", "Time in seconds"),
|
'expiration': (None, "--expiration", "Time in seconds"),
|
||||||
'status': (None, "--status", "Show status"),
|
|
||||||
'force': (None, "--force", "Create new address beyong gap limit, if no more address is available."),
|
'force': (None, "--force", "Create new address beyong gap limit, if no more address is available."),
|
||||||
|
'pending': (None, "--pending", "Show only pending requests."),
|
||||||
|
'expired': (None, "--expired", "Show only expired requests."),
|
||||||
|
'paid': (None, "--paid", "Show only paid requests."),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue