json rpc daemon
This commit is contained in:
@@ -67,9 +67,9 @@ register_command('dumpprivkeys', 0, 0, False, True, True, 'dump all pr
|
||||
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, True, False, 'Return the balance of an address', 'getaddressbalance <address>')
|
||||
register_command('getaddresshistory', 1, 1, True, True, False, 'Return the transaction history of a wallet address', 'getaddresshistory <address>')
|
||||
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>')
|
||||
@@ -79,7 +79,8 @@ register_command('help', 0, 1, False, False, False, 'Prints this
|
||||
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, True, False, 'Returns the list of unspent inputs in your wallet.')
|
||||
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('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)
|
||||
@@ -95,6 +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')
|
||||
|
||||
|
||||
|
||||
@@ -106,6 +109,7 @@ class Commands:
|
||||
self._callback = callback
|
||||
self.password = None
|
||||
|
||||
|
||||
def _run(self, method, args, password_getter):
|
||||
cmd = known_commands[method]
|
||||
if cmd.requires_password and self.wallet.use_encryption:
|
||||
@@ -117,11 +121,14 @@ class Commands:
|
||||
apply(self._callback, ())
|
||||
return result
|
||||
|
||||
|
||||
def getaddresshistory(self, addr):
|
||||
assert self.wallet.is_mine(addr)
|
||||
h = self.wallet.get_history(addr)
|
||||
if h is None: h = self.network.synchronous_get([ ('blockchain.address.get_history',[addr]) ])[0]
|
||||
return h
|
||||
return self.network.synchronous_get([ ('blockchain.address.get_history',[addr]) ])[0]
|
||||
|
||||
|
||||
def stop_network(self):
|
||||
return self.network.stop()
|
||||
|
||||
|
||||
def listunspent(self):
|
||||
import copy
|
||||
@@ -129,6 +136,11 @@ class Commands:
|
||||
for i in l: i["value"] = str(Decimal(i["value"])/100000000)
|
||||
return l
|
||||
|
||||
|
||||
def getaddressunspent(self, addr):
|
||||
return self.network.synchronous_get([ ('blockchain.address.getunspent',[addr]) ])[0]
|
||||
|
||||
|
||||
def createrawtransaction(self, inputs, outputs):
|
||||
# convert to own format
|
||||
for i in inputs:
|
||||
@@ -199,10 +211,11 @@ 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
|
||||
# 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]
|
||||
|
||||
def getservers(self):
|
||||
return self.network.get_servers()
|
||||
@@ -350,11 +363,19 @@ class Commands:
|
||||
if cmd.options: print_msg("options:\n" + cmd.options)
|
||||
return None
|
||||
|
||||
|
||||
def getrawtransaction(self, tx_hash):
|
||||
import transaction
|
||||
if self.wallet:
|
||||
tx = self.wallet.transactions.get(tx_hash)
|
||||
if tx:
|
||||
return tx
|
||||
return self.network.retrieve_transaction(tx_hash)
|
||||
|
||||
r = self.network.synchronous_get([ ('blockchain.transaction.get',[tx_hash]) ])[0]
|
||||
if r:
|
||||
return transaction.Transaction(r)
|
||||
else:
|
||||
return "unknown transaction"
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user