Merge branch 'master' of gitorious.org:electrum/electrum
This commit is contained in:
commit
d497a37370
|
@ -278,7 +278,9 @@ class Wallet:
|
||||||
|
|
||||||
def is_valid(self,addr):
|
def is_valid(self,addr):
|
||||||
ADDRESS_RE = re.compile('[1-9A-HJ-NP-Za-km-z]{26,}\\Z')
|
ADDRESS_RE = re.compile('[1-9A-HJ-NP-Za-km-z]{26,}\\Z')
|
||||||
return ADDRESS_RE.match(addr)
|
if not ADDRESS_RE.match(addr): return False
|
||||||
|
h = bc_address_to_hash_160(addr)
|
||||||
|
return addr == hash_160_to_bc_address(h)
|
||||||
|
|
||||||
def create_new_address(self, for_change, password):
|
def create_new_address(self, for_change, password):
|
||||||
seed = self.pw_decode( self.seed, password)
|
seed = self.pw_decode( self.seed, password)
|
||||||
|
@ -596,6 +598,8 @@ class Wallet:
|
||||||
tx['default_label'] = default_label
|
tx['default_label'] = default_label
|
||||||
|
|
||||||
def mktx(self, to_address, amount, label, password, fee=None):
|
def mktx(self, to_address, amount, label, password, fee=None):
|
||||||
|
if not self.is_valid(to_address):
|
||||||
|
return False, "Invalid address"
|
||||||
if fee is None: fee = self.fee
|
if fee is None: fee = self.fee
|
||||||
try:
|
try:
|
||||||
inputs, outputs = wallet.choose_inputs_outputs( to_address, amount, fee, password )
|
inputs, outputs = wallet.choose_inputs_outputs( to_address, amount, fee, password )
|
||||||
|
@ -621,14 +625,11 @@ class Wallet:
|
||||||
return True, out
|
return True, out
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
known_commands = ['help', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'gui', 'mktx','seed']
|
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'gui', 'mktx','seed']
|
||||||
|
|
||||||
usage = "usage: %prog [options] command args\nCommands: "+ (', '.join(known_commands))
|
usage = "usage: %prog [options] command args\nCommands: "+ (', '.join(known_commands))
|
||||||
|
|
||||||
|
@ -719,7 +720,7 @@ if __name__ == '__main__':
|
||||||
cmd = 'help'
|
cmd = 'help'
|
||||||
|
|
||||||
# open session
|
# open session
|
||||||
if cmd not in ['password', 'mktx', 'history', 'label','contacts','help']:
|
if cmd not in ['password', 'mktx', 'history', 'label','contacts','help','validateaddress']:
|
||||||
wallet.new_session()
|
wallet.new_session()
|
||||||
wallet.update()
|
wallet.update()
|
||||||
wallet.save()
|
wallet.save()
|
||||||
|
@ -766,6 +767,10 @@ if __name__ == '__main__':
|
||||||
import mnemonic
|
import mnemonic
|
||||||
print wallet.seed, '"'+' '.join(mnemonic.mn_encode(wallet.seed))+'"'
|
print wallet.seed, '"'+' '.join(mnemonic.mn_encode(wallet.seed))+'"'
|
||||||
|
|
||||||
|
elif cmd == 'validateaddress':
|
||||||
|
addr = args[1]
|
||||||
|
print wallet.is_valid(addr)
|
||||||
|
|
||||||
elif cmd == 'balance':
|
elif cmd == 'balance':
|
||||||
c, u = wallet.get_balance()
|
c, u = wallet.get_balance()
|
||||||
if u:
|
if u:
|
||||||
|
@ -828,8 +833,8 @@ if __name__ == '__main__':
|
||||||
for k, v in wallet.labels.items():
|
for k, v in wallet.labels.items():
|
||||||
if v == to_address:
|
if v == to_address:
|
||||||
to_address = k
|
to_address = k
|
||||||
|
print "alias", to_address
|
||||||
break
|
break
|
||||||
print "alias", to_address
|
|
||||||
r, h = wallet.mktx( to_address, amount, label, password, fee = options.tx_fee )
|
r, h = wallet.mktx( to_address, amount, label, password, fee = options.tx_fee )
|
||||||
if r and cmd=='payto':
|
if r and cmd=='payto':
|
||||||
r, h = wallet.sendtx( tx )
|
r, h = wallet.sendtx( tx )
|
||||||
|
|
Loading…
Reference in New Issue