rename 'addresses' command as 'listadresses'. use json syntax.
This commit is contained in:
parent
3960f383e0
commit
95dc97b39b
6
electrum
6
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("-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("-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("-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", "--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("-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")
|
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':
|
elif cmd == 'createrawtransaction':
|
||||||
args = [ cmd, json.loads(args[1]), json.loads(args[2])]
|
args = [ cmd, json.loads(args[1]), json.loads(args[2])]
|
||||||
|
|
||||||
elif cmd=='addresses':
|
elif cmd=='listaddresses':
|
||||||
args = [cmd, options.show_all]
|
args = [cmd, options.show_all, options.show_balance, options.show_labels]
|
||||||
|
|
||||||
elif cmd == 'setlabel':
|
elif cmd == 'setlabel':
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -475,6 +475,7 @@ class Transaction:
|
||||||
self.outputs = self.d['outputs']
|
self.outputs = self.d['outputs']
|
||||||
self.outputs = map(lambda x: (x['address'],x['value']), self.outputs)
|
self.outputs = map(lambda x: (x['address'],x['value']), self.outputs)
|
||||||
self.input_info = None
|
self.input_info = None
|
||||||
|
self.is_complete = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_io(klass, inputs, outputs):
|
def from_io(klass, inputs, outputs):
|
||||||
|
|
|
@ -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>',
|
'Broadcasts a transaction to the network. \nSyntax: sendrawtransaction <tx in hexadecimal>',
|
||||||
'password':
|
'password':
|
||||||
"Changes your password",
|
"Changes your password",
|
||||||
'addresses':
|
'listaddresses':
|
||||||
"""Shows your list of addresses.
|
"""Shows your list of addresses.
|
||||||
options:
|
options:
|
||||||
-a: show all addresses, including change addresses""",
|
-a: show all addresses, including change addresses""",
|
||||||
|
@ -87,7 +87,7 @@ offline_commands = [ 'password', 'mktx',
|
||||||
'setlabel', 'contacts',
|
'setlabel', 'contacts',
|
||||||
'help', 'validateaddress',
|
'help', 'validateaddress',
|
||||||
'signmessage', 'verifymessage',
|
'signmessage', 'verifymessage',
|
||||||
'eval', 'set', 'get', 'create', 'addresses',
|
'eval', 'set', 'get', 'create', 'listaddresses',
|
||||||
'importprivkey', 'get_seed',
|
'importprivkey', 'get_seed',
|
||||||
'deseed',
|
'deseed',
|
||||||
'freeze','unfreeze',
|
'freeze','unfreeze',
|
||||||
|
@ -286,17 +286,21 @@ class Commands:
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
|
||||||
def addresses(self, show_all = False):
|
def listaddresses(self, show_all = False, show_balance = False, show_label = False):
|
||||||
out = []
|
out = []
|
||||||
for addr in self.wallet.all_addresses():
|
for addr in self.wallet.all_addresses():
|
||||||
if show_all or not self.wallet.is_change(addr):
|
if show_all or not self.wallet.is_change(addr):
|
||||||
|
if show_balance or show_label:
|
||||||
flags = self.wallet.get_address_flags(addr)
|
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,'')
|
label = self.wallet.labels.get(addr,'')
|
||||||
if label: label = "\"%s\""%label
|
if label:
|
||||||
b = format_satoshis(self.wallet.get_addr_balance(addr)[0])
|
item['label'] = label
|
||||||
m_addr = "%34s"%addr
|
else:
|
||||||
out.append( flags + ' ' + m_addr + ' ' + b + ' ' + label )
|
item = addr
|
||||||
|
out.append( item )
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue