From dab9d6bda9f140c06917fc6b20c80e306a6cd528 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 29 Aug 2026 15:04:29 +0000 Subject: [PATCH] tx.unsigned: new `sign()` method --- mmgen/proto/btc/tx/unsigned.py | 8 +------- mmgen/proto/vm/tx/unsigned.py | 8 +------- mmgen/tx/unsigned.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mmgen/proto/btc/tx/unsigned.py b/mmgen/proto/btc/tx/unsigned.py index 75157275..0e8f7bf2 100755 --- a/mmgen/proto/btc/tx/unsigned.py +++ b/mmgen/proto/btc/tx/unsigned.py @@ -21,13 +21,7 @@ class Unsigned(Completed, TxBase.Unsigned): desc = 'unsigned transaction' # Return signed object or False. Don’t exit or raise exception: - async def sign(self, keys, tx_num_str=''): - - from ....exception import TransactionChainMismatch - try: - self.check_correct_chain() - except TransactionChainMismatch: - return False + async def proto_sign(self, keys, tx_num_str=''): if (self.has_segwit_inputs() or self.has_segwit_outputs()) and not self.proto.cap('segwit'): ymsg(f"TX has Segwit inputs or outputs, but {self.coin} doesn't support Segwit!") diff --git a/mmgen/proto/vm/tx/unsigned.py b/mmgen/proto/vm/tx/unsigned.py index 270ba810..8030c4f0 100755 --- a/mmgen/proto/vm/tx/unsigned.py +++ b/mmgen/proto/vm/tx/unsigned.py @@ -18,13 +18,7 @@ class Unsigned: desc = 'unsigned transaction' # Return signed object or False. Don’t exit or raise exception: - async def sign(self, keys, tx_num_str=''): - - from ....exception import TransactionChainMismatch - try: - self.check_correct_chain() - except TransactionChainMismatch: - return False + async def proto_sign(self, keys, tx_num_str=''): o = self.txobj diff --git a/mmgen/tx/unsigned.py b/mmgen/tx/unsigned.py index 0ea448e8..ba0fc507 100755 --- a/mmgen/tx/unsigned.py +++ b/mmgen/tx/unsigned.py @@ -20,6 +20,18 @@ class Unsigned(Completed): ext = 'rawtx' automount = False + # Return signed object or False. Don’t exit or raise exception, unless fatal: + async def sign(self, keys, tx_num_str=''): + + try: + self.check_correct_chain() + except Exception as e: + if type(e).__name__ == 'TransactionChainMismatch': + return False + raise # fatal + + return await self.proto_sign(keys, tx_num_str=tx_num_str) + def delete_attrs(self, desc, attr): for e in getattr(self, desc): if hasattr(e, attr):