electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit b83b7fa5c8157d51250d72d8dbfd5540724aa7b6
parent 2727df962ed13036eb482e4afd94c651d2c70662
Author: ThomasV <thomasv@gitorious>
Date:   Tue,  2 Jun 2015 10:25:39 +0200

cmd line: format payment requests

Diffstat:
Mlib/commands.py | 29+++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/lib/commands.py b/lib/commands.py @@ -506,20 +506,25 @@ class Commands: """Decrypt a message encrypted with a public key.""" return self.wallet.decrypt_message(pubkey, encrypted, self.password) + def _format_request(self, v): + addr = v.get('address') + out = { + 'address': addr, + 'amount': format_satoshis(v.get('amount')), + 'time': v.get('time'), + 'reason': self.wallet.get_label(addr)[0], + 'expiration': v.get('expiration'), + } + if v.get('path'): + p = self.config.get('url_prefix', 'file://') + URI = 'bitcoin:?r=' + p + v.get('path') + out['url'] = URI + return out + @command('w') def listrequests(self): """List the payment requests you made""" - out = [] - for k, v in self.wallet.receive_requests.items(): - out.append({ - 'address': v.get('address'), - 'amount': format_satoshis(v.get('amount')), - 'time': v.get('time'), - 'reason': self.wallet.get_label(addr)[0], - 'expiration': v.get('expiration'), - 'url': 'bitcoin:?r=file://' + v.get('path'), - }) - return out + return map(self._format_request, self.wallet.receive_requests.values()) @command('w') def addrequest(self, amount, reason='', expiration=60*60): @@ -531,7 +536,7 @@ class Commands: up to a root CA.""" amount = int(Decimal(amount)*COIN) key = self.wallet.add_payment_request(self.config, amount, reason, expiration) - return self.wallet.get_payment_request(key) if key else False + return self._format_request(self.wallet.get_payment_request(key)) if key else False @command('w') def removerequest(self, address):