From c37ebd3f1aae8b3faf238cdca9789f1ca079f52c Mon Sep 17 00:00:00 2001 From: scgbckbone Date: Wed, 5 Apr 2023 19:20:37 +0200 Subject: [PATCH] zero output test; limitations update --- docs/limitations.md | 1 + shared/psbt.py | 2 +- testing/test_sign.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/limitations.md b/docs/limitations.md index 329df444..22b51c4a 100644 --- a/docs/limitations.md +++ b/docs/limitations.md @@ -48,6 +48,7 @@ - bitcoin limits transactions to 100k, but there could be large input transactions inside the PSBT. Reduce this by using segwit signatures and provide only the individual UTXO ("out points"). +- every transaction needs to have at least one output (otherwise Invalid PSBT) # P2SH / Multisig diff --git a/shared/psbt.py b/shared/psbt.py index f7e7e03e..b7e93f94 100644 --- a/shared/psbt.py +++ b/shared/psbt.py @@ -1162,7 +1162,7 @@ class psbtObject(psbtProxy): if self.xpubs: await self.handle_xpubs() - assert self.num_outputs >= 1, 'need outs' + assert self.num_outputs >= 1, 'need outputs' if DEBUG: our_keys = sum(1 for i in self.inputs if i.num_our_keys) diff --git a/testing/test_sign.py b/testing/test_sign.py index 9e9975f8..b00f8b3e 100644 --- a/testing/test_sign.py +++ b/testing/test_sign.py @@ -1941,4 +1941,30 @@ def test_sighash_all(addr_fmt, num_outs, microsd_path, need_keypress, goto_home, # tx with 6 inputs representing all possible sighashes _test_single_sig_sighash(addr_fmt, tuple(SIGHASH_MAP.keys()), num_inputs=6, num_outputs=num_outs) + +def test_no_outputs_tx(fake_txn, microsd_path, goto_home, need_keypress, pick_menu_item, cap_story): + goto_home() + psbt = fake_txn(3, 0) # no outputs + fname = "zero_outputs.psbt" + fpath = microsd_path(fname) + + with open(fpath, "wb") as f: + f.write(psbt) + + pick_menu_item("Ready To Sign") + time.sleep(0.1) + title, story = cap_story() + if "Choose PSBT file to be signed" in story: + need_keypress("y") + pick_menu_item(fname) + time.sleep(0.1) + title, story = cap_story() + + assert title == "Failure" + assert "Invalid PSBT" in story + assert "need outputs" in story + + try: os.remove(fpath) + except: pass + # EOF