mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Remove excessive get_ prefixes from method names
This commit is contained in:
parent
218d3dc36f
commit
c695e43883
11 changed files with 116 additions and 116 deletions
|
@ -37,10 +37,10 @@ Let's start with the master address:
|
|||
In [3]: a.is_testnet()
|
||||
Out[3]: True
|
||||
|
||||
In [4]: a.get_spend_key()
|
||||
In [4]: a.spend_key()
|
||||
Out[4]: 'f0481b63cb937fa5960529247ebf6db627ff1b0bb88de9feccc3c504c16aa4b0'
|
||||
|
||||
In [5]: a.get_view_key()
|
||||
In [5]: a.view_key()
|
||||
Out[5]: '2c5ba76d22e48a7ea4ddabea3cce66808ba0cc91265371910f893962e977af1e'
|
||||
|
||||
In [6]: type(a)
|
||||
|
@ -55,10 +55,10 @@ We may use a subaddress too:
|
|||
In [8]: b.is_testnet()
|
||||
Out[8]: True
|
||||
|
||||
In [9]: b.get_spend_key()
|
||||
In [9]: b.spend_key()
|
||||
Out[9]: 'ae7e136f46f618fe7f4a6b323ed60864c20070bf110978d7e3868686d5677318'
|
||||
|
||||
In [10]: b.get_view_key()
|
||||
In [10]: b.view_key()
|
||||
Out[10]: '2bf801cdaf3a8b41020098a6d5e194f48fa62129fe9d8f09d19fee9260665baa'
|
||||
|
||||
In [11]: type(b)
|
||||
|
@ -85,13 +85,13 @@ an **integrated address**.
|
|||
In [13]: ia
|
||||
Out[13]: ABySz66nm1QUhPiwoAbR2tXU9LJu2U6fJjcsv3rxgkVRWU6tEYcn6C1NBc7wqCv5V7NW3zeYuzKf6RGGgZTFTpVC623BT1ptXvVU2GjR1B
|
||||
|
||||
In [14]: ia.get_base_address()
|
||||
In [14]: ia.base_address()
|
||||
Out[14]: A2GmyHHJ9jtUhPiwoAbR2tXU9LJu2U6fJjcsv3rxgkVRWU6tEYcn6C1NBc7wqCv5V7NW3zeYuzKf6RGGgZTFTpVC4QxAiAX
|
||||
|
||||
In [15]: ia.get_base_address() == a
|
||||
In [15]: ia.base_address() == a
|
||||
Out[15]: True
|
||||
|
||||
In [16]: ia.get_payment_id()
|
||||
In [16]: ia.payment_id()
|
||||
Out[16]: 00000feedbadbeef
|
||||
|
||||
|
||||
|
|
|
@ -85,10 +85,10 @@ Connect to the wallet
|
|||
|
||||
In [3]: w = Wallet(JSONRPCWallet(port=28088))
|
||||
|
||||
In [4]: w.get_address()
|
||||
In [4]: w.address()
|
||||
Out[4]: A2GmyHHJ9jtUhPiwoAbR2tXU9LJu2U6fJjcsv3rxgkVRWU6tEYcn6C1NBc7wqCv5V7NW3zeYuzKf6RGGgZTFTpVC4QxAiAX
|
||||
|
||||
In [5]: w.get_balance()
|
||||
In [5]: w.balance()
|
||||
Out[5]: Decimal('0E-12')
|
||||
|
||||
Congratulations! You have connected to the wallet. You may now proceed to the
|
||||
|
|
|
@ -9,33 +9,33 @@ class Account(object):
|
|||
self.index = index
|
||||
self._backend = backend
|
||||
|
||||
def get_balances(self):
|
||||
return self._backend.get_balances(account=self.index)
|
||||
def balances(self):
|
||||
return self._backend.balances(account=self.index)
|
||||
|
||||
def get_balance(self, unlocked=False):
|
||||
return self._backend.get_balances(account=self.index)[1 if unlocked else 0]
|
||||
def balance(self, unlocked=False):
|
||||
return self._backend.balances(account=self.index)[1 if unlocked else 0]
|
||||
|
||||
def get_address(self):
|
||||
def address(self):
|
||||
"""
|
||||
Return account's main address.
|
||||
"""
|
||||
return self._backend.get_addresses(account=self.index)[0]
|
||||
return self._backend.addresses(account=self.index)[0]
|
||||
|
||||
def get_addresses(self):
|
||||
return self._backend.get_addresses(account=self.index)
|
||||
def addresses(self):
|
||||
return self._backend.addresses(account=self.index)
|
||||
|
||||
def new_address(self, label=None):
|
||||
return self._backend.new_address(account=self.index, label=label)
|
||||
|
||||
def get_payments(self, payment_id=None):
|
||||
return self._backend.get_payments(account=self.index, payment_id=payment_id)
|
||||
def payments(self, payment_id=None):
|
||||
return self._backend.payments(account=self.index, payment_id=payment_id)
|
||||
|
||||
def get_transactions_in(self, confirmed=True, unconfirmed=False):
|
||||
return self._backend.get_transactions_in(
|
||||
def transactions_in(self, confirmed=True, unconfirmed=False):
|
||||
return self._backend.transactions_in(
|
||||
account=self.index, confirmed=confirmed, unconfirmed=unconfirmed)
|
||||
|
||||
def get_transactions_out(self, confirmed=True, unconfirmed=True):
|
||||
return self._backend.get_transactions_out(
|
||||
def transactions_out(self, confirmed=True, unconfirmed=True):
|
||||
return self._backend.transactions_out(
|
||||
account=self.index, confirmed=confirmed, unconfirmed=unconfirmed)
|
||||
|
||||
def transfer(self, address, amount,
|
||||
|
|
|
@ -48,14 +48,14 @@ class Address(object):
|
|||
"""
|
||||
return self._decoded[0] == self._valid_netbytes[1]
|
||||
|
||||
def get_view_key(self):
|
||||
def view_key(self):
|
||||
"""Returns public view key.
|
||||
|
||||
:rtype: str
|
||||
"""
|
||||
return hexlify(self._decoded[33:65]).decode()
|
||||
|
||||
def get_spend_key(self):
|
||||
def spend_key(self):
|
||||
"""Returns public spend key.
|
||||
|
||||
:rtype: str
|
||||
|
@ -116,14 +116,14 @@ class IntegratedAddress(Address):
|
|||
"is {addr} ({len} chars length)".format(addr=address, len=len(address)))
|
||||
self._decode(address)
|
||||
|
||||
def get_payment_id(self):
|
||||
def payment_id(self):
|
||||
"""Returns the integrated payment id.
|
||||
|
||||
:rtype: PaymentID
|
||||
"""
|
||||
return numbers.PaymentID(hexlify(self._decoded[65:-4]).decode())
|
||||
|
||||
def get_base_address(self):
|
||||
def base_address(self):
|
||||
"""Returns the base address without payment id.
|
||||
:rtype: Address
|
||||
"""
|
||||
|
|
|
@ -23,7 +23,7 @@ class JSONRPCDaemon(object):
|
|||
port=port)
|
||||
_log.debug("JSONRPC daemon backend URL: {url}".format(url=self.url))
|
||||
|
||||
def get_info(self):
|
||||
def info(self):
|
||||
info = self.raw_jsonrpc_request('get_info')
|
||||
return info
|
||||
|
||||
|
@ -37,7 +37,7 @@ class JSONRPCDaemon(object):
|
|||
"{status}: {reason}".format(**res),
|
||||
details=res)
|
||||
|
||||
def get_mempool(self):
|
||||
def mempool(self):
|
||||
res = self.raw_request('/get_transaction_pool', {})
|
||||
txs = []
|
||||
for tx in res.get('transactions', []):
|
||||
|
@ -113,20 +113,20 @@ class JSONRPCWallet(object):
|
|||
_log.debug("JSONRPC wallet backend auth: '{user}'/'{stars}'".format(
|
||||
user=user, stars=('*' * len(password)) if password else ''))
|
||||
|
||||
def get_height(self):
|
||||
def height(self):
|
||||
return self.raw_request('getheight')['height']
|
||||
|
||||
def get_spend_key(self):
|
||||
def spend_key(self):
|
||||
# NOTE: This will fail on 0.11.x, the method was missing
|
||||
return self.raw_request('query_key', {'key_type': 'spend_key'})['key']
|
||||
|
||||
def get_view_key(self):
|
||||
def view_key(self):
|
||||
return self.raw_request('query_key', {'key_type': 'view_key'})['key']
|
||||
|
||||
def get_seed(self):
|
||||
def seed(self):
|
||||
return self.raw_request('query_key', {'key_type': 'mnemonic'})['key']
|
||||
|
||||
def get_accounts(self):
|
||||
def accounts(self):
|
||||
accounts = []
|
||||
try:
|
||||
_accounts = self.raw_request('get_accounts')
|
||||
|
@ -147,7 +147,7 @@ class JSONRPCWallet(object):
|
|||
_account = self.raw_request('create_account', {'label': label})
|
||||
return Account(self, _account['account_index']), SubAddress(_account['address'])
|
||||
|
||||
def get_addresses(self, account=0):
|
||||
def addresses(self, account=0):
|
||||
_addresses = self.raw_request('getaddress', {'account_index': account})
|
||||
if 'addresses' not in _addresses:
|
||||
# monero <= 0.11
|
||||
|
@ -165,11 +165,11 @@ class JSONRPCWallet(object):
|
|||
'create_address', {'account_index': account, 'label': label})
|
||||
return SubAddress(_address['address'])
|
||||
|
||||
def get_balances(self, account=0):
|
||||
def balances(self, account=0):
|
||||
_balance = self.raw_request('getbalance', {'account_index': account})
|
||||
return (from_atomic(_balance['balance']), from_atomic(_balance['unlocked_balance']))
|
||||
|
||||
def get_payments(self, account=0, payment_id=0):
|
||||
def payments(self, account=0, payment_id=0):
|
||||
payment_id = PaymentID(payment_id)
|
||||
_log.debug("Getting payments for account {acc}, payment_id {pid}".format(
|
||||
acc=account, pid=payment_id))
|
||||
|
@ -183,7 +183,7 @@ class JSONRPCWallet(object):
|
|||
pmts.append(self._inpayment(data))
|
||||
return pmts
|
||||
|
||||
def get_transactions_in(self, account=0, confirmed=True, unconfirmed=False):
|
||||
def transactions_in(self, account=0, confirmed=True, unconfirmed=False):
|
||||
_txns = self.raw_request('get_transfers',
|
||||
{'account_index': account, 'in': confirmed, 'out': False, 'pool': unconfirmed})
|
||||
txns = _txns.get('in', [])
|
||||
|
@ -191,7 +191,7 @@ class JSONRPCWallet(object):
|
|||
txns.extend(_txns.get('pool', []))
|
||||
return [self._inpayment(tx) for tx in sorted(txns, key=operator.itemgetter('timestamp'))]
|
||||
|
||||
def get_transactions_out(self, account=0, confirmed=True, unconfirmed=True):
|
||||
def transactions_out(self, account=0, confirmed=True, unconfirmed=True):
|
||||
_txns = self.raw_request('get_transfers',
|
||||
{'account_index': account, 'in': False, 'out': confirmed, 'pool': unconfirmed})
|
||||
txns = _txns.get('out', [])
|
||||
|
|
|
@ -2,14 +2,14 @@ class Daemon(object):
|
|||
def __init__(self, backend):
|
||||
self._backend = backend
|
||||
|
||||
def get_info(self):
|
||||
return self._backend.get_info()
|
||||
def info(self):
|
||||
return self._backend.info()
|
||||
|
||||
def get_height(self):
|
||||
return self._backend.get_info()['height']
|
||||
def height(self):
|
||||
return self._backend.info()['height']
|
||||
|
||||
def send_transaction(self, tx):
|
||||
return self._backend.send_transaction(tx.blob)
|
||||
|
||||
def get_mempool(self):
|
||||
return self._backend.get_mempool()
|
||||
def mempool(self):
|
||||
return self._backend.mempool()
|
||||
|
|
|
@ -13,7 +13,7 @@ class Wallet(object):
|
|||
def refresh(self):
|
||||
self.accounts = self.accounts or []
|
||||
idx = 0
|
||||
for _acc in self._backend.get_accounts():
|
||||
for _acc in self._backend.accounts():
|
||||
try:
|
||||
if self.accounts[idx]:
|
||||
continue
|
||||
|
@ -22,29 +22,29 @@ class Wallet(object):
|
|||
self.accounts.append(_acc)
|
||||
idx += 1
|
||||
|
||||
def get_height(self):
|
||||
def height(self):
|
||||
"""
|
||||
Returns the height of the wallet.
|
||||
"""
|
||||
return self._backend.get_height()
|
||||
return self._backend.height()
|
||||
|
||||
def get_spend_key(self):
|
||||
def spend_key(self):
|
||||
"""
|
||||
Returns private spend key.
|
||||
"""
|
||||
return self._backend.get_spend_key()
|
||||
return self._backend.spend_key()
|
||||
|
||||
def get_view_key(self):
|
||||
def view_key(self):
|
||||
"""
|
||||
Returns private view key.
|
||||
"""
|
||||
return self._backend.get_view_key()
|
||||
return self._backend.view_key()
|
||||
|
||||
def get_seed(self):
|
||||
def seed(self):
|
||||
"""
|
||||
Returns word seed.
|
||||
"""
|
||||
return self._backend.get_seed()
|
||||
return self._backend.seed()
|
||||
|
||||
def new_account(self, label=None):
|
||||
acc, addr = self._backend.new_account(label=label)
|
||||
|
@ -59,32 +59,32 @@ class Wallet(object):
|
|||
txn = self._backend.get_transaction(txn)
|
||||
if txn.height is None:
|
||||
return 0
|
||||
return max(0, self.get_height() - txn.height)
|
||||
return max(0, self.height() - txn.height)
|
||||
|
||||
# Following methods operate on default account (index=0)
|
||||
def get_balances(self):
|
||||
return self.accounts[0].get_balances()
|
||||
def balances(self):
|
||||
return self.accounts[0].balances()
|
||||
|
||||
def get_balance(self, unlocked=False):
|
||||
return self.accounts[0].get_balance(unlocked=unlocked)
|
||||
def balance(self, unlocked=False):
|
||||
return self.accounts[0].balance(unlocked=unlocked)
|
||||
|
||||
def get_address(self):
|
||||
return self.accounts[0].get_addresses()[0]
|
||||
def address(self):
|
||||
return self.accounts[0].addresses()[0]
|
||||
|
||||
def get_addresses(self):
|
||||
return self.accounts[0].get_addresses()
|
||||
def addresses(self):
|
||||
return self.accounts[0].addresses()
|
||||
|
||||
def new_address(self, label=None):
|
||||
return self.accounts[0].new_address(label=label)
|
||||
|
||||
def get_payments(self, payment_id=None):
|
||||
return self.accounts[0].get_payments(payment_id=payment_id)
|
||||
def payments(self, payment_id=None):
|
||||
return self.accounts[0].payments(payment_id=payment_id)
|
||||
|
||||
def get_transactions_in(self, confirmed=True, unconfirmed=False):
|
||||
return self.accounts[0].get_transactions_in(confirmed=confirmed, unconfirmed=unconfirmed)
|
||||
def transactions_in(self, confirmed=True, unconfirmed=False):
|
||||
return self.accounts[0].transactions_in(confirmed=confirmed, unconfirmed=unconfirmed)
|
||||
|
||||
def get_transactions_out(self, confirmed=True, unconfirmed=True):
|
||||
return self.accounts[0].get_transactions_out(confirmed=confirmed, unconfirmed=unconfirmed)
|
||||
def transactions_out(self, confirmed=True, unconfirmed=True):
|
||||
return self.accounts[0].transactions_out(confirmed=confirmed, unconfirmed=unconfirmed)
|
||||
|
||||
def transfer(self, address, amount,
|
||||
priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0,
|
||||
|
|
|
@ -6,15 +6,15 @@ class Tests(object):
|
|||
def test_from_and_to_string(self):
|
||||
a = Address(self.addr)
|
||||
self.assertEqual(str(a), self.addr)
|
||||
self.assertEqual(a.get_spend_key(), self.psk)
|
||||
self.assertEqual(a.get_view_key(), self.pvk)
|
||||
self.assertEqual(a.spend_key(), self.psk)
|
||||
self.assertEqual(a.view_key(), self.pvk)
|
||||
|
||||
ia = IntegratedAddress(self.iaddr)
|
||||
self.assertEqual(ia.get_payment_id(), self.pid)
|
||||
self.assertEqual(ia.payment_id(), self.pid)
|
||||
self.assertEqual(str(ia), self.iaddr)
|
||||
self.assertEqual(ia.get_spend_key(), self.psk)
|
||||
self.assertEqual(ia.get_view_key(), self.pvk)
|
||||
self.assertEqual(ia.get_base_address(), a)
|
||||
self.assertEqual(ia.spend_key(), self.psk)
|
||||
self.assertEqual(ia.view_key(), self.pvk)
|
||||
self.assertEqual(ia.base_address(), a)
|
||||
|
||||
sa = SubAddress(self.subaddr)
|
||||
self.assertEqual(str(sa), self.subaddr)
|
||||
|
@ -23,7 +23,7 @@ class Tests(object):
|
|||
a = Address(self.addr)
|
||||
ia = a.with_payment_id(self.pid)
|
||||
self.assertIsInstance(ia, IntegratedAddress)
|
||||
self.assertEqual(ia.get_payment_id(), self.pid)
|
||||
self.assertEqual(ia.payment_id(), self.pid)
|
||||
self.assertEqual(str(ia), self.iaddr)
|
||||
|
||||
def test_recognition_and_comparisons(self):
|
||||
|
@ -44,10 +44,10 @@ class Tests(object):
|
|||
self.assertEqual(self.iaddr, ia)
|
||||
self.assertEqual(ia.is_testnet(), self.testnet)
|
||||
self.assertEqual(ia2.is_testnet(), self.testnet)
|
||||
self.assertEqual(ia2.get_base_address(), a)
|
||||
self.assertEqual(ia2.base_address(), a)
|
||||
|
||||
self.assertEqual(ia.get_view_key(), a.get_view_key())
|
||||
self.assertEqual(ia.get_spend_key(), a.get_spend_key())
|
||||
self.assertEqual(ia.view_key(), a.view_key())
|
||||
self.assertEqual(ia.spend_key(), a.spend_key())
|
||||
|
||||
sa = SubAddress(self.subaddr)
|
||||
sa2 = address(self.subaddr)
|
||||
|
|
|
@ -12,7 +12,7 @@ from monero.transaction import IncomingPayment, OutgoingPayment, Transaction
|
|||
from monero.backends.jsonrpc import JSONRPCWallet
|
||||
|
||||
class SubaddrWalletTestCase(unittest.TestCase):
|
||||
get_accounts_result = {'id': 0,
|
||||
accounts_result = {'id': 0,
|
||||
'jsonrpc': '2.0',
|
||||
'result': {'subaddress_accounts': [{'account_index': 0,
|
||||
'balance': 224916129245183,
|
||||
|
@ -33,9 +33,9 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
'total_unlocked_balance': 236153709446071}}
|
||||
|
||||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_balance(self, mock_post):
|
||||
def test_balance(self, mock_post):
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
mock_post.return_value.json.return_value = self.accounts_result
|
||||
self.wallet = Wallet(JSONRPCWallet())
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
'jsonrpc': '2.0',
|
||||
|
@ -59,9 +59,9 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
'num_unspent_outputs': 5,
|
||||
'unlocked_balance': 35000000000000}],
|
||||
'unlocked_balance': 224916129245183}}
|
||||
locked = self.wallet.get_balance()
|
||||
unlocked = self.wallet.get_balance(unlocked=True)
|
||||
balances = self.wallet.get_balances()
|
||||
locked = self.wallet.balance()
|
||||
unlocked = self.wallet.balance(unlocked=True)
|
||||
balances = self.wallet.balances()
|
||||
self.assertEqual(balances[0], locked)
|
||||
self.assertEqual(balances[1], unlocked)
|
||||
self.assertIsInstance(locked, Decimal)
|
||||
|
@ -71,9 +71,9 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
self.assertEqual(locked, Decimal('224.916129245183'))
|
||||
|
||||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_address(self, mock_post):
|
||||
def test_address(self, mock_post):
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
mock_post.return_value.json.return_value = self.accounts_result
|
||||
self.wallet = Wallet(JSONRPCWallet())
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
'jsonrpc': '2.0',
|
||||
|
@ -110,19 +110,19 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
'address_index': 7,
|
||||
'label': '(Untitled address)',
|
||||
'used': True}]}}
|
||||
waddr = self.wallet.get_address()
|
||||
a0addr = self.wallet.accounts[0].get_address()
|
||||
waddr = self.wallet.address()
|
||||
a0addr = self.wallet.accounts[0].address()
|
||||
self.assertEqual(waddr, a0addr)
|
||||
self.assertEqual(
|
||||
waddr,
|
||||
'9vgV48wWAPTWik5QSUSoGYicdvvsbSNHrT9Arsx1XBTz6VrWPSgfmnUKSPZDMyX4Ms8R9TkhB4uFqK9s5LUBbV6YQN2Q9ag')
|
||||
self.assertEqual(a0addr.label, 'Primary account')
|
||||
self.assertEqual(len(self.wallet.accounts[0].get_addresses()), 8)
|
||||
self.assertEqual(len(self.wallet.accounts[0].addresses()), 8)
|
||||
|
||||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_transactions_in(self, mock_post):
|
||||
def test_transactions_in(self, mock_post):
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
mock_post.return_value.json.return_value = self.accounts_result
|
||||
self.wallet = Wallet(JSONRPCWallet())
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value ={'id': 0,
|
||||
|
@ -160,7 +160,7 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
'txid': 'd23a7d086e70df7aa0ca002361c4b35e35a272345b0a513ece4f21b773941f5e',
|
||||
'type': 'in',
|
||||
'unlock_time': 0}]}}
|
||||
pay_in = self.wallet.get_transactions_in()
|
||||
pay_in = self.wallet.transactions_in()
|
||||
self.assertEqual(len(list(pay_in)), 3)
|
||||
for pmt in pay_in:
|
||||
self.assertIsInstance(pmt, IncomingPayment)
|
||||
|
@ -172,9 +172,9 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
self.assertIsInstance(pmt.transaction.height, int)
|
||||
|
||||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_transactions_out(self, mock_post):
|
||||
def test_transactions_out(self, mock_post):
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
mock_post.return_value.json.return_value = self.accounts_result
|
||||
self.wallet = Wallet(JSONRPCWallet())
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
|
@ -257,7 +257,7 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
'txid': '7e3db6c59c02d870f18b37a37cfc5857eeb5412df4ea00bb1971f3095f72b0d8',
|
||||
'type': 'out',
|
||||
'unlock_time': 0}]}}
|
||||
pay_out = self.wallet.get_transactions_out()
|
||||
pay_out = self.wallet.transactions_out()
|
||||
self.assertEqual(len(list(pay_out)), 6)
|
||||
for pmt in pay_out:
|
||||
self.assertIsInstance(pmt, OutgoingPayment)
|
||||
|
@ -270,9 +270,9 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
self.assertIsInstance(pmt.transaction.height, int)
|
||||
|
||||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_payments(self, mock_post):
|
||||
def test_payments(self, mock_post):
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
mock_post.return_value.json.return_value = self.accounts_result
|
||||
self.wallet = Wallet(JSONRPCWallet())
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
|
@ -284,7 +284,7 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
'subaddr_index': {'major': 1, 'minor': 1},
|
||||
'tx_hash': 'e84343c2ebba4d4d94764e0cd275adee07cf7b4718565513be453d3724f6174b',
|
||||
'unlock_time': 0}]}}
|
||||
payments = self.wallet.get_payments(payment_id=0xfeedbadbeef12345)
|
||||
payments = self.wallet.payments(payment_id=0xfeedbadbeef12345)
|
||||
self.assertEqual(len(list(payments)), 1)
|
||||
for pmt in payments:
|
||||
self.assertIsInstance(pmt, IncomingPayment)
|
||||
|
@ -296,7 +296,7 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_send_transfer(self, mock_post):
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
mock_post.return_value.json.return_value = self.accounts_result
|
||||
self.wallet = Wallet(JSONRPCWallet())
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
|
|
|
@ -28,7 +28,7 @@ def get_daemon():
|
|||
return Daemon(JSONRPCDaemon(**args.daemon_rpc_url))
|
||||
|
||||
d = get_daemon()
|
||||
info = d.get_info()
|
||||
info = d.info()
|
||||
print("Net: {net:>18s}\n"
|
||||
"Height: {height:10d}\n"
|
||||
"Difficulty: {difficulty:10d}".format(
|
||||
|
|
|
@ -51,13 +51,13 @@ def a2str(a):
|
|||
label=a.label or "")
|
||||
|
||||
w = get_wallet()
|
||||
masteraddr = w.get_address()
|
||||
masteraddr = w.address()
|
||||
print(
|
||||
"Master address: {addr}\n" \
|
||||
"Balance: {total:16.12f} ({unlocked:16.12f} unlocked)".format(
|
||||
addr=a2str(masteraddr),
|
||||
total=w.get_balance(),
|
||||
unlocked=w.get_balance(unlocked=True)))
|
||||
total=w.balance(),
|
||||
unlocked=w.balance(unlocked=True)))
|
||||
print(
|
||||
"Keys:\n" \
|
||||
" private spend: {ssk}\n" \
|
||||
|
@ -65,11 +65,11 @@ print(
|
|||
" public spend: {psk}\n" \
|
||||
" public view: {pvk}\n\n" \
|
||||
"Seed:\n{seed}".format(
|
||||
ssk=w.get_spend_key(),
|
||||
svk=w.get_view_key(),
|
||||
psk=masteraddr.get_spend_key(),
|
||||
pvk=masteraddr.get_view_key(),
|
||||
seed=w.get_seed()
|
||||
ssk=w.spend_key(),
|
||||
svk=w.view_key(),
|
||||
psk=masteraddr.spend_key(),
|
||||
pvk=masteraddr.view_key(),
|
||||
seed=w.seed()
|
||||
))
|
||||
|
||||
if len(w.accounts) > 1:
|
||||
|
@ -77,31 +77,31 @@ if len(w.accounts) > 1:
|
|||
for acc in w.accounts:
|
||||
print("\nAccount {idx:02d}:".format(idx=acc.index))
|
||||
print("Balance: {total:16.12f} ({unlocked:16.12f} unlocked)".format(
|
||||
total=acc.get_balance(),
|
||||
unlocked=acc.get_balance(unlocked=True)))
|
||||
addresses = acc.get_addresses()
|
||||
total=acc.balance(),
|
||||
unlocked=acc.balance(unlocked=True)))
|
||||
addresses = acc.addresses()
|
||||
print("{num:2d} address(es):".format(num=len(addresses)))
|
||||
print("\n".join(map(a2str, addresses)))
|
||||
ins = acc.get_transactions_in(unconfirmed=True)
|
||||
ins = acc.transactions_in(unconfirmed=True)
|
||||
if ins:
|
||||
print("\nIncoming transactions:")
|
||||
print(_TXHDR.format(dir='received by'))
|
||||
for tx in ins:
|
||||
print(pmt2str(tx))
|
||||
outs = acc.get_transactions_out(unconfirmed=True)
|
||||
outs = acc.transactions_out(unconfirmed=True)
|
||||
if outs:
|
||||
print("\nOutgoing transactions:")
|
||||
print(_TXHDR.format(dir='sent from'))
|
||||
for tx in outs:
|
||||
print(pmt2str(tx))
|
||||
else:
|
||||
ins = w.get_transactions_in(unconfirmed=True)
|
||||
ins = w.transactions_in(unconfirmed=True)
|
||||
if ins:
|
||||
print("\nIncoming transactions:")
|
||||
print(_TXHDR.format(dir='received by'))
|
||||
for tx in ins:
|
||||
print(pmt2str(tx))
|
||||
outs = w.get_transactions_out(unconfirmed=True)
|
||||
outs = w.transactions_out(unconfirmed=True)
|
||||
if outs:
|
||||
print("\nOutgoing transactions:")
|
||||
print(_TXHDR.format(dir='sent from'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue