print_msg("Network daemon connected to " + network.interface.connection_msg)
from SimpleXMLRPCServer import SimpleXMLRPCServer
server = SimpleXMLRPCServer(('localhost',8000), allow_none=True, logRequests=False)
+ server.network = network
server.register_function(lambda: 'pong', 'ping')
server.register_function(network.synchronous_get, 'synchronous_get')
server.register_function(network.get_servers, 'get_servers')
if (pid2 == 0): # Second child
server = start_server()
server.running = True
+ timeout = 60
+ t0 = time.time()
+ server.socket.settimeout(timeout)
while server.running:
server.handle_request()
- print_msg("Daemon stopped")
+ t = time.time()
+ if t - t0 > 0.9*timeout:
+ break
+ if not server.network.is_connected():
+ break
+ t0 = t
sys.exit(0)
time.sleep(2)
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('listaddresses', 2, 2, False, True, False, 'Returns your list of addresses.', '', listaddr_options)
-register_command('listunspent', 0, 0, True, False, False, 'Returns the list of unspent inputs in your wallet.')
-register_command('getaddressunspent', 1, 1, True, False, False, 'Returns the list of unspent inputs in your wallet.')
+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)
return out
def getaddressbalance(self, addr):
- b = self.network.synchronous_get([ ('blockchain.address.get_balance',[addr]) ])[0]
- return str(Decimal(b)/100000000)
+ out = self.network.synchronous_get([ ('blockchain.address.get_balance',[addr]) ])[0]
+ out["confirmed"] = str(Decimal(out["confirmed"])/100000000)
+ out["unconfirmed"] = str(Decimal(out["unconfirmed"])/100000000)
+ return out
+
def getproof(self, addr):
p = self.network.synchronous_get([ ('blockchain.address.get_proof',[addr]) ])[0]