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("-s", "--server", dest="server", default=None, help="set server host:port:protocol, where protocol is either t (tcp), h (http), s (tcp+ssl), or g (https)")
parser.add_option("-p", "--proxy", dest="proxy", default=None, help="set proxy [type:]host[:port], where type is socks4,socks5 or http")
parser.add_option("-W", "--password", dest="password", default=None, help="set password for usage with commands (currently only implemented for create command, do not use it for longrunning gui session since the password is visible in /proc)")
parser.add_option("-1", "--oneserver", action="store_true", dest="oneserver", default=False, help="connect to one server only")
parser.add_option("--mpk", dest="mpk", default=False, help="restore from master public key")
parser.add_option("-m", action="store_true", dest="hide_gui", default=False, help="hide GUI on startup")
parser.add_option("--nbits", dest="nbits", default="128", help="number of bits for make_seed")
parser.add_option("--entropy", dest="entropy", default="1", help="custom entropy for make_seed")
return parser
def print_help(parser):
parser.print_help()
print_msg("Type 'electrum help <command>' to see the help for a specific command")
print_msg("Type 'electrum --help' to see the list of options")
run_command(known_commands['help'])
def print_help_cb(self, opt, value, parser):
print_help(parser)
sys.exit(1)
def run_command(cmd, password=None, args=None):
if args is None:
args = [] # Do not use mutables as default values!
if cmd.requires_network and not options.offline:
s = get_daemon(config, False)
if not s:
print_msg("Network daemon is not running. Try 'electrum daemon start'")
payto_syntax="payto <recipient> <amount> [label]\n<recipient> can be a bitcoin address or a label"
paytomany_syntax="paytomany <recipient> <amount> [<recipient> <amount> ...]\n<recipient> can be a bitcoin address or a label"
signmessage_syntax='signmessage <address> <message>\nIf you want to lead or end a message with spaces, or want double spaces inside the message make sure you quote the string. I.e. " Hello This is a weird String "'
verifymessage_syntax='verifymessage <address> <signature> <message>\nIf you want to lead or end a message with spaces, or want double spaces inside the message make sure you quote the string. I.e. " Hello This is a weird String "'
# command
# requires_network
# requires_wallet
# requires_password
register_command('contacts',0,0,False,True,False,'Show your list of contacts')
register_command('create',0,0,False,True,False,'Create a new wallet')
register_command('createmultisig',2,2,False,True,False,'similar to bitcoind\'s command')
register_command('createrawtransaction',2,2,False,True,False,'Create an unsigned transaction. The syntax is similar to bitcoind.')
register_command('deseed',0,0,False,True,False,'Remove seed from wallet, creating a seedless, watching-only wallet.')
register_command('decoderawtransaction',1,1,False,False,False,'similar to bitcoind\'s command')
register_command('getprivatekeys',1,1,False,True,True,'Get the private keys of a given address','getprivatekeys <bitcoin address>')
register_command('dumpprivkeys',0,0,False,True,True,'Dump all private keys in your wallet')
register_command('freeze',1,1,False,True,True,'Freeze the funds at one of your wallet\'s addresses','freeze <address>')
register_command('getbalance',0,1,True,True,False,'Return the balance of your wallet, or of one account in your wallet','getbalance [<account>]')
register_command('getservers',0,0,True,False,False,'Return the list of available servers')
register_command('getversion',0,0,False,False,False,'Return the version of your client','getversion')
register_command('getaddressbalance',1,1,True,False,False,'Return the balance of an address','getaddressbalance <address>')
register_command('getaddresshistory',1,1,True,False,False,'Return the transaction history of a wallet address','getaddresshistory <address>')
register_command('getconfig',1,1,False,False,False,'Return a configuration variable','getconfig <name>')
register_command('getpubkeys',1,1,False,True,False,'Return the public keys for a wallet address','getpubkeys <bitcoin address>')
register_command('getrawtransaction',1,1,True,False,False,'Retrieve a transaction','getrawtransaction <txhash>')
register_command('getseed',0,0,False,True,True,'Print the generation seed of your wallet.')
register_command('getmpk',0,0,False,True,False,'Return your wallet\'s master public key','getmpk')
register_command('help',0,1,False,False,False,'Prints this help')
register_command('history',0,0,True,True,False,'Returns the transaction history of your wallet')
register_command('importprivkey',1,1,False,True,True,'Import a private key','importprivkey <privatekey>')
register_command('ismine',1,1,False,True,False,'Return true if and only if address is in wallet','ismine <address>')
register_command('listaddresses',2,2,False,True,False,'Returns your list of addresses.','',listaddr_options)
register_command('listunspent',0,0,True,True,False,'Returns the list of unspent inputs in your wallet.')
register_command('getaddressunspent',1,1,True,False,False,'Returns the list of unspent inputs for an address.')
register_command('mktx',5,5,False,True,True,'Create a signed transaction','mktx <recipient> <amount> [label]',payto_options)
register_command('mksendmanytx',4,4,False,True,True,'Create a signed transaction',mksendmany_syntax,payto_options)
register_command('payto',5,5,True,True,True,'Create and broadcast a transaction.',payto_syntax,payto_options)
register_command('paytomany',4,4,True,True,True,'Create and broadcast a transaction.',paytomany_syntax,payto_options)
register_command('password',0,0,False,True,True,'Change your password')
register_command('restore',0,0,True,True,False,'Restore a wallet','',restore_options)
register_command('searchcontacts',1,1,False,True,False,'Search through contacts, return matching entries','searchcontacts <query>')
register_command('setconfig',2,2,False,False,False,'Set a configuration variable','setconfig <name> <value>')
register_command('setlabel',2,-1,False,True,False,'Assign a label to an item','setlabel <tx_hash> <label>')
register_command('sendrawtransaction',1,1,True,False,False,'Broadcasts a transaction to the network.','sendrawtransaction <tx in hexadecimal>')
register_command('signtxwithkey',1,3,False,False,False,'Sign a serialized transaction with a key','signtxwithkey <tx> <key>')
register_command('signtxwithwallet',1,3,False,True,True,'Sign a serialized transaction with a wallet','signtxwithwallet <tx>')
register_command('signmessage',2,-1,False,True,True,'Sign a message with a key',signmessage_syntax)
register_command('unfreeze',1,1,False,True,False,'Unfreeze the funds at one of your wallet\'s address','unfreeze <address>')
register_command('validateaddress',1,1,False,False,False,'Check that the address is valid','validateaddress <address>')
register_command('verifymessage',3,-1,False,False,False,'Verifies a signature',verifymessage_syntax)
register_command('encrypt',2,-1,False,False,False,'encrypt a message with pubkey','encrypt <pubkey> <message>')
register_command('decrypt',2,-1,False,True,True,'decrypt a message encrypted with pubkey','decrypt <pubkey> <message>')
register_command('getmerkle',2,2,True,False,False,'Get Merkle branch of a transaction included in a block','getmerkle <txid> <height>')
register_command('getproof',1,1,True,False,False,'Get Merkle branch of an address in the UTXO set','getproof <address>')
register_command('getutxoaddress',2,2,True,False,False,'get the address of an unspent transaction output','getutxoaddress <txid> <pos>')
register_command('sweep',2,3,True,False,False,'Sweep a private key.','sweep privkey addr [fee]')
register_command('make_seed',3,3,False,False,False,'Create a seed.','options: --nbits --entropy --lang')
register_command('check_seed',1,-1,False,False,False,'Check that a seed was generated with external entropy. Option: --entropy --lang')
# requires_network
# requires_wallet
# requires_password
# args
# optional args
register_command('contacts',False,True,False,[],[],'Show your list of contacts')
register_command('create',False,True,False,[],[],'Create a new wallet')
register_command('createrawtransaction',False,True,False,['inputs','outputs'],[],'Create an unsigned transaction. The syntax is similar to bitcoind.')
register_command('deseed',False,True,False,[],[],'Remove seed from wallet, creating a seedless, watching-only wallet.')
register_command('decoderawtransaction',False,False,False,['raw_tx'],[],'Decode raw transaction')
register_command('getprivatekeys',False,True,True,['address'],[],'Get the private keys of a given address')
register_command('dumpprivkeys',False,True,True,[],[],'Dump private keys from your wallet')
register_command('freeze',False,True,True,['address'],[],'Freeze the funds at one of your wallet\'s addresses')
register_command('getbalance',True,True,False,[],[],'Return the balance of your wallet, or of one account in your wallet')
register_command('getservers',True,False,False,[],[],'Return the list of available servers')
register_command('getaddressbalance',True,False,False,['address'],[],'Return the balance of an address')
register_command('getaddresshistory',True,False,False,['address'],[],'Return the transaction history of a wallet address')
register_command('getconfig',False,False,False,['key'],[],'Return a configuration variable')
register_command('getpubkeys',False,True,False,['address'],[],'Return the public keys for a wallet address')
register_command('getrawtransaction',True,False,False,['txid'],[],'Retrieve a transaction')
register_command('getseed',False,True,True,[],[],'Print the generation seed of your wallet.')
register_command('getmpk',False,True,False,[],[],'Return your wallet\'s master public key')
register_command('help',False,False,False,[],[],'Print help on a command.')
register_command('history',True,True,False,[],[],'Returns the transaction history of your wallet')
register_command('importprivkey',False,True,True,['privatekey'],[],'Import a private key')
register_command('ismine',False,True,False,['address'],[],'Return true if and only if address is in wallet')
register_command('listaddresses',False,True,False,[],['show_all','show_labels'],'Returns your list of addresses.')
register_command('listunspent',True,True,False,[],[],'Returns the list of unspent inputs in your wallet.')
register_command('getaddressunspent',True,False,False,['address'],[],'Returns the list of unspent inputs for an address.')
register_command('mktx',False,True,True,['recipient','amount'],['tx_fee','from_addr','change_addr'],'Create a signed transaction')
register_command('payto',True,True,True,['recipient','amount'],['tx_fee','from_addr','change_addr'],'Create and broadcast a transaction.')
register_command('password',False,True,True,[],[],'Change your password')
register_command('restore',True,True,False,[],['gap_limit','mpk','concealed'],'Restore a wallet')
register_command('searchcontacts',False,True,False,['query'],[],'Search through contacts, return matching entries')
register_command('setconfig',False,False,False,['key','value'],[],'Set a configuration variable')
register_command('setlabel',False,True,False,['txid','label'],[],'Assign a label to an item')
register_command('sendrawtransaction',True,False,False,['raw_tx'],[],'Broadcast a transaction to the network.')
register_command('signtxwithkey',False,False,False,['raw_tx','key'],[],'Sign a serialized transaction with a key')
register_command('signtxwithwallet',False,True,True,['raw_tx'],[],'Sign a serialized transaction with a wallet')
register_command('signmessage',False,True,True,['address','message'],[],'Sign a message with a key')
register_command('unfreeze',False,True,False,['address'],[],'Unfreeze the funds at one of your wallet\'s address')
register_command('validateaddress',False,False,False,['address'],[],'Check that the address is valid')
register_command('verifymessage',False,False,False,['address','message'],[],'Verify a signature')
register_command('version',False,False,False,[],[],'Return the version of your client')
register_command('encrypt',False,False,False,['pubkey','message'],[],'Encrypt a message with a public key')
register_command('decrypt',False,True,True,['pubkey','message'],[],'Decrypt a message encrypted with a public key')
register_command('getmerkle',True,False,False,['txid','height'],[],'Get Merkle branch of a transaction included in a block')
register_command('getproof',True,False,False,['address'],[],'Get Merkle branch of an address in the UTXO set')
register_command('getutxoaddress',True,False,False,['txid','pos'],[],'Get the address of an unspent transaction output')
register_command('sweep',True,False,False,['privkey','destination_address'],['tx_fee'],'Sweep a private key.')
register_command('make_seed',False,False,False,[],['nbits','entropy','language'],'Create a seed.')
register_command('check_seed',False,False,False,['seed'],['entropy'],'Check that a seed was generated with external entropy.')
#register_command('mksendmanytx', False, True, True, 'Create a signed transaction', mksendmany_syntax, payto_options)
#register_command('paytomany', True, True, True, 'Create and broadcast a transaction.', paytomany_syntax, payto_options)
command_options={
'password':("-W","--password",None,"Password"),
'concealed':("-C","--concealed",False,"Don't echo seed to console when restoring"),
'show_all':("-a","--all",False,"Show all addresses"),
'show_labels':("-l","--labels",False,"Show the labels of listed addresses"),
'tx_fee':("-f","--fee",None,"set tx fee"),
'from_addr':("-F","--fromaddr",None,"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."),
'change_addr':("-c","--changeaddr",None,"set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet"),
'nbits':(None,"--nbits","128","Number of bits of entropy"),