mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 16:01:30 +00:00
merge signtxwithwallet and signtxwithkey
This commit is contained in:
parent
1d5f04c588
commit
cc610d352f
2 changed files with 14 additions and 17 deletions
9
electrum
9
electrum
|
@ -291,11 +291,6 @@ def run_cmdline(config):
|
||||||
else:
|
else:
|
||||||
network = None
|
network = None
|
||||||
|
|
||||||
# See if they specificed a key on the cmd line, if not prompt
|
|
||||||
if (cmd.name == 'importprivkey' and len(args)==1)\
|
|
||||||
or (cmd.name == 'signtxwithkey' and len(args)==2):
|
|
||||||
args.append(prompt_password('Enter PrivateKey (will not echo):', False))
|
|
||||||
|
|
||||||
# run the command
|
# run the command
|
||||||
if cmd.name == 'deseed':
|
if cmd.name == 'deseed':
|
||||||
if not wallet.seed:
|
if not wallet.seed:
|
||||||
|
@ -390,6 +385,10 @@ if __name__ == '__main__':
|
||||||
if config_options.get('portable') and config_options.get('wallet_path') is None:
|
if config_options.get('portable') and config_options.get('wallet_path') is None:
|
||||||
config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')
|
config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')
|
||||||
|
|
||||||
|
# If private key is passed on the command line, '?' triggers prompt.
|
||||||
|
if config_options.get('privkey') and config_options['privkey'] == '?':
|
||||||
|
config_options['privkey'] = prompt_password('Enter PrivateKey (will not echo):', False)
|
||||||
|
|
||||||
set_verbosity(config_options.get('verbose'))
|
set_verbosity(config_options.get('verbose'))
|
||||||
config = SimpleConfig(config_options)
|
config = SimpleConfig(config_options)
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ register_command('getseed', 0, 1, 1, [], [], 'Get seed phrase', 'Prin
|
||||||
register_command('getmpk', 0, 1, 0, [], [], 'Get Master Public Key', 'Return your wallet\'s master public key')
|
register_command('getmpk', 0, 1, 0, [], [], 'Get Master Public Key', 'Return your wallet\'s master public key')
|
||||||
register_command('help', 0, 0, 0, [], [], 'Print help on a command.', '')
|
register_command('help', 0, 0, 0, [], [], 'Print help on a command.', '')
|
||||||
register_command('history', 1, 1, 0, [], [], 'Wallet history', 'Returns the transaction history of your wallet')
|
register_command('history', 1, 1, 0, [], [], 'Wallet history', 'Returns the transaction history of your wallet')
|
||||||
register_command('importprivkey', 0, 1, 1, [('privkey', 'Private key')], [], 'Import a private key', '')
|
register_command('importprivkey', 0, 1, 1, [('privkey', 'Private key. Set value to \'?\' if you want to get a prompt')], [], 'Import a private key', '')
|
||||||
register_command('ismine', 0, 1, 0, [('address', 'Bitcoin address')], [], 'Check if address is in wallet', 'Return true if and only if address is in wallet')
|
register_command('ismine', 0, 1, 0, [('address', 'Bitcoin address')], [], 'Check if address is in wallet', 'Return true if and only if address is in wallet')
|
||||||
register_command('listaddresses', 0, 1, 0, [], ['show_all', 'show_labels', 'frozen', 'unused', 'funded', 'show_balance'],
|
register_command('listaddresses', 0, 1, 0, [], ['show_all', 'show_labels', 'frozen', 'unused', 'funded', 'show_balance'],
|
||||||
'List wallet addresses', 'Returns your list of addresses.')
|
'List wallet addresses', 'Returns your list of addresses.')
|
||||||
|
@ -94,8 +94,8 @@ register_command('searchcontacts', 0, 1, 0, [('query', '')], [], 'Search thr
|
||||||
register_command('setconfig', 0, 0, 0, [('key', ''), ('value', '')], [], 'Set a configuration variable', '')
|
register_command('setconfig', 0, 0, 0, [('key', ''), ('value', '')], [], 'Set a configuration variable', '')
|
||||||
register_command('setlabel', 0, 1, 0, [('txid', 'Transaction ID'), ('label', '')], [], 'Assign a label to an item', '')
|
register_command('setlabel', 0, 1, 0, [('txid', 'Transaction ID'), ('label', '')], [], 'Assign a label to an item', '')
|
||||||
register_command('sendrawtx', 1, 0, 0, [('tx', 'Serialized transaction')], [], 'Broadcast a transaction to the network.', '')
|
register_command('sendrawtx', 1, 0, 0, [('tx', 'Serialized transaction')], [], 'Broadcast a transaction to the network.', '')
|
||||||
register_command('signtxwithkey', 0, 0, 0, [('tx', 'raw_tx'), ('key', '')], [], 'Sign a serialized transaction with a key', '')
|
register_command('signtransaction', 0, 0, 0, [('tx', 'raw_tx')], ['privkey'],
|
||||||
register_command('signtxwithwallet', 0, 1, 1, [('tx', 'raw_tx')], [], 'Sign a serialized transaction with a wallet', '')
|
'Sign a transaction', 'The wallet keys will be used unless a private key is provided.')
|
||||||
register_command('signmessage', 0, 1, 1, [('address', 'Bitcoin address'), ('message', 'Message to sign.')], [],
|
register_command('signmessage', 0, 1, 1, [('address', 'Bitcoin address'), ('message', 'Message to sign.')], [],
|
||||||
'Sign a message with a key.', 'Use quotes if your message contains whitespaces')
|
'Sign a message with a key.', 'Use quotes if your message contains whitespaces')
|
||||||
register_command('unfreeze', 0, 1, 0, [('address', 'Bitcoin address')], [], 'Unfreeze the funds at one of your wallet\'s address', '')
|
register_command('unfreeze', 0, 1, 0, [('address', 'Bitcoin address')], [], 'Unfreeze the funds at one of your wallet\'s address', '')
|
||||||
|
@ -114,7 +114,6 @@ register_command('make_seed', 0, 0, 0, [], ['nbits', 'entropy', 'langua
|
||||||
register_command('check_seed', 0, 0, 0, [('seed', 'Seed phrase')], ['entropy', 'language'], 'Check that a seed was generated with external entropy.', '')
|
register_command('check_seed', 0, 0, 0, [('seed', 'Seed phrase')], ['entropy', 'language'], 'Check that a seed was generated with external entropy.', '')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
command_options = {
|
command_options = {
|
||||||
'password': ("-W", "--password", None, "Password"),
|
'password': ("-W", "--password", None, "Password"),
|
||||||
'concealed': ("-C", "--concealed", False, "Don't echo seed to console when restoring"),
|
'concealed': ("-C", "--concealed", False, "Don't echo seed to console when restoring"),
|
||||||
|
@ -133,6 +132,7 @@ command_options = {
|
||||||
'gap_limit': ("-G", "--gap", None, "Gap limit"),
|
'gap_limit': ("-G", "--gap", None, "Gap limit"),
|
||||||
'mpk': (None, "--mpk", None, "Restore from master public key"),
|
'mpk': (None, "--mpk", None, "Restore from master public key"),
|
||||||
'deserialize': ("-d", "--deserialize", False, "Deserialize transaction"),
|
'deserialize': ("-d", "--deserialize", False, "Deserialize transaction"),
|
||||||
|
'privkey': (None, "--privkey", None, "private key. Use --privkey='?' to get a prompt."),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,15 +295,13 @@ class Commands:
|
||||||
tx = Transaction.from_io(tx_inputs, outputs)
|
tx = Transaction.from_io(tx_inputs, outputs)
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
def signtxwithkey(self, raw_tx, sec):
|
def signtransaction(self, raw_tx, privkey=None):
|
||||||
tx = Transaction(raw_tx)
|
|
||||||
pubkey = bitcoin.public_key_from_private_key(sec)
|
|
||||||
tx.sign({ pubkey:sec })
|
|
||||||
return tx
|
|
||||||
|
|
||||||
def signtxwithwallet(self, raw_tx):
|
|
||||||
tx = Transaction(raw_tx)
|
tx = Transaction(raw_tx)
|
||||||
tx.deserialize()
|
tx.deserialize()
|
||||||
|
if privkey:
|
||||||
|
pubkey = bitcoin.public_key_from_private_key(sec)
|
||||||
|
tx.sign({pubkey:sec})
|
||||||
|
else:
|
||||||
self.wallet.sign_transaction(tx, self.password)
|
self.wallet.sign_transaction(tx, self.password)
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue