The monerowallet
module¶
Provide pythonic way to request a Monero wallet.
Example: |
---|
>>> import monerowallet
>>> mw = monerowallet.MoneroWallet()
>>> mw.getaddress()
'94EJSG4URLDVwzAgDvCLaRwFGHxv75DT5MvFp1YfAxQU9icGxjVJiY8Jr9YF1atXN7UFBDx3vJq2s3CzULkPrEAuEioqyrP'
-
class
monerowallet.
MoneroWallet
(protocol='http', host='127.0.0.1', port=18082, path='/json_rpc')¶ The MoneroWallet class. Instantiate a MoneroWallet object with parameters to dialog with the RPC wallet server.
Parameters: - protocol (str) – Protocol for requesting the RPC server (‘http’ or ‘https, defaults to ‘http’)
- host – The host for requesting the RPC server (defaults to ‘127.0.0.1’)
- port (str) – The port for requesting the RPC server (defaults to 18082)
- path (str) – The path for requesting the RPC server (defaults to ‘/json_rpc’)
Returns: A MoneroWallet object
Return type: Example: >>> mw = MoneroWallet() >>> mw <monerowallet.MoneroWallet object at 0x7fe09e4e8da0>
-
get_bulk_payments
(payment_ids, min_block_height)¶ - Get a list of incoming payments using a given payment id, or a list of payments ids, from a given height. This method is the preferred method over get_payments because it has the same functionality but is more extendable. Either is fine for looking up transactions by a single payment ID.
Parameters: payment_ids (list) – A list of incoming payments Returns: A list of dictionaries with the details of the incoming payments Return type: dict Example: >>> mw.get_bulk_payments(['94dd4c2613f5919d'], 1148609) >>> mw.get_bulk_payments(['fdfcfd993482b58b'], 1157950) [{'unlock_time': 0, 'amount': 1000000000, 'tx_hash': 'db3870905ce3c8ca349e224688c344371addca7be4eb36d5dbc61600c8f75726', 'block_height': 1157951, 'payment_id': 'fdfcfd993482b58b'}]
-
get_payments
(payment_id)¶ - Get a list of incoming payments using a given payment id.
Parameters: payment_id (str) – Payment id Returns: A list of dictionaries with the details of the incoming payments Return type: list Example: >>> mw = MoneroWallet() >>> mw.get_payments('fdfcfd993482b58b') [{'unlock_time': 0, 'amount': 1000000000, 'tx_hash': 'db3870905ce3c8ca349e224688c344371addca7be4eb36d5dbc61600c8f75726', 'block_height': 1157951, 'payment_id': 'fdfcfd993482b58b'}]
-
getaddress
()¶ - Return the wallet’s address.
Returns: A string with the address of the wallet Return type: str Example: >>> mw.getaddress() '94EJSG4URLDVwzAgDvCLaRwFGHxv75DT5MvFp1YfAxQU9icGxjVJiY8Jr9YF1atXN7UFBDx3vJq2s3CzULkPrEAuEioqyrP'
-
getbalance
()¶ - Return the wallet’s balance.
Returns: A dictionary with the wallet balance and the unlocked balance Return type: dict Example: >>> mw.getbalance() {'unlocked_balance': 2262265030000, 'balance': 2262265030000}
-
getheight
()¶ - Returns the wallet’s current block height.
Returns: An integer with the wallet’s current block height Return type: int Example: >>> mw.getheight() 1146043
-
incoming_transfers
(transfer_type='all')¶ - Return a list of incoming transfers to the wallet.
Parameters: transfer_type (str) – The transfer type (‘all’, ‘available’ or ‘unavailable’) Returns: A list with the incoming transfers Return type: list Example: >>> import pprint # just useful for a nice display of data >>> pprint.pprint(mw.incoming_transfers()) [{'amount': 30000, 'global_index': 4593, 'spent': False, 'tx_hash': '0a4562f0bfc4c5e7123e0ff212b1ca810c76a95fa45b18a7d7c4f123456caa12', 'tx_size': 606}, {'amount': 5000000, 'global_index': 23572, 'spent': False, 'tx_hash': '1a4567f0afc7e5e7123e0aa192b2ca101c75a95ba12b53a1d7c4f871234caa11', 'tx_size': 606}, ]
-
make_integrated_address
(payment_id='')¶ - Make an integrated address from the wallet address and a payment id.
Parameters: payment_id (str) – Specific payment id. Otherwise it is randomly generated Returns: A dictionary with both integrated address and payment id Return type: dict Example: >>> mw.make_integrated_address() {'integrated_address': '4JwWT4sy2bjFfzSxvRBUxTLftcNM98DT5MvFp4JNJRih3icqrjVJiY8Jr9YF1atXN7UFBDx4vKq4s3ozUpkwrEAuMLBRqCy9Vhg9Y49vcq', 'payment_id': '8c9a5fd001c3c74b'}
-
query_key
(key_type='mnemonic')¶ - Return the spend or view private key.
Parameters: key_type (str) – Which key to retrieve (‘mnemonic’ or ‘view_key’, default is ‘mnemonic’) Returns: A string with either the mnemonic-format key either the hexadecimal-format key Return type: str Example: >>> mw.query_key(key_type='mnemonic') 'adapt adapt nostril using suture tail faked relic huddle army gags bugs abyss wield tidy jailed ridges does stacking karate hockey using suture tail faked' >>> mw.query_key(key_type='view_key') '49c087c10112eea3554d85bc9813c57f8bbd1cac1f3abb3b70d12cbea712c908'
-
split_integrated_address
(integrated_address)¶ Retrieve the standard address and payment id corresponding to an integrated address.
Parameters: integrated_address (str) – the integrated address to split Returns: a dictionary with the payment id and the standard address Return type: dict Example: >>> mw.split_integrated_address('4JwWT4sy2bjFfzSxvRBUxTLftcNM98DT5MvFp4JNJRih3icqrjVJiY8Jr9YF1atXN7UFBDx4vKq4s3ozUpkwrEAuMLBRqCy9Vhg9Y49vcq') {'standard_address': '12GLv8KzVhxehv712FWPTF7CSWuVjuBarFd17QP163uxMaFyoqwmDf1aiRtS5jWgCkRsk12ycdBNJa6V4La8joznK4GAhcq', 'payment_id': '1acca0543e3082fa'}
-
stop_wallet
()¶ - Stops the wallet, storing the current state.
Returns: An empty dictionary Return type: dict Example: >>> mw.stop_wallet() {}
-
store
()¶ - Save the blockchain.
Returns: An empty dictionary Return type: dict Example: >>> mw.store() {}
-
sweep_dust
()¶ Send all dust outputs back to the wallet’s, to make them easier to spend (and mix).
Returns: a list of the hashes of the transactions Return type: list Example: >>> mw.sweep_dust() []
-
transfer
(destinations)¶ - Send monero to a number of recipients.
Parameters: destinations – a list of destinations to receive XMR Returns: a dict of with the hash and the key of the transaction Example: >>> mw.transfer([{'amount': 10000000000, 'address': '51EqSG4URLDFfzSxvRBUxTLftcMM76DT3MvFp3JNJRih2icqrjVJiY5Jr2YF1atXN7UFBDx4vKq4s3ozUpkwrEAuEioqyPY'}]) {'tx_hash': 'd4d0048c275e816ae1f6f55b4b04f7d508662679c044741db2aeb7cd63452059', 'tx_key': ''}
-
transfer_split
(destinations)¶ - Send monero to a number of recipients.
Parameters: destinations – a list of destinations to receive XMR Returns: a list with the transaction hashes Return type: list Example: >>> mw.transfer_split([{'amount': 10000000000, 'address': '59EqSG5UKBDFfzSxvRABxTLftcNM77DT3MvFp4JNJRLh3KCTrjBJiY4Jr9YB2atXN7UFBDx4vKq4s3ozUpkwrEAuEioqyBP'}, {'amount': 10000000000, 'address': '12EqFG3DCSDFfzSx5RBUxTLftcNM43DT2MvFp2JNJRih4444rjVJFY8Jr9YF2AtXN7UFBDx4vKq4s3ozUKkwrVAuAi55yCC'}]) ['653a5da2dd541ab4b3d9811f84255bb243dd7338c1218c5e75036725b6ca123e']