Skip to content

Commit

Permalink
Spark tx added
Browse files Browse the repository at this point in the history
  • Loading branch information
levonpetrosyan93 committed Sep 24, 2023
1 parent a3f6438 commit e24a7cf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion electrum_dash/address_synchronizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def add_transaction(self, tx: Transaction, *, allow_unrelated=False) -> bool:
# being is_mine, as we roll the gap_limit forward

# prevent lelantus transasctions stored as cb.
is_coinbase = tx.inputs()[0].is_coinbase_input() and not tx.inputs()[0].is_lelantus_input()
is_coinbase = tx.inputs()[0].is_coinbase_input() and not (tx.inputs()[0].is_lelantus_input() or tx.inputs()[0].is_spark_input())
tx_height = self.get_tx_height(tx_hash).height
if not allow_unrelated:
# note that during sync, if the transactions are not properly sorted,
Expand Down
25 changes: 24 additions & 1 deletion electrum_dash/dash_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,26 @@ def read_vds(cls, vds):
vds.read_cursor = len(vds.input)
return tx

class FiroSparkSpend(ProTxBase):
__slots__ = ('sparkData').split()

def __str__(self):
res = ('sparkData: %s\n'
% (self.sparkData))
return res

def serialize(self):
res = (
self.sparkData
)
return res

@classmethod
def read_vds(cls, vds):
tx = FiroSparkSpend(vds.input[vds.read_cursor:])
vds.read_cursor = len(vds.input)
return tx

class DashSubTxRegister(ProTxBase):
'''Class representing DIP5 SubTxRegister'''

Expand Down Expand Up @@ -856,6 +876,7 @@ def read_vds(cls, vds):
SPEC_PRO_UP_REV_TX = 4
SPEC_CB_TX = 5
LELANTUS_JSPLIT = 8
SPARK_SPEND = 9


SPEC_TX_HANDLERS = {
Expand All @@ -865,6 +886,7 @@ def read_vds(cls, vds):
SPEC_PRO_UP_REV_TX: DashProUpRevTx,
SPEC_CB_TX: DashCbTx,
LELANTUS_JSPLIT: FiroLelantusJsplitTx,
SPARK_SPEND: FiroSparkSpend,
}


Expand All @@ -888,7 +910,8 @@ class PSTxTypes(IntEnum):
SPEC_PRO_UP_REG_TX: 'ProUpRegTx',
SPEC_PRO_UP_REV_TX: 'ProUpRevTx',
SPEC_CB_TX: 'CbTx',
LELANTUS_JSPLIT: 'LelantusJsplit'
LELANTUS_JSPLIT: 'LelantusJsplit',
SPARK_SPEND: 'SparkSpend'
}


Expand Down
3 changes: 3 additions & 0 deletions electrum_dash/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ def is_lelantus_input(self) -> bool:
return self.script_sig and \
(self.script_sig[0] == 0xC7 or self.script_sig[0] == 0xC9)

def is_spark_input(self) -> bool:
return self.script_sig and self.script_sig[0] == 0xd3

def is_coinbase_input(self) -> bool:
"""Whether this is the input of a coinbase tx."""
return self.prevout.is_coinbase()
Expand Down

0 comments on commit e24a7cf

Please sign in to comment.