Differentiate between None and 0 as payment id
This commit is contained in:
parent
5b7dd90b9d
commit
02a599e9ad
|
@ -33,7 +33,7 @@ class Account(object):
|
||||||
def get_transactions_out(self):
|
def get_transactions_out(self):
|
||||||
return self._backend.get_transactions_out(account=self.index)
|
return self._backend.get_transactions_out(account=self.index)
|
||||||
|
|
||||||
def transfer(self, address, amount, priority=prio.NORMAL, mixin=5, payment_id=0, unlock_time=0):
|
def transfer(self, address, amount, priority=prio.NORMAL, mixin=5, payment_id=None, unlock_time=0):
|
||||||
return self._backend.transfer(
|
return self._backend.transfer(
|
||||||
[(address, amount)],
|
[(address, amount)],
|
||||||
priority,
|
priority,
|
||||||
|
@ -42,7 +42,7 @@ class Account(object):
|
||||||
unlock_time,
|
unlock_time,
|
||||||
account=self.index)
|
account=self.index)
|
||||||
|
|
||||||
def transfer_multiple(self, destinations, priority=prio.NORMAL, mixin=5, payment_id=0, unlock_time=0):
|
def transfer_multiple(self, destinations, priority=prio.NORMAL, mixin=5, payment_id=None, unlock_time=0):
|
||||||
"""
|
"""
|
||||||
destinations = [(address, amount), ...]
|
destinations = [(address, amount), ...]
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -89,13 +89,14 @@ class JSONRPCWallet(object):
|
||||||
sorted(_transfers.get('out', []), key=operator.itemgetter('timestamp'))]
|
sorted(_transfers.get('out', []), key=operator.itemgetter('timestamp'))]
|
||||||
|
|
||||||
def _tx2dict(self, tx):
|
def _tx2dict(self, tx):
|
||||||
|
pid = tx.get('payment_id', None)
|
||||||
return {
|
return {
|
||||||
'hash': tx.get('txid', tx.get('tx_hash')),
|
'hash': tx.get('txid', tx.get('tx_hash')),
|
||||||
'timestamp': datetime.fromtimestamp(tx['timestamp']) if 'timestamp' in tx else None,
|
'timestamp': datetime.fromtimestamp(tx['timestamp']) if 'timestamp' in tx else None,
|
||||||
'amount': from_atomic(tx['amount']),
|
'amount': from_atomic(tx['amount']),
|
||||||
'fee': from_atomic(tx['fee']) if 'fee' in tx else None,
|
'fee': from_atomic(tx['fee']) if 'fee' in tx else None,
|
||||||
'height': tx.get('height', tx.get('block_height')),
|
'height': tx.get('height', tx.get('block_height')),
|
||||||
'payment_id': PaymentID(tx.get('payment_id', 0)),
|
'payment_id': None if pid is None else PaymentID(pid),
|
||||||
'note': tx.get('note'),
|
'note': tx.get('note'),
|
||||||
# NOTE: address will be resolved only after PR#3010 has been merged to Monero
|
# NOTE: address will be resolved only after PR#3010 has been merged to Monero
|
||||||
'local_address': address(tx['address']) if 'address' in tx else None,
|
'local_address': address(tx['address']) if 'address' in tx else None,
|
||||||
|
@ -103,7 +104,7 @@ class JSONRPCWallet(object):
|
||||||
'blob': tx.get('blob', None),
|
'blob': tx.get('blob', None),
|
||||||
}
|
}
|
||||||
|
|
||||||
def transfer(self, destinations, priority, mixin, payment_id, unlock_time, account=0):
|
def transfer(self, destinations, priority, mixin, payment_id=None, unlock_time=0, account=0):
|
||||||
data = {
|
data = {
|
||||||
'account_index': account,
|
'account_index': account,
|
||||||
'destinations': list(map(
|
'destinations': list(map(
|
||||||
|
@ -112,11 +113,12 @@ class JSONRPCWallet(object):
|
||||||
'mixin': mixin,
|
'mixin': mixin,
|
||||||
'priority': priority,
|
'priority': priority,
|
||||||
'unlock_time': 0,
|
'unlock_time': 0,
|
||||||
'payment_id': str(PaymentID(payment_id)),
|
|
||||||
'get_tx_keys': True,
|
'get_tx_keys': True,
|
||||||
'get_tx_hex': True,
|
'get_tx_hex': True,
|
||||||
'new_algorithm': True,
|
'new_algorithm': True,
|
||||||
}
|
}
|
||||||
|
if payment_id is not None:
|
||||||
|
data['payment_id'] = str(PaymentID(payment_id))
|
||||||
_transfers = self.raw_request('transfer_split', data)
|
_transfers = self.raw_request('transfer_split', data)
|
||||||
_pertx = [dict(_tx) for _tx in map(
|
_pertx = [dict(_tx) for _tx in map(
|
||||||
lambda vs: zip(('txid', 'amount', 'fee', 'key', 'blob', 'payment_id'), vs),
|
lambda vs: zip(('txid', 'amount', 'fee', 'key', 'blob', 'payment_id'), vs),
|
||||||
|
|
|
@ -40,15 +40,16 @@ class Wallet(object):
|
||||||
def get_transactions_out(self):
|
def get_transactions_out(self):
|
||||||
return self.accounts[0].get_transactions_out()
|
return self.accounts[0].get_transactions_out()
|
||||||
|
|
||||||
def transfer(self, address, amount, priority=prio.NORMAL, mixin=5, unlock_time=0):
|
def transfer(self, address, amount, priority=prio.NORMAL, mixin=5, payment_id=None, unlock_time=0):
|
||||||
return self.accounts[0].transfer(
|
return self.accounts[0].transfer(
|
||||||
address,
|
address,
|
||||||
amount,
|
amount,
|
||||||
priority=priority,
|
priority=priority,
|
||||||
mixin=mixin,
|
mixin=mixin,
|
||||||
|
payment_id=None,
|
||||||
unlock_time=unlock_time)
|
unlock_time=unlock_time)
|
||||||
|
|
||||||
def transfer_multiple(self, destinations, priority=prio.NORMAL, mixin=5, unlock_time=0):
|
def transfer_multiple(self, destinations, priority=prio.NORMAL, mixin=5, payment_id=None, unlock_time=0):
|
||||||
"""
|
"""
|
||||||
destinations = [(address, amount), ...]
|
destinations = [(address, amount), ...]
|
||||||
"""
|
"""
|
||||||
|
@ -56,4 +57,5 @@ class Wallet(object):
|
||||||
destinations,
|
destinations,
|
||||||
priority=priority,
|
priority=priority,
|
||||||
mixin=mixin,
|
mixin=mixin,
|
||||||
|
payment_id=None,
|
||||||
unlock_time=unlock_time)
|
unlock_time=unlock_time)
|
||||||
|
|
Loading…
Reference in New Issue