tx.new: add is_swap attribute

This commit is contained in:
The MMGen Project 2025-02-15 09:54:19 +00:00
commit 0f7e51e499
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
6 changed files with 12 additions and 5 deletions

View file

@ -135,7 +135,7 @@ class New(Base, TxNew):
async def create_serialized(self, locktime=None, bump=None):
if not bump:
if not (bump or self.is_swap):
self.inputs.sort_bip69()
# Set all sequence numbers to the same value, in conformity with the behavior of most modern wallets:
do_rbf = self.proto.cap('rbf') and not self.cfg.no_rbf
@ -143,7 +143,8 @@ class New(Base, TxNew):
for i in self.inputs:
i.sequence = seqnum_val
self.outputs.sort_bip69()
if not self.is_swap:
self.outputs.sort_bip69()
inputs_list = [{
'txid': e.txid,

View file

@ -79,6 +79,7 @@ class Base(MMGenObject):
locktime = None
chain = None
signed = False
is_swap = False
file_format = 'json'
non_mmgen_inputs_msg = f"""
This transaction includes inputs with non-{gc.proj_name} addresses. When

View file

@ -71,6 +71,7 @@ class MMGenTxFile(MMGenObject):
'comment': MMGenTxComment,
'coin_txid': CoinTxID,
'sent_timestamp': None,
'is_swap': False,
}
def __init__(self, tx):

View file

@ -29,6 +29,9 @@ class TxInfo:
tx = self.tx
if tx.is_swap:
sort = 'raw'
if tx.proto.base_proto == 'Ethereum':
blockcount = None
else:

View file

@ -83,7 +83,7 @@ class New(Base):
_funds_available = namedtuple('funds_available', ['is_positive', 'amt'])
def __init__(self, *args, target=None, **kwargs):
self.target = target
self.is_swap = target == 'swaptx'
super().__init__(*args, **kwargs)
def warn_insufficient_funds(self, amt, coin):
@ -266,7 +266,7 @@ class New(Base):
edesc = 'argument',
)
cmd_args = tuple(a for a in cmd_args if a not in addrfile_args)
if self.target == 'tx':
if not self.is_swap:
cmd_args = remove_dups(cmd_args, desc='command line', edesc='argument')
return cmd_args, addrfile_args
@ -415,7 +415,7 @@ class New(Base):
if not do_info:
cmd_args, addrfile_args = self.get_addrfiles_from_cmdline(cmd_args)
if self.target == 'swaptx':
if self.is_swap:
# updates self.proto!
self.proto, cmd_args = await self.process_swap_cmdline_args(cmd_args, addrfile_args)
from ..rpc import rpc_init

View file

@ -16,6 +16,7 @@ from .new import New
class NewSwap(New):
desc = 'swap transaction'
is_swap = True
async def process_swap_cmdline_args(self, cmd_args):
raise NotImplementedError(f'Swap not implemented for protocol {self.proto.__name__}')