tx.unsigned: new sign() method

This commit is contained in:
The MMGen Project 2026-08-29 15:04:29 +00:00
commit dab9d6bda9
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 14 additions and 14 deletions

View file

@ -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!")

View file

@ -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

View file

@ -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):