teleport PSBT offset fix

This commit is contained in:
scgbckbone 2026-03-20 10:31:15 +01:00 committed by doc-hex
parent e630dd614f
commit 3f2e471ef5
2 changed files with 13 additions and 9 deletions

View File

@ -276,8 +276,10 @@ async def try_push_tx(data, txid, txn_sha=None):
class ApproveTransaction(UserAuthorizedAction):
def __init__(self, psbt_len, flags=None, psbt_sha=None, input_method=None,
output_encoder=None, filename=None, miniscript_wallet=None):
output_encoder=None, filename=None, miniscript_wallet=None,
offset=TXN_INPUT_OFFSET):
super().__init__()
self.offset = offset
self.psbt_len = psbt_len
# do finalize is None if not USB, None = decide based on is_complete
@ -406,7 +408,7 @@ class ApproveTransaction(UserAuthorizedAction):
# step 1: parse PSBT from PSRAM into in-memory objects.
try:
with SFFile(TXN_INPUT_OFFSET, length=self.psbt_len, message='Reading...') as fd:
with SFFile(self.offset, length=self.psbt_len, message='Reading...') as fd:
# NOTE: psbtObject captures the file descriptor and uses it later
self.psbt = psbtObject.read_psbt(fd)
except BaseException as exc:
@ -773,13 +775,14 @@ class ApproveTransaction(UserAuthorizedAction):
msg.write('%s %s\n\n' % self.chain.render_value(total_change - visible_change_sum))
def sign_transaction(psbt_len, flags=0x0, psbt_sha=None, miniscript_wallet=None):
def sign_transaction(psbt_len, flags=0x0, psbt_sha=None, miniscript_wallet=None,
offset=TXN_INPUT_OFFSET):
# transaction (binary) loaded into PSRAM already, checksum checked
# optional miniscript_wallet arg, choose particular enrolled wallet by name to sign
UserAuthorizedAction.check_busy(ApproveTransaction)
UserAuthorizedAction.active_request = ApproveTransaction(
psbt_len, flags, psbt_sha=psbt_sha, input_method="usb",
miniscript_wallet=miniscript_wallet,
miniscript_wallet=miniscript_wallet, offset=offset
)
# kill any menu stack, and put our thing at the top
@ -934,8 +937,9 @@ async def done_signing(psbt, tx_req, input_method=None, filename=None,
elif (ch == 't') and not is_complete:
# they might want to teleport it, but only if we have PSBT
# there is no need to teleport PSBT if txn is already complete & ready to be broadcast
# updated PSBT is at TXN_OUTPUT_OFFSET (at TXN_INPUT_OFFSET is PSBT that is NOT updated)
from teleport import kt_send_psbt
ok = await kt_send_psbt(psbt, data_len)
ok = await kt_send_psbt(psbt, data_len, psbt_offset=TXN_OUTPUT_OFFSET)
if ok:
title = "Sent by Teleport"
else:

View File

@ -639,7 +639,7 @@ class SecretPickerMenu(MenuSystem):
await kt_do_send(self.rx_pubkey, 's', raw=raw)
async def kt_send_psbt(psbt, psbt_len):
async def kt_send_psbt(psbt, psbt_len, psbt_offset):
# We just finished adding our signature to an incomplete PSBT.
# User wants to send to one or more other senders for them to complete signing.
@ -689,12 +689,12 @@ async def kt_send_psbt(psbt, psbt_len):
f = None
if x in need:
# we haven't signed ourselves yet, so allow that
from auth import sign_transaction, TXN_INPUT_OFFSET
from auth import sign_transaction
async def sign_now(*a):
# this will reset the UX stack:
# flags=None --> whether to finalize is decided based on psbt.is_complete
sign_transaction(psbt_len, flags=None)
sign_transaction(psbt_len, flags=None, offset=psbt_offset)
f = sign_now
@ -786,6 +786,6 @@ async def kt_send_file_psbt(*a):
await ux_show_story("We are not part of this wallet.", "Cannot Teleport PSBT")
return
await kt_send_psbt(psbt, psbt_len=psbt_len)
await kt_send_psbt(psbt, psbt_len=psbt_len, psbt_offset=TXN_INPUT_OFFSET)
# EOF