commands: use the same option names for RPC and command line. fixes #2875
This commit is contained in:
parent
6dd2b8b471
commit
c810c6a356
|
@ -387,11 +387,11 @@ class Commands:
|
||||||
return out['address']
|
return out['address']
|
||||||
|
|
||||||
@command('nw')
|
@command('nw')
|
||||||
def sweep(self, privkey, destination, tx_fee=None, nocheck=False, imax=100):
|
def sweep(self, privkey, destination, fee=None, nocheck=False, imax=100):
|
||||||
"""Sweep private keys. Returns a transaction that spends UTXOs from
|
"""Sweep private keys. Returns a transaction that spends UTXOs from
|
||||||
privkey to a destination address. The transaction is not
|
privkey to a destination address. The transaction is not
|
||||||
broadcasted."""
|
broadcasted."""
|
||||||
tx_fee = satoshis(tx_fee)
|
tx_fee = satoshis(fee)
|
||||||
privkeys = privkey.split()
|
privkeys = privkey.split()
|
||||||
self.nocheck = nocheck
|
self.nocheck = nocheck
|
||||||
dest = self._resolver(destination)
|
dest = self._resolver(destination)
|
||||||
|
@ -432,17 +432,17 @@ class Commands:
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
@command('wp')
|
@command('wp')
|
||||||
def payto(self, destination, amount, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, rbf=False, password=None, locktime=None):
|
def payto(self, destination, amount, fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, rbf=False, password=None, locktime=None):
|
||||||
"""Create a transaction. """
|
"""Create a transaction. """
|
||||||
tx_fee = satoshis(tx_fee)
|
tx_fee = satoshis(fee)
|
||||||
domain = [from_addr] if from_addr else None
|
domain = [from_addr] if from_addr else None
|
||||||
tx = self._mktx([(destination, amount)], tx_fee, change_addr, domain, nocheck, unsigned, rbf, password, locktime)
|
tx = self._mktx([(destination, amount)], tx_fee, change_addr, domain, nocheck, unsigned, rbf, password, locktime)
|
||||||
return tx.as_dict()
|
return tx.as_dict()
|
||||||
|
|
||||||
@command('wp')
|
@command('wp')
|
||||||
def paytomany(self, outputs, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, rbf=False, password=None, locktime=None):
|
def paytomany(self, outputs, fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, rbf=False, password=None, locktime=None):
|
||||||
"""Create a multi-output transaction. """
|
"""Create a multi-output transaction. """
|
||||||
tx_fee = satoshis(tx_fee)
|
tx_fee = satoshis(fee)
|
||||||
domain = [from_addr] if from_addr else None
|
domain = [from_addr] if from_addr else None
|
||||||
tx = self._mktx(outputs, tx_fee, change_addr, domain, nocheck, unsigned, rbf, password, locktime)
|
tx = self._mktx(outputs, tx_fee, change_addr, domain, nocheck, unsigned, rbf, password, locktime)
|
||||||
return tx.as_dict()
|
return tx.as_dict()
|
||||||
|
@ -515,7 +515,7 @@ class Commands:
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@command('w')
|
@command('w')
|
||||||
def listaddresses(self, receiving=False, change=False, show_labels=False, frozen=False, unused=False, funded=False, show_balance=False):
|
def listaddresses(self, receiving=False, change=False, labels=False, frozen=False, unused=False, funded=False, balance=False):
|
||||||
"""List wallet addresses. Returns the list of all addresses in your wallet. Use optional arguments to filter the results."""
|
"""List wallet addresses. Returns the list of all addresses in your wallet. Use optional arguments to filter the results."""
|
||||||
out = []
|
out = []
|
||||||
for addr in self.wallet.get_addresses():
|
for addr in self.wallet.get_addresses():
|
||||||
|
@ -530,10 +530,12 @@ class Commands:
|
||||||
if funded and self.wallet.is_empty(addr):
|
if funded and self.wallet.is_empty(addr):
|
||||||
continue
|
continue
|
||||||
item = addr
|
item = addr
|
||||||
if show_balance:
|
if labels or balance:
|
||||||
item += ", "+ format_satoshis(sum(self.wallet.get_addr_balance(addr)))
|
item = (item,)
|
||||||
if show_labels:
|
if balance:
|
||||||
item += ', ' + repr(self.wallet.labels.get(addr, ''))
|
item += (format_satoshis(sum(self.wallet.get_addr_balance(addr))),)
|
||||||
|
if labels:
|
||||||
|
item += (repr(self.wallet.labels.get(addr, '')),)
|
||||||
out.append(item)
|
out.append(item)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
@ -695,37 +697,36 @@ param_descriptions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
command_options = {
|
command_options = {
|
||||||
'password': ("-W", "--password", "Password"),
|
'password': ("-W", "Password"),
|
||||||
'new_password':(None, "--new_password","New Password"),
|
'new_password':(None, "New Password"),
|
||||||
'receiving': (None, "--receiving", "Show only receiving addresses"),
|
'receiving': (None, "Show only receiving addresses"),
|
||||||
'change': (None, "--change", "Show only change addresses"),
|
'change': (None, "Show only change addresses"),
|
||||||
'frozen': (None, "--frozen", "Show only frozen addresses"),
|
'frozen': (None, "Show only frozen addresses"),
|
||||||
'unused': (None, "--unused", "Show only unused addresses"),
|
'unused': (None, "Show only unused addresses"),
|
||||||
'funded': (None, "--funded", "Show only funded addresses"),
|
'funded': (None, "Show only funded addresses"),
|
||||||
'show_balance':("-b", "--balance", "Show the balances of listed addresses"),
|
'balance': ("-b", "Show the balances of listed addresses"),
|
||||||
'show_labels': ("-l", "--labels", "Show the labels of listed addresses"),
|
'labels': ("-l", "Show the labels of listed addresses"),
|
||||||
'nocheck': (None, "--nocheck", "Do not verify aliases"),
|
'nocheck': (None, "Do not verify aliases"),
|
||||||
'imax': (None, "--imax", "Maximum number of inputs"),
|
'imax': (None, "Maximum number of inputs"),
|
||||||
'tx_fee': ("-f", "--fee", "Transaction fee (in BTC)"),
|
'fee': ("-f", "Transaction fee (in BTC)"),
|
||||||
'from_addr': ("-F", "--from", "Source address. 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."),
|
'from_addr': ("-F", "Source address. 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."),
|
||||||
'change_addr': ("-c", "--change", "Change address. Default is a spare address, or the source address if it's not in the wallet"),
|
'change_addr': ("-c", "Change address. Default is a spare address, or the source address if it's not in the wallet"),
|
||||||
'nbits': (None, "--nbits", "Number of bits of entropy"),
|
'nbits': (None, "Number of bits of entropy"),
|
||||||
'entropy': (None, "--entropy", "Custom entropy"),
|
'entropy': (None, "Custom entropy"),
|
||||||
'segwit': (None, "--segwit", "Create segwit seed"),
|
'segwit': (None, "Create segwit seed"),
|
||||||
'language': ("-L", "--lang", "Default language for wordlist"),
|
'language': ("-L", "Default language for wordlist"),
|
||||||
'gap_limit': ("-G", "--gap", "Gap limit"),
|
'privkey': (None, "Private key. Set to '?' to get a prompt."),
|
||||||
'privkey': (None, "--privkey", "Private key. Set to '?' to get a prompt."),
|
'unsigned': ("-u", "Do not sign transaction"),
|
||||||
'unsigned': ("-u", "--unsigned", "Do not sign transaction"),
|
'rbf': (None, "Replace-by-fee transaction"),
|
||||||
'rbf': (None, "--rbf", "Replace-by-fee transaction"),
|
'locktime': (None, "Set locktime block number"),
|
||||||
'locktime': (None, "--locktime", "Set locktime block number"),
|
'domain': ("-D", "List of addresses"),
|
||||||
'domain': ("-D", "--domain", "List of addresses"),
|
'memo': ("-m", "Description of the request"),
|
||||||
'memo': ("-m", "--memo", "Description of the request"),
|
'expiration': (None, "Time in seconds"),
|
||||||
'expiration': (None, "--expiration", "Time in seconds"),
|
'timeout': (None, "Timeout in seconds"),
|
||||||
'timeout': (None, "--timeout", "Timeout in seconds"),
|
'force': (None, "Create new address beyond gap limit, if no more addresses are available."),
|
||||||
'force': (None, "--force", "Create new address beyond gap limit, if no more addresses are available."),
|
'pending': (None, "Show only pending requests."),
|
||||||
'pending': (None, "--pending", "Show only pending requests."),
|
'expired': (None, "Show only expired requests."),
|
||||||
'expired': (None, "--expired", "Show only expired requests."),
|
'paid': (None, "Show only paid requests."),
|
||||||
'paid': (None, "--paid", "Show only paid requests."),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -742,7 +743,7 @@ arg_types = {
|
||||||
'jsontx': json_loads,
|
'jsontx': json_loads,
|
||||||
'inputs': json_loads,
|
'inputs': json_loads,
|
||||||
'outputs': json_loads,
|
'outputs': json_loads,
|
||||||
'tx_fee': lambda x: str(Decimal(x)) if x is not None else None,
|
'fee': lambda x: str(Decimal(x)) if x is not None else None,
|
||||||
'amount': lambda x: str(Decimal(x)) if x != '!' else '!',
|
'amount': lambda x: str(Decimal(x)) if x != '!' else '!',
|
||||||
'locktime': int,
|
'locktime': int,
|
||||||
}
|
}
|
||||||
|
@ -854,7 +855,8 @@ def get_parser():
|
||||||
if cmdname == 'restore':
|
if cmdname == 'restore':
|
||||||
p.add_argument("-o", "--offline", action="store_true", dest="offline", default=False, help="Run offline")
|
p.add_argument("-o", "--offline", action="store_true", dest="offline", default=False, help="Run offline")
|
||||||
for optname, default in zip(cmd.options, cmd.defaults):
|
for optname, default in zip(cmd.options, cmd.defaults):
|
||||||
a, b, help = command_options[optname]
|
a, help = command_options[optname]
|
||||||
|
b = '--' + optname
|
||||||
action = "store_true" if type(default) is bool else 'store'
|
action = "store_true" if type(default) is bool else 'store'
|
||||||
args = (a, b) if a else (b,)
|
args = (a, b) if a else (b,)
|
||||||
if action == 'store':
|
if action == 'store':
|
||||||
|
|
Loading…
Reference in New Issue