electrum

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

commit 95dc97b39b421f1d223ad3fa1436980493df0d6a
parent 3960f383e02ea09a5db76ca4b3b7be833127cbea
Author: thomasv <thomasv@gitorious>
Date:   Fri,  1 Mar 2013 11:21:10 +0100

rename 'addresses' command as 'listadresses'. use json syntax.

Diffstat:
Melectrum | 6++++--
Mlib/bitcoin.py | 1+
Mlib/commands.py | 24++++++++++++++----------
3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/electrum b/electrum @@ -63,6 +63,8 @@ def arg_parser(): parser.add_option("-o", "--offline", action="store_true", dest="offline", default=False, help="remain offline") parser.add_option("-a", "--all", action="store_true", dest="show_all", default=False, help="show all addresses") parser.add_option("-b", "--balance", action="store_true", dest="show_balance", default=False, help="show the balance at listed addresses") + parser.add_option("-l", "--labels", action="store_true", dest="show_labels", default=False, help="show the labels of listed addresses") + parser.add_option("-f", "--fee", dest="tx_fee", default="0.005", help="set tx fee") parser.add_option("-F", "--fromaddr", dest="from_addr", default=None, help="set source address for payto/mktx. if it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet.") parser.add_option("-c", "--changeaddr", dest="change_addr", default=None, help="set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet") @@ -376,8 +378,8 @@ if __name__ == '__main__': elif cmd == 'createrawtransaction': args = [ cmd, json.loads(args[1]), json.loads(args[2])] - elif cmd=='addresses': - args = [cmd, options.show_all] + elif cmd=='listaddresses': + args = [cmd, options.show_all, options.show_balance, options.show_labels] elif cmd == 'setlabel': try: diff --git a/lib/bitcoin.py b/lib/bitcoin.py @@ -475,6 +475,7 @@ class Transaction: self.outputs = self.d['outputs'] self.outputs = map(lambda x: (x['address'],x['value']), self.outputs) self.input_info = None + self.is_complete = True @classmethod def from_io(klass, inputs, outputs): diff --git a/lib/commands.py b/lib/commands.py @@ -38,7 +38,7 @@ options:\n --fee, -f: set transaction fee\n --fromaddr, -s: send from address 'Broadcasts a transaction to the network. \nSyntax: sendrawtransaction <tx in hexadecimal>', 'password': "Changes your password", - 'addresses': + 'listaddresses': """Shows your list of addresses. options: -a: show all addresses, including change addresses""", @@ -87,7 +87,7 @@ offline_commands = [ 'password', 'mktx', 'setlabel', 'contacts', 'help', 'validateaddress', 'signmessage', 'verifymessage', - 'eval', 'set', 'get', 'create', 'addresses', + 'eval', 'set', 'get', 'create', 'listaddresses', 'importprivkey', 'get_seed', 'deseed', 'freeze','unfreeze', @@ -286,17 +286,21 @@ class Commands: return c - def addresses(self, show_all = False): + def listaddresses(self, show_all = False, show_balance = False, show_label = False): out = [] for addr in self.wallet.all_addresses(): if show_all or not self.wallet.is_change(addr): - - flags = self.wallet.get_address_flags(addr) - label = self.wallet.labels.get(addr,'') - if label: label = "\"%s\""%label - b = format_satoshis(self.wallet.get_addr_balance(addr)[0]) - m_addr = "%34s"%addr - out.append( flags + ' ' + m_addr + ' ' + b + ' ' + label ) + if show_balance or show_label: + item = { 'address': addr } + if show_balance: + item['balance'] = str(Decimal(self.wallet.get_addr_balance(addr)[0])/100000000) + if show_label: + label = self.wallet.labels.get(addr,'') + if label: + item['label'] = label + else: + item = addr + out.append( item ) return out