@ -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 ( ' 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 ( ' 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 ( ' 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 ( ' 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 ( ' getaddressbalance ' , 1 , 1 , True , False , 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 ( ' 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 ( ' 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 ( ' 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> ' )
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 ( ' 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 ( ' 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 ( ' 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 ( ' 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 ( ' 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 )
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 ( ' 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 ( ' 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 . _callback = callback
self . password = None
self . password = None
def _run ( self , method , args , password_getter ) :
def _run ( self , method , args , password_getter ) :
cmd = known_commands [ method ]
cmd = known_commands [ method ]
if cmd . requires_password and self . wallet . use_encryption :
if cmd . requires_password and self . wallet . use_encryption :
@ -117,11 +121,14 @@ class Commands:
apply ( self . _callback , ( ) )
apply ( self . _callback , ( ) )
return result
return result
def getaddresshistory ( self , addr ) :
def getaddresshistory ( self , addr ) :
assert self . wallet . is_mine ( addr )
return self . network . synchronous_get ( [ ( ' blockchain.address.get_history ' , [ addr ] ) ] ) [ 0 ]
h = self . wallet . get_history ( addr )
if h is None : h = self . network . synchronous_get ( [ ( ' blockchain.address.get_history ' , [ addr ] ) ] ) [ 0 ]
return h
def stop_network ( self ) :
return self . network . stop ( )
def listunspent ( self ) :
def listunspent ( self ) :
import copy
import copy
@ -129,6 +136,11 @@ class Commands:
for i in l : i [ " value " ] = str ( Decimal ( i [ " value " ] ) / 100000000 )
for i in l : i [ " value " ] = str ( Decimal ( i [ " value " ] ) / 100000000 )
return l
return l
def getaddressunspent ( self , addr ) :
return self . network . synchronous_get ( [ ( ' blockchain.address.getunspent ' , [ addr ] ) ] ) [ 0 ]
def createrawtransaction ( self , inputs , outputs ) :
def createrawtransaction ( self , inputs , outputs ) :
# convert to own format
# convert to own format
for i in inputs :
for i in inputs :
@ -199,10 +211,11 @@ class Commands:
return out
return out
def getaddressbalance ( self , addr ) :
def getaddressbalance ( self , addr ) :
c , u = self . wallet . get_addr_balance ( addr )
# c, u = self.wallet.get_addr_balance(addr)
out = { " confirmed " : str ( Decimal ( c ) / 100000000 ) }
# out = { "confirmed": str(Decimal(c)/100000000) }
if u : out [ " unconfirmed " ] = str ( Decimal ( u ) / 100000000 )
# if u: out["unconfirmed"] = str(Decimal(u)/100000000)
return out
# return out
return self . network . synchronous_get ( [ ( ' blockchain.address.get_balance ' , [ addr ] ) ] ) [ 0 ]
def getservers ( self ) :
def getservers ( self ) :
return self . network . get_servers ( )
return self . network . get_servers ( )
@ -350,11 +363,19 @@ class Commands:
if cmd . options : print_msg ( " options: \n " + cmd . options )
if cmd . options : print_msg ( " options: \n " + cmd . options )
return None
return None
def getrawtransaction ( self , tx_hash ) :
def getrawtransaction ( self , tx_hash ) :
import transaction
if self . wallet :
if self . wallet :
tx = self . wallet . transactions . get ( tx_hash )
tx = self . wallet . transactions . get ( tx_hash )
if tx :
if tx :
return 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 "