ThomasV 11 years ago
parent
commit
7c6bc72cb4
  1. 15
      electrum
  2. 25
      lib/commands.py
  3. 10
      lib/network.py
  4. 2
      scripts/block_headers

15
electrum

@ -121,7 +121,7 @@ def run_command(cmd, password=None, args=[]):
try:
result = func(*args[1:])
except socket.error:
print "Network server not found."
print "Daemon not running"
sys.exit(1)
except Exception:
traceback.print_exc(file=sys.stdout)
@ -222,9 +222,6 @@ if __name__ == '__main__':
if cmd.name in ['create', 'restore']:
if storage.file_exists:
sys.exit("Error: Remove the existing wallet first!")
@ -370,7 +367,7 @@ if __name__ == '__main__':
args = args[0:cmd.min_args] + [message]
if cmd.name == 'start_network':
if cmd.name == 'daemon' and args[1] == 'start':
pid = os.fork()
if (pid == 0): # The first child.
os.chdir("/")
@ -397,13 +394,9 @@ if __name__ == '__main__':
server.running = True
while server.running:
server.handle_request()
print_msg("Server stopped")
sys.exit(0)
else:
sys.exit(0)
else:
sys.exit(0)
print_msg("Daemon stopped")
sys.exit(0)
# run the command
if cmd.name == 'deseed':

25
lib/commands.py

@ -96,8 +96,8 @@ register_command('unfreeze', 1, 1, False, True, False, 'Unfreeze th
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('start_network', 0, 0, False, False, False, 'start the daemon')
register_command('stop_network', 0, 0, True, False, False, 'stop the daemon')
register_command('daemon', 1, 1, True, False, False, 'start/stop daemon')
@ -126,8 +126,16 @@ class Commands:
return self.network.synchronous_get([ ('blockchain.address.get_history',[addr]) ])[0]
def stop_network(self):
return self.network.stop()
def daemon(self, arg):
if arg=='stop':
return self.network.stop()
elif arg=='status':
return {
'server':self.network.main_server(),
'connected':self.network.is_connected()
}
else:
return "unknown command \"%s\""% arg
def listunspent(self):
@ -138,7 +146,7 @@ class Commands:
def getaddressunspent(self, addr):
return self.network.synchronous_get([ ('blockchain.address.getunspent',[addr]) ])[0]
return self.network.synchronous_get([ ('blockchain.address.listunspent',[addr]) ])[0]
def createrawtransaction(self, inputs, outputs):
@ -211,11 +219,8 @@ class Commands:
return out
def getaddressbalance(self, addr):
# c, u = self.wallet.get_addr_balance(addr)
# out = { "confirmed": str(Decimal(c)/100000000) }
# if u: out["unconfirmed"] = str(Decimal(u)/100000000)
# return out
return self.network.synchronous_get([ ('blockchain.address.get_balance',[addr]) ])[0]
b = self.network.synchronous_get([ ('blockchain.address.get_balance',[addr]) ])[0]
return str(Decimal(b)/100000000)
def getservers(self):
return self.network.get_servers()

10
lib/network.py

@ -421,6 +421,16 @@ class Network(threading.Thread):
class NetworkProxy:
# interface to the network object.
# handle subscriptions and callbacks
# the network object can be jsonrpc server
def __init__(self, network):
self.network = network
if __name__ == "__main__":
import simple_config
config = simple_config.SimpleConfig({'verbose':True, 'server':'ecdsa.org:50002:s'})

2
scripts/block_headers

@ -5,7 +5,7 @@
import time, electrum
# 1. start the interface and wait for connection
interface = electrum.Interface('electrum.no-ip.org:50002:s')
interface = electrum.Interface('ecdsa.net:50002:s')
interface.start(wait = True)
if not interface.is_connected:
print "not connected"

Loading…
Cancel
Save