ui: Expose Particl blinded and anon balances.

This commit is contained in:
tecnovert
2021-02-07 00:35:12 +02:00
parent dd37156e65
commit b1ea76dcb6
6 changed files with 192 additions and 12 deletions
+39
View File
@@ -5,6 +5,8 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
from enum import IntEnum
from .contrib.test_framework.messages import (
CTxOutPart,
)
@@ -17,11 +19,21 @@ from .interface_btc import BTCInterface
from .chainparams import Coins
class BalanceTypes(IntEnum):
PLAIN = 1
BLIND = 2
ANON = 3
class PARTInterface(BTCInterface):
@staticmethod
def coin_type():
return Coins.PART
@staticmethod
def balance_type():
return BalanceTypes.PLAIN
@staticmethod
def witnessScaleFactor():
return 2
@@ -38,6 +50,10 @@ class PARTInterface(BTCInterface):
def txoType():
return CTxOutPart
def setDefaults(self):
super().setDefaults()
self._anon_tx_ring_size = 8 # TODO: Make option
def knownWalletSeed(self):
# TODO: Double check
return True
@@ -45,6 +61,9 @@ class PARTInterface(BTCInterface):
def getNewAddress(self, use_segwit):
return self.rpc_callback('getnewaddress', ['swap_receive'])
def getNewStealthAddress(self):
return self.rpc_callback('getnewstealthaddress', ['swap_stealth'])
def haveSpentIndex(self):
version = self.getDaemonVersion()
index_info = self.rpc_callback('getinsightinfo' if int(str(version)[:2]) > 19 else 'getindexinfo')
@@ -57,5 +76,25 @@ class PARTInterface(BTCInterface):
params = [addr_to, value, '', '', subfee, '', True, self._conf_target]
return self.rpc_callback('sendtoaddress', params)
def sendTypeTo(self, type_from, type_to, value, addr_to, subfee):
params = [type_from, type_to,
[{'address': addr_to, 'amount': value, 'subfee': subfee}, ],
'', '', self._anon_tx_ring_size, 1, False,
{'conf_target': self._conf_target}]
return self.rpc_callback('sendtypeto', params)
def getScriptForPubkeyHash(self, pkh):
return CScript([OP_DUP, OP_HASH160, pkh, OP_EQUALVERIFY, OP_CHECKSIG])
class PARTInterfaceBlind(PARTInterface):
@staticmethod
def balance_type():
return BalanceTypes.BLIND
class PARTInterfaceAnon(PARTInterface):
@staticmethod
def balance_type():
return BalanceTypes.ANON