mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Add methods for exporting/importing outputs and key images
This commit is contained in:
parent
a31afd84e5
commit
915590780f
4 changed files with 102 additions and 1 deletions
|
@ -1,4 +1,3 @@
|
||||||
import binascii
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import operator
|
import operator
|
||||||
import json
|
import json
|
||||||
|
@ -263,6 +262,23 @@ class JSONRPCWallet(object):
|
||||||
'blob': data.get('blob', None),
|
'blob': data.get('blob', None),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def export_outputs(self):
|
||||||
|
return self.raw_request('export_outputs')['outputs_data_hex']
|
||||||
|
|
||||||
|
def import_outputs(self, outputs_hex):
|
||||||
|
return self.raw_request(
|
||||||
|
'import_outputs',
|
||||||
|
{'outputs_data_hex': outputs_hex})['num_imported']
|
||||||
|
|
||||||
|
def export_key_images(self):
|
||||||
|
return self.raw_request('export_key_images')['signed_key_images']
|
||||||
|
|
||||||
|
def import_key_images(self, key_images):
|
||||||
|
_data = self.raw_request(
|
||||||
|
'import_key_images',
|
||||||
|
{'signed_key_images': key_images})
|
||||||
|
return (_data['height'], from_atomic(_data['spent']), from_atomic(_data['unspent']))
|
||||||
|
|
||||||
def transfer(self, destinations, priority, ringsize,
|
def transfer(self, destinations, priority, ringsize,
|
||||||
payment_id=None, unlock_time=0, account=0,
|
payment_id=None, unlock_time=0, account=0,
|
||||||
relay=True):
|
relay=True):
|
||||||
|
@ -341,6 +357,7 @@ _err2exc = {
|
||||||
-2: exceptions.WrongAddress,
|
-2: exceptions.WrongAddress,
|
||||||
-5: exceptions.WrongPaymentId,
|
-5: exceptions.WrongPaymentId,
|
||||||
-8: exceptions.TransactionNotFound,
|
-8: exceptions.TransactionNotFound,
|
||||||
|
-9: exceptions.SignatureCheckFailed,
|
||||||
-16: exceptions.TransactionNotPossible,
|
-16: exceptions.TransactionNotPossible,
|
||||||
-17: exceptions.NotEnoughMoney,
|
-17: exceptions.NotEnoughMoney,
|
||||||
-20: exceptions.AmountIsZero,
|
-20: exceptions.AmountIsZero,
|
||||||
|
|
|
@ -35,3 +35,6 @@ class TransactionBroadcastError(BackendException):
|
||||||
|
|
||||||
class TransactionNotFound(AccountException):
|
class TransactionNotFound(AccountException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class SignatureCheckFailed(MoneroException):
|
||||||
|
pass
|
||||||
|
|
|
@ -104,6 +104,40 @@ class Wallet(object):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def export_outputs(self):
|
||||||
|
"""
|
||||||
|
Exports outputs in hexadecimal format.
|
||||||
|
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
return self._backend.export_outputs()
|
||||||
|
|
||||||
|
def import_outputs(self, outputs_hex):
|
||||||
|
"""
|
||||||
|
Imports outputs in hexadecimal format. Returns number of imported outputs.
|
||||||
|
|
||||||
|
:rtype: int
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self._backend.import_outputs(outputs_hex)
|
||||||
|
|
||||||
|
def export_key_images(self):
|
||||||
|
"""
|
||||||
|
Exports signed key images as a list of dicts.
|
||||||
|
|
||||||
|
:rtype: [dict, dict, ...]
|
||||||
|
"""
|
||||||
|
return self._backend.export_key_images()
|
||||||
|
|
||||||
|
def import_key_images(self, key_images_hex):
|
||||||
|
"""
|
||||||
|
Imports key images from a list of dicts. Returns tuple of (height, spent, unspent).
|
||||||
|
|
||||||
|
:rtype: (int, Decimal, Decimal)
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self._backend.import_key_images(key_images_hex)
|
||||||
|
|
||||||
# Following methods operate on default account (index=0)
|
# Following methods operate on default account (index=0)
|
||||||
def balances(self):
|
def balances(self):
|
||||||
"""
|
"""
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue