Allow creating txs without relaying to the network

This commit is contained in:
Michał Sałaban 2018-01-14 03:40:46 +01:00
parent 1be5d0b063
commit 34fa48fcf8
4 changed files with 38 additions and 11 deletions

View file

@ -36,16 +36,21 @@ class Account(object):
def get_transactions_out(self):
return self._backend.get_transactions_out(account=self.index)
def transfer(self, address, amount, priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0):
def transfer(self, address, amount,
priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0,
relay=True):
return self._backend.transfer(
[(address, amount)],
priority,
ringsize,
payment_id,
unlock_time,
account=self.index)
account=self.index,
relay=relay)
def transfer_multiple(self, destinations, priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0):
def transfer_multiple(self, destinations,
priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0,
relay=True):
"""
destinations = [(address, amount), ...]
"""
@ -55,4 +60,5 @@ class Account(object):
ringsize,
payment_id,
unlock_time,
account=self.index)
account=self.index,
relay=relay)

View file

@ -1,3 +1,4 @@
import binascii
from datetime import datetime
import operator
import json
@ -115,7 +116,9 @@ class JSONRPCWallet(object):
'blob': tx.get('blob', None),
}
def transfer(self, destinations, priority, ringsize, payment_id=None, unlock_time=0, account=0):
def transfer(self, destinations, priority, ringsize,
payment_id=None, unlock_time=0, account=0,
relay=True):
data = {
'account_index': account,
'destinations': list(map(
@ -127,6 +130,7 @@ class JSONRPCWallet(object):
'get_tx_keys': True,
'get_tx_hex': True,
'new_algorithm': True,
'do_not_relay': not relay,
}
if payment_id is not None:
data['payment_id'] = str(PaymentID(payment_id))

View file

@ -52,16 +52,21 @@ class Wallet(object):
def get_transactions_out(self):
return self.accounts[0].get_transactions_out()
def transfer(self, address, amount, priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0):
def transfer(self, address, amount,
priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0,
relay=True):
return self.accounts[0].transfer(
address,
amount,
priority=priority,
ringsize=ringsize,
payment_id=None,
unlock_time=unlock_time)
unlock_time=unlock_time,
relay=relay)
def transfer_multiple(self, destinations, priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0):
def transfer_multiple(self, destinations,
priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0,
relay=True):
"""
destinations = [(address, amount), ...]
"""
@ -70,4 +75,5 @@ class Wallet(object):
priority=priority,
ringsize=ringsize,
payment_id=None,
unlock_time=unlock_time)
unlock_time=unlock_time,
relay=relay)