From 8a6e5b8f11190b1fc3366bd470efdd8eca489a57 Mon Sep 17 00:00:00 2001 From: tadeubas Date: Fri, 12 Jul 2024 19:08:48 -0300 Subject: [PATCH 1/6] change high fees warning from 30 to 10% --- src/krux/pages/home_pages/home.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/krux/pages/home_pages/home.py b/src/krux/pages/home_pages/home.py index 39b5f28f2..66fe985eb 100644 --- a/src/krux/pages/home_pages/home.py +++ b/src/krux/pages/home_pages/home.py @@ -330,8 +330,8 @@ def sign_psbt(self): self.ctx.display.draw_centered_text(t("Processing ...")) outputs, fee_percent = signer.outputs() - # Warn if fees greater than 30% of what is spent - if fee_percent >= 30.0: + # Warn if fees greater than 10% of what is spent + if fee_percent >= 10.0: self.ctx.display.clear() self.ctx.display.draw_centered_text( t("Warning:") From b6736e021365b8ad3b0b2d464f9bc2151c85e0b5 Mon Sep 17 00:00:00 2001 From: tadeubas Date: Fri, 12 Jul 2024 19:11:24 -0300 Subject: [PATCH 2/6] Test P2TR PSBT without fingerprint --- tests/pages/home_pages/test_home.py | 81 ++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/tests/pages/home_pages/test_home.py b/tests/pages/home_pages/test_home.py index 57380a987..5d4e4b746 100644 --- a/tests/pages/home_pages/test_home.py +++ b/tests/pages/home_pages/test_home.py @@ -6,7 +6,7 @@ @pytest.fixture def tdata(mocker): from collections import namedtuple - from krux.key import Key, P2PKH, P2SH_P2WPKH + from krux.key import Key, P2PKH, P2SH_P2WPKH, P2TR from embit.networks import NETWORKS TEST_12_WORD_MNEMONIC = ( @@ -22,6 +22,9 @@ def tdata(mocker): SINGLESIG_SIGNING_KEY = Key(SIGNING_MNEMONIC, False, NETWORKS["main"]) MULTISIG_SIGNING_KEY = Key(SIGNING_MNEMONIC, True, NETWORKS["main"]) SINGLESIG_ACTION_KEY = Key(ACTION_MNEMONIC, False, NETWORKS["main"]) + SINGLESIG_ACTION_KEY_TEST = Key( + ACTION_MNEMONIC, False, NETWORKS["test"], script_type=P2TR + ) LEGACY1_KEY = Key( TEST_12_WORD_MNEMONIC, False, @@ -54,7 +57,9 @@ def tdata(mocker): SIGNED_P2WPKH_PSBT = b'psbt\xff\x01\x00q\x02\x00\x00\x00\x01\xcfe\xff;L\xd4\x7f\x12\x1f\xa7\xc9\x82(F\x18\xdb\x801G\xb0V\xd3\x93\x94\xd4\xecB\x0e\xfd\xfck\xa1\x02 l\xbd\xd8\x8a\xc5\x18l?.\xfd$%1\xedy\x17uvQ\xac&#t\xf3\xd3\x1d\x85\xd6\x16\xcdj\x81\x01\x00\x00\x00' P2WPKH_PSBT_B64 = "cHNidP8BAHECAAAAAc88WMMpgq4gUIjZvUnrmwKs3009rnalFsazBrFd46FOAAAAAAD9////Anw/XQUAAAAAFgAULzSqHPAKU7BVopGgOn1F8KaYi1KAlpgAAAAAABYAFOZq/v/Dg45x8KJ7B+OwDt5q6OFgAAAAAAABAR8A4fUFAAAAABYAFNDEo+8J6Ze26Z45flGP4+QaEYyhIgYC56slN7XUnpcDCargbp5J82zhyf671E7I4NHMoLT5wxkYc8XaClQAAIABAACAAAAAgAAAAAAAAAAAACICA11J7M1U0AmeQ2did8em1GJdYR2oil30m/lReneRp3elGHPF2gpUAACAAQAAgAAAAIABAAAAAAAAAAAA" P2WPKH_PSBT_B64_ZEROES_FINGERPRINT = "cHNidP8BAHECAAAAAc88WMMpgq4gUIjZvUnrmwKs3009rnalFsazBrFd46FOAAAAAAD9////Anw/XQUAAAAAFgAULzSqHPAKU7BVopGgOn1F8KaYi1KAlpgAAAAAABYAFOZq/v/Dg45x8KJ7B+OwDt5q6OFgAAAAAAABAR8A4fUFAAAAABYAFNDEo+8J6Ze26Z45flGP4+QaEYyhIgYC56slN7XUnpcDCargbp5J82zhyf671E7I4NHMoLT5wxkYAAAAAFQAAIABAACAAAAAgAAAAAAAAAAAACICA11J7M1U0AmeQ2did8em1GJdYR2oil30m/lReneRp3elGHPF2gpUAACAAQAAgAAAAIABAAAAAAAAAAAA" + P2TR_PSBT_BIN_ZEROES_FINGERPRINT = b"psbt\xff\x01\x00R\x02\x00\x00\x00\x01\xe6\x02\x02c\xc5\xfdX\xa1\x17[\xf2\xc0Z-\xfd\xa9\x84\xc8H\xf0\x84B)\xa7\x0b\xf6WA\xfaE\xde\xf4\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01-\xe1\x01\x00\x00\x00\x00\x00\x16\x00\x14\xb1P%\xed\xdb8\x87^\xc7h\x8d]6srC\x81)gq\x00\x00\x00\x00O\x01\x045\x87\xcf\x03\xca\xd0\xf4J\x80\x00\x00\x00\x07\x1aOa\x83\xb1T7u\x18\xe8\xbd|\x9e\x0c\x9c\xa0\t\x8cV\x8a:J\x96\xa3\x9eK\xd9\xb4\xff\x9f4\x02\x8c\xc0\x83\xa0\x96^\x8c@A!\xf6\xd7\xa46#?3E\x89p\xb1E\xd3rk2lDL\x84\xfd\xdf\x10\x00\x00\x00\x00V\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x00\x01\x00\x87\x02\x00\x00\x00\x02\xc6\xfcO\x0f\t|9X\x93\xfc\x051\x12\x03(\xe7\xc38\x87\xee\xaf\xf9\x84\x06\xea\xf5\xa6)#\xf7\xa8;\x00\x00\x00\x00\x00\xfd\xff\xff\xff\xe1\xa1U,\x01\n?\x8e:Y1e\xf8\xc7`$\xb0\xa2\xb6V\xa5\x9e\x01\n\xcd0P\xe9%\x18n\xb5\x01\x00\x00\x00\x00\xfd\xff\xff\xff\x01\xe8\xe7\x01\x00\x00\x00\x00\x00\"Q \x0f\xdf\xc7Q\x92}\xd5t\xbe'\\\xd6m\xb4\x84\xc8t.\x8f\xcc\xaa\xff\x04*\xf8\xc5\xe9(\x83\x0fX\xac\xd4\xc1+\x00\x01\x01+\xe8\xe7\x01\x00\x00\x00\x00\x00\"Q \x0f\xdf\xc7Q\x92}\xd5t\xbe'\\\xd6m\xb4\x84\xc8t.\x8f\xcc\xaa\xff\x04*\xf8\xc5\xe9(\x83\x0fX\xac\x01\x03\x04\x00\x00\x00\x00!\x16\x8b4{\xa5\xc1l\n&\xcd3\xfefv\xbbA~\xe8\x1fB\xf1(\x17\xa6\xe4\x11\xee\x8a\xb2\x00\xdf\xe9`\x19\x00\x00\x00\x00\x00V\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x01\x17 \x8b4{\xa5\xc1l\n&\xcd3\xfefv\xbbA~\xe8\x1fB\xf1(\x17\xa6\xe4\x11\xee\x8a\xb2\x00\xdf\xe9`\x00\x00" SIGNED_P2WPKH_PSBT_B64 = "cHNidP8BAHECAAAAAc88WMMpgq4gUIjZvUnrmwKs3009rnalFsazBrFd46FOAAAAAAD9////Anw/XQUAAAAAFgAULzSqHPAKU7BVopGgOn1F8KaYi1KAlpgAAAAAABYAFOZq/v/Dg45x8KJ7B+OwDt5q6OFgAAAAAAABAR8A4fUFAAAAABYAFNDEo+8J6Ze26Z45flGP4+QaEYyhIgIC56slN7XUnpcDCargbp5J82zhyf671E7I4NHMoLT5wxlHMEQCID5l/ztM1H8SH6fJgihGGNuAMUewVtOTlNTsQg79/GuhAiBsvdiKxRhsPy79JCUx7XkXdXZRrCYjdPPTHYXWFs1qgQEAAAA=" + SIGNED_P2TR_PSBT_BIN = b"psbt\xff\x01\x00R\x02\x00\x00\x00\x01\xe6\x02\x02c\xc5\xfdX\xa1\x17[\xf2\xc0Z-\xfd\xa9\x84\xc8H\xf0\x84B)\xa7\x0b\xf6WA\xfaE\xde\xf4\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01-\xe1\x01\x00\x00\x00\x00\x00\x16\x00\x14\xb1P%\xed\xdb8\x87^\xc7h\x8d]6srC\x81)gq\x00\x00\x00\x00\x00\x01\x01+\xe8\xe7\x01\x00\x00\x00\x00\x00\"Q \x0f\xdf\xc7Q\x92}\xd5t\xbe'\\\xd6m\xb4\x84\xc8t.\x8f\xcc\xaa\xff\x04*\xf8\xc5\xe9(\x83\x0fX\xac\x01\x08B\x01@jRXU\x1f\x0f2\xd2\xd8?\x08a\x089\xfa\x936\x13_\x8d\x0f\xcb\xb9\x04\xc0T\xe4\xea\xc6~\xf2A\xa6K\xc8Lu\r\x1b\x8aN\xca\xf6\x95\xce\xa6p\x0e\xc1\x95\xcbd\t\xfc\xa3^,lQF\xca'9\xa6\x00\x00" P2WSH_PSBT = b'psbt\xff\x01\x00\xb2\x02\x00\x00\x00\x02\xadC\x87\x14J\xfae\x07\xe1>\xaeP\xda\x1b\xf1\xb5\x1ag\xb3\x0f\xfb\x8e\x0c[\x8f\x98\xf5\xb3\xb1\xa68Y\x00\x00\x00\x00\x00\xfd\xff\xff\xffig%Y\x0f\xb8\xe4r\xab#N\xeb\xf3\xbf\x04\xd9J\xc0\xba\x94\xf6\xa5\xa4\xf8B\xea\xdb\x9a\xd3c`\xd4\x01\x00\x00\x00\x00\xfd\xff\xff\xff\x02@B\x0f\x00\x00\x00\x00\x00"\x00 \xa9\x903\xc3\x86b3>Y\t\xae<=\x03\xbdq\x8d\xb2\x14Y\xfd\xd5P\x1e\xe8\xa0RaMY\xb4\xe2\xd8\xd2!\x01\x00\x00\x00\x00"\x00 \x8d\x02\x85\r\xab\x88^\xc5y\xbbm\xcb\x05\xd6 ;\x05\xf5\x17\x01\x86\xac\xb8\x90}l\xc1\xb4R\x99\xed\xd2\x00\x00\x00\x00O\x01\x045\x87\xcf\x04>b\xdf~\x80\x00\x00\x02A+I\x84\xd5I\xba^\xef\x1c\xa6\xe8\xf3u]\x9a\xe0\x16\xdam\x16ir\xca\x0eQ@6~\xddP\xda\x025\xb8K1\xdc8*|\xfbC\xba:{\x17K\xe9AaA\xe8\x16\xf6r[\xd1%\x12\xb5\xb2\xc4\xa5\xac\x14\x02\x08\xcbw0\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80O\x01\x045\x87\xcf\x04\x9d\xb1\xd0\x00\x80\x00\x00\x02?\xd8\xd7;\xc7\xb8\x8c\xa4\x93Z\xa57\xbf8\x94\xd5\xe2\x88\x9f\xab4\x1ca\x8fJWo\x8f\x19\x18\xc2u\x02h\xc3\rV\x9d#j}\xccW\x1b+\xb1\xd2\xadO\xa9\xf9\xb3R\xa8\t6\xa2\x89\n\x99\xaa#\xdbx\xec\x14&\xbb\x83\xc40\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80O\x01\x045\x87\xcf\x04\xba\xc1H9\x80\x00\x00\x02\x1dO\xbe\xbd\xd9g\xe1\xafqL\t\x97\xd3\x8f\xcfg\x0b\\\xe9\xd3\x01\xc0D\x0b\xbc\xc3\xb6\xa2\x0e\xb7r\x1c\x03V\x8e\xa1\xf3`Q\x91n\xd1\xb6\x90\xc3\x9e\x12\xa8\xe7\x06\x03\xb2\x80\xbd0\xce_(\x1f)\x18\xa5Sc\xaa\x14s\xc5\xda\n0\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x00\x01\x01+\x80\x96\x98\x00\x00\x00\x00\x00"\x00 \x89\x801pn\xdd\x9e\xb1"g\x85G\x15Q\xce\xa3_\x17\t\xa9o\x85\x96.2\xa0k\xf6~\xc7\x11$\x01\x05iR!\x02N\x8d\x08\x0c}}\xba\\G\xfe\xb6\xb1\xc8\x12M\xebbA\x17\xe5\x8d\x8d~\xb1J@\x04Oq\xdd\x97\xf2!\x03\x05a\xd4\x82\xad\xb9=\xf1\xef\x13\xe8ep\x1a\xf2$n\xf0\xa3l\xbc\x8c\xa5\x12=\x8e\xecw\xceN8\xc7!\x03h\x95r\xe2\x8b\x0f\xed\xa9\xd6\x98\x1c\x027\xd9\xe5\xde\xdb\xfe\xc1m\xe7\x14?h\n\x02\xed]\x15\x9fu\x87S\xae"\x06\x02N\x8d\x08\x0c}}\xba\\G\xfe\xb6\xb1\xc8\x12M\xebbA\x17\xe5\x8d\x8d~\xb1J@\x04Oq\xdd\x97\xf2\x1c&\xbb\x83\xc40\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x00\x00\x00\x00\x01\x00\x00\x00"\x06\x03\x05a\xd4\x82\xad\xb9=\xf1\xef\x13\xe8ep\x1a\xf2$n\xf0\xa3l\xbc\x8c\xa5\x12=\x8e\xecw\xceN8\xc7\x1c\x02\x08\xcbw0\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x00\x00\x00\x00\x01\x00\x00\x00"\x06\x03h\x95r\xe2\x8b\x0f\xed\xa9\xd6\x98\x1c\x027\xd9\xe5\xde\xdb\xfe\xc1m\xe7\x14?h\n\x02\xed]\x15\x9fu\x87\x1cs\xc5\xda\n0\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01\x01+\x80\x96\x98\x00\x00\x00\x00\x00"\x00 3w\xad03\xd1\x05\x9c\xf1\xd25\xbb\x12%\xfc\xa2\xa4\xbf&\xc9R\xd5?o\xef\xc3:-UD\x8d\xc5\x01\x05iR!\x02"\x821\x12\xe5\xcc\x88K\x91\x16\xcb!B\x0c\xc7\x92\x98$\xcd/\xe8\xb7#[\xf9\x92\xe8\xae\xde\x14l"!\x02\x83\xcdG\xe5Sm\xcby\xe7\x11\x830\xe8\xe4\x80B\x12\xf6\x96\x19\xf1\xd6\xec\x99\r\xc75\xef\xb9\xce\xc5t!\x03\x0b\x90\xed.\x86\xba\xd7\xf2\xa4\xfe\x97i\xbbA}{\xa9\xca\xa1\x12H\x07\xdb\xfb6-\xfb\xee\xb6^~\x01S\xae"\x06\x02"\x821\x12\xe5\xcc\x88K\x91\x16\xcb!B\x0c\xc7\x92\x98$\xcd/\xe8\xb7#[\xf9\x92\xe8\xae\xde\x14l"\x1c\x02\x08\xcbw0\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00"\x06\x02\x83\xcdG\xe5Sm\xcby\xe7\x11\x830\xe8\xe4\x80B\x12\xf6\x96\x19\xf1\xd6\xec\x99\r\xc75\xef\xb9\xce\xc5t\x1c&\xbb\x83\xc40\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00"\x06\x03\x0b\x90\xed.\x86\xba\xd7\xf2\xa4\xfe\x97i\xbbA}{\xa9\xca\xa1\x12H\x07\xdb\xfb6-\xfb\xee\xb6^~\x01\x1cs\xc5\xda\n0\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01iR!\x02\xad!\xd9\xad(\xab\x99\xac~\xdf\xd9\x1e"!O\x11YS\xab\t\xd1\xd5X\x10\x92\xfbG\xbd\xa5\x92r\xfe!\x03\xa0};\xe0\xba\xd6<\x805\xd2\x1c\x97\xb4\x10\x89\r=:\x19\xd2\xe4\x03\xaf\xb3\xfc\xfch&\xaa&\x02\xb8\xf4\xcfb\xbc\xc6\xa7\xa2kS\xae"\x02\x02\xad!\xd9\xad(\xab\x99\xac~\xdf\xd9\x1e"!O\x11YS\xab\t\xd1\xd5X\x10\x92\xfbG\xbd\xa5\x92r\xfe\x1c\x02\x08\xcbw0\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x01\x00\x00\x00\x00\x00\x00\x00"\x02\x03\xa0};\xe0\xba\xd6<\x805\xd2\x1c\x97\xb4\x10\x89\r=:\x19\xd2\xe4\x03\xaf\xb3\xfc\xfch&\xaa&\x02\xb8\xf4\xcfb\xbc\xc6\xa7\xa2k\x1c&\xbb\x83\xc40\x00\x00\x80\x01\x00\x00\x80\x00\x00\x00\x80\x02\x00\x00\x80\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00' SIGNED_P2WSH_PSBT = b'psbt\xff\x01\x00\xb2\x02\x00\x00\x00\x02\xadC\x87\x14J\xfae\x07\xe1>\xaeP\xda\x1b\xf1\xb5\x1ag\xb3\x0f\xfb\x8e\x0c[\x8f\x98\xf5\xb3\xb1\xa68Y\x00\x00\x00\x00\x00\xfd\xff\xff\xffig%Y\x0f\xb8\xe4r\xab#N\xeb\xf3\xbf\x04\xd9J\xc0\xba\x94\xf6\xa5\xa4\xf8B\xea\xdb\x9a\xd3c`\xd4\x01\x00\x00\x00\x00\xfd\xff\xff\xff\x02@B\x0f\x00\x00\x00\x00\x00"\x00 \xa9\x903\xc3\x86b3>Y\t\xae<=\x03\xbdq\x8d\xb2\x14Y\xfd\xd5P\x1e\xe8\xa0RaMY\xb4\xe2\xd8\xd2!\x01\x00\x00\x00\x00"\x00 \x8d\x02\x85\r\xab\x88^\xc5y\xbbm\xcb\x05\xd6 ;\x05\xf5\x17\x01\x86\xac\xb8\x90}l\xc1\xb4R\x99\xed\xd2\x00\x00\x00\x00\x00\x01\x01+\x80\x96\x98\x00\x00\x00\x00\x00"\x00 \x89\x801pn\xdd\x9e\xb1"g\x85G\x15Q\xce\xa3_\x17\t\xa9o\x85\x96.2\xa0k\xf6~\xc7\x11$"\x02\x03h\x95r\xe2\x8b\x0f\xed\xa9\xd6\x98\x1c\x027\xd9\xe5\xde\xdb\xfe\xc1m\xe7\x14?h\n\x02\xed]\x15\x9fu\x87G0D\x02 h?m\x19\x04C\x89\x95\x8b\xba\xed\xbb\xba8)\t\xae^\xe3`\x16G\xc8\x8bq\x9c\x0e\xbc\xc5\xb1j\xa2\x02 \x05\rP(\xe0\x9cc])q\xe5\xe2S\x9f\xaf+\xe4_\xa9\xc6\xf9\r"%\xf4\xa2\x00;\xa2\xaf2W\x01\x01\x05iR!\x02N\x8d\x08\x0c}}\xba\\G\xfe\xb6\xb1\xc8\x12M\xebbA\x17\xe5\x8d\x8d~\xb1J@\x04Oq\xdd\x97\xf2!\x03\x05a\xd4\x82\xad\xb9=\xf1\xef\x13\xe8ep\x1a\xf2$n\xf0\xa3l\xbc\x8c\xa5\x12=\x8e\xecw\xceN8\xc7!\x03h\x95r\xe2\x8b\x0f\xed\xa9\xd6\x98\x1c\x027\xd9\xe5\xde\xdb\xfe\xc1m\xe7\x14?h\n\x02\xed]\x15\x9fu\x87S\xae\x00\x01\x01+\x80\x96\x98\x00\x00\x00\x00\x00"\x00 3w\xad03\xd1\x05\x9c\xf1\xd25\xbb\x12%\xfc\xa2\xa4\xbf&\xc9R\xd5?o\xef\xc3:-UD\x8d\xc5"\x02\x03\x0b\x90\xed.\x86\xba\xd7\xf2\xa4\xfe\x97i\xbbA}{\xa9\xca\xa1\x12H\x07\xdb\xfb6-\xfb\xee\xb6^~\x01G0D\x02 ~O\x1b\x8c\xbb\x87x\xa3\xbb\xff\x04\xd8\x10Cq\xc8Y\x0f;N6\x97\xd8S\xfeti\x80\xb3\x12\xe0>\x02 l\x93=\x02m\xb4<\x90\xf4%\xf9Z${\xb7\xecO\x19\x15\xa3\xa3S\xf2Q\x81\xdcX\xfb\xd5&\x9e\xc5\x01\x01\x05iR!\x02"\x821\x12\xe5\xcc\x88K\x91\x16\xcb!B\x0c\xc7\x92\x98$\xcd/\xe8\xb7#[\xf9\x92\xe8\xae\xde\x14l"!\x02\x83\xcdG\xe5Sm\xcby\xe7\x11\x830\xe8\xe4\x80B\x12\xf6\x96\x19\xf1\xd6\xec\x99\r\xc75\xef\xb9\xce\xc5t!\x03\x0b\x90\xed.\x86\xba\xd7\xf2\xa4\xfe\x97i\xbbA}{\xa9\xca\xa1\x12H\x07\xdb\xfb6-\xfb\xee\xb6^~\x01S\xae\x00\x00\x00' P2WSH_PSBT_B64 = "cHNidP8BALICAAAAAq1DhxRK+mUH4T6uUNob8bUaZ7MP+44MW4+Y9bOxpjhZAAAAAAD9////aWclWQ+45HKrI07r878E2UrAupT2paT4QurbmtNjYNQBAAAAAP3///8CQEIPAAAAAAAiACCpkDPDhmIzPlkJrjw9A71xjbIUWf3VUB7ooFJhTVm04tjSIQEAAAAAIgAgjQKFDauIXsV5u23LBdYgOwX1FwGGrLiQfWzBtFKZ7dIAAAAATwEENYfPBD5i336AAAACQStJhNVJul7vHKbo83VdmuAW2m0WaXLKDlFANn7dUNoCNbhLMdw4Knz7Q7o6exdL6UFhQegW9nJb0SUStbLEpawUAgjLdzAAAIABAACAAAAAgAIAAIBPAQQ1h88EnbHQAIAAAAI/2Nc7x7iMpJNapTe/OJTV4oifqzQcYY9KV2+PGRjCdQJoww1WnSNqfcxXGyux0q1PqfmzUqgJNqKJCpmqI9t47BQmu4PEMAAAgAEAAIAAAACAAgAAgE8BBDWHzwS6wUg5gAAAAh1Pvr3ZZ+GvcUwJl9OPz2cLXOnTAcBEC7zDtqIOt3IcA1aOofNgUZFu0baQw54SqOcGA7KAvTDOXygfKRilU2OqFHPF2gowAACAAQAAgAAAAIACAACAAAEBK4CWmAAAAAAAIgAgiYAxcG7dnrEiZ4VHFVHOo18XCalvhZYuMqBr9n7HESQBBWlSIQJOjQgMfX26XEf+trHIEk3rYkEX5Y2NfrFKQARPcd2X8iEDBWHUgq25PfHvE+hlcBryJG7wo2y8jKUSPY7sd85OOMchA2iVcuKLD+2p1pgcAjfZ5d7b/sFt5xQ/aAoC7V0Vn3WHU64iBgJOjQgMfX26XEf+trHIEk3rYkEX5Y2NfrFKQARPcd2X8hwmu4PEMAAAgAEAAIAAAACAAgAAgAAAAAABAAAAIgYDBWHUgq25PfHvE+hlcBryJG7wo2y8jKUSPY7sd85OOMccAgjLdzAAAIABAACAAAAAgAIAAIAAAAAAAQAAACIGA2iVcuKLD+2p1pgcAjfZ5d7b/sFt5xQ/aAoC7V0Vn3WHHHPF2gowAACAAQAAgAAAAIACAACAAAAAAAEAAAAAAQErgJaYAAAAAAAiACAzd60wM9EFnPHSNbsSJfyipL8myVLVP2/vwzotVUSNxQEFaVIhAiKCMRLlzIhLkRbLIUIMx5KYJM0v6LcjW/mS6K7eFGwiIQKDzUflU23LeecRgzDo5IBCEvaWGfHW7JkNxzXvuc7FdCEDC5DtLoa61/Kk/pdpu0F9e6nKoRJIB9v7Ni377rZefgFTriIGAiKCMRLlzIhLkRbLIUIMx5KYJM0v6LcjW/mS6K7eFGwiHAIIy3cwAACAAQAAgAAAAIACAACAAAAAAAAAAAAiBgKDzUflU23LeecRgzDo5IBCEvaWGfHW7JkNxzXvuc7FdBwmu4PEMAAAgAEAAIAAAACAAgAAgAAAAAAAAAAAIgYDC5DtLoa61/Kk/pdpu0F9e6nKoRJIB9v7Ni377rZefgEcc8XaCjAAAIABAACAAAAAgAIAAIAAAAAAAAAAAAABAWlSIQKtIdmtKKuZrH7f2R4iIU8RWVOrCdHVWBCS+0e9pZJy/iEDoH074LrWPIA10hyXtBCJDT06GdLkA6+z/PxoJqomPHYhA6GoQ/otQdk71nUpYZFfbkSKdBkkSj4CuPTPYrzGp6JrU64iAgKtIdmtKKuZrH7f2R4iIU8RWVOrCdHVWBCS+0e9pZJy/hwCCMt3MAAAgAEAAIAAAACAAgAAgAEAAAAAAAAAIgIDoH074LrWPIA10hyXtBCJDT06GdLkA6+z/PxoJqomPHYcc8XaCjAAAIABAACAAAAAgAIAAIABAAAAAAAAACICA6GoQ/otQdk71nUpYZFfbkSKdBkkSj4CuPTPYrzGp6JrHCa7g8QwAACAAQAAgAAAAIACAACAAQAAAAAAAAAAAA==" @@ -77,6 +82,7 @@ def tdata(mocker): "SINGLESIG_SIGNING_KEY", "MULTISIG_SIGNING_KEY", "SINGLESIG_ACTION_KEY", + "SINGLESIG_ACTION_KEY_TEST", "LEGACY1_KEY", "NESTEDSW1_KEY", "NATIVESW1_KEY", @@ -89,7 +95,9 @@ def tdata(mocker): "SIGNED_P2WPKH_PSBT", "P2WPKH_PSBT_B64", "P2WPKH_PSBT_B64_ZEROES_FINGERPRINT", + "P2TR_PSBT_BIN_ZEROES_FINGERPRINT", "SIGNED_P2WPKH_PSBT_B64", + "SIGNED_P2TR_PSBT_BIN", "P2WSH_PSBT", "SIGNED_P2WSH_PSBT", "P2WSH_PSBT_B64", @@ -106,6 +114,7 @@ def tdata(mocker): SINGLESIG_SIGNING_KEY, MULTISIG_SIGNING_KEY, SINGLESIG_ACTION_KEY, + SINGLESIG_ACTION_KEY_TEST, LEGACY1_KEY, NESTEDSW1_KEY, NATIVESW1_KEY, @@ -118,7 +127,9 @@ def tdata(mocker): SIGNED_P2WPKH_PSBT, P2WPKH_PSBT_B64, P2WPKH_PSBT_B64_ZEROES_FINGERPRINT, + P2TR_PSBT_BIN_ZEROES_FINGERPRINT, SIGNED_P2WPKH_PSBT_B64, + SIGNED_P2TR_PSBT_BIN, P2WSH_PSBT, SIGNED_P2WSH_PSBT, P2WSH_PSBT_B64, @@ -847,6 +858,74 @@ def test_sign_zeroes_fingerprint(mocker, m5stickv, tdata): ) +def test_sign_p2tr_zeroes_fingerprint(mocker, m5stickv, tdata): + from krux.pages.home_pages.home import Home + from krux.wallet import Wallet + from krux.input import BUTTON_ENTER, BUTTON_PAGE + from krux.sd_card import PSBT_FILE_EXTENSION, SIGNED_FILE_SUFFIX + + PSBT_FILE_NAME = "test.psbt" + SIGNED_PSBT_FILE_NAME = "test-signed.psbt" + + btn_seq = [ + BUTTON_PAGE, # Move to "Load from SD card" + BUTTON_ENTER, # Load from SD card + BUTTON_ENTER, # Confirm fingerprint missing + BUTTON_ENTER, # PSBT resume + BUTTON_ENTER, # output 1 + BUTTON_PAGE, # Move to "Sign to QR SD card" + BUTTON_ENTER, # Sign to SD card + ] + + wallet = Wallet(tdata.SINGLESIG_ACTION_KEY_TEST) + ctx = create_ctx(mocker, btn_seq, wallet) + home = Home(ctx) + + mocker.spy(home, "display_qr_codes") + mocker.spy(ctx.display, "draw_centered_text") + + # SD available + mocker.patch.object(home, "has_sd_card", new=lambda: True) + mock_utils = mocker.patch("krux.pages.utils.Utils") + mock_utils.return_value.load_file.return_value = (PSBT_FILE_NAME, None) + # Mock for reading from input file + mock_open_read = mocker.mock_open(read_data=tdata.P2TR_PSBT_BIN_ZEROES_FINGERPRINT) + # Mock for writing to output file + mock_open_write = mocker.mock_open() + # Ensure the write method returns the number of bytes written + mock_open_write.return_value.write.side_effect = lambda x: len(x) + mocker.patch( + "builtins.open", + side_effect=[mock_open_read.return_value, mock_open_write.return_value], + ) + mock_set_filename = mocker.patch( + "krux.pages.file_operations.SaveFile.set_filename", + return_value=SIGNED_PSBT_FILE_NAME, + ) + + home.sign_psbt() + + # all inputs were used/consumed + assert ctx.input.wait_for_button.call_count == len(btn_seq) + + # signed from/to SD card + mock_utils.return_value.load_file.assert_called_once_with( + ".psbt", prompt=False, only_get_filename=True + ) + mock_set_filename.assert_called_once_with( + PSBT_FILE_NAME, + "QRCode", + SIGNED_FILE_SUFFIX, + PSBT_FILE_EXTENSION, + ) + + # Get the mock file handle for writing + handle_write = mock_open_write() + # # Embit will write the signed PSBT to the output file in chunks. Capture all write calls + written_data = b"".join(call.args[0] for call in handle_write.write.call_args_list) + assert written_data == tdata.SIGNED_P2TR_PSBT_BIN + + def test_sign_high_fee(mocker, m5stickv, tdata): from krux.pages.home_pages.home import Home from krux.wallet import Wallet From 468f565579619af47be2e51ef029bafd31400b5e Mon Sep 17 00:00:00 2001 From: tadeubas Date: Fri, 12 Jul 2024 19:11:59 -0300 Subject: [PATCH 3/6] changelog small text changes --- CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90b839d5d..4cf5cd20d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,16 +43,16 @@ Ensure you are signing for the correct multisig setup by inspecting PSBT's finge The loaded key's fingerprint is now shown in the status bar. ### Fee Percentage of Transaction -Show the transaction's fee as a proportion of the transaction cost, warning if it is greater than 30%. +Show the transaction's fee as a proportion of the transaction cost, warning if it is greater than 10%. ### Sats/vB -PSBT now displays an accurate estimation of the transaction’s fee rate. +PSBT now displays an accurate estimation of the transaction’s feerate. ### Brightness Control for Maix Cube and M5stickV Adjust backlight intensity for better viewing and scanning from your Cube or M5stickV. ### Fast Forward for Buttons -Hold the NEXT or PREVIOUS buttons when typing text to fast forward or backward. +Hold the NEXT or PREVIOUS buttons when navigating among letters while typing text to fast forward or backward. ### Add Display Settings for Maix Amigo Add more display settings for Amigo to allow different display models to work properly. @@ -67,13 +67,13 @@ Krux will now sign PSBTs even if a fingerprint is not properly set on the coordi Krux will detect and warn the user in case arithmetic progression patterns in dice rolls by evaluating Shannon's entropy of the rolls derivative. ### Optimized SD Card Signing -Better suited for large transactions, SD card signing is now more RAM efficient, allowing transactions with 100 inputs or more to be signed in less than a minute. +Better suited for large transactions, SD card signing is now more RAM efficient, allowing transactions with +100 inputs to be signed in less than a minute. ### Stand Alone Verifiable Signed PSBTs Signed PSBT QR codes and SD card files now contain all the required data to verify the signatures without needing the original, unsigned PSBT. -### Camera Optimizations for Yahboom With GC2145 Camera -Recent Yahboom K210 devices now come with the GC2145 camera instead of the OV2640. Optimizations and features, such as anti-glare, have been added for the new camera. +### Camera Optimizations for Yahboom (ver:1.1) With GC2145 Camera +Recent Yahboom K210 devices (ver:1.1) come with the GC2145 camera instead of the OV2640 (ver:1.0). Optimizations and features, such as anti-glare, have been added for the new camera. ### Yahboom and Cube Devices Added to Simulator Simulator can now run as M5stickV, Amigo, Dock, Yahboom, and Cube. From e1e1f666682071c948439e1bd85bfa73ee995a79 Mon Sep 17 00:00:00 2001 From: tadeubas Date: Fri, 12 Jul 2024 19:17:05 -0300 Subject: [PATCH 4/6] Changelog: added sorted SD file explorer --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf5cd20d..a4b88ca28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,9 @@ Recent Yahboom K210 devices (ver:1.1) come with the GC2145 camera instead of the ### Yahboom and Cube Devices Added to Simulator Simulator can now run as M5stickV, Amigo, Dock, Yahboom, and Cube. +### Files sorted in SD file explorer +The SD file explorer now sorts files in ascending order, showing directories first. + # Changelog 24.03.0 - March 12, 2024 ## Changes From b60029f8350943c7c4485ac389b844a67f5436e3 Mon Sep 17 00:00:00 2001 From: tadeubas Date: Fri, 12 Jul 2024 19:41:22 -0300 Subject: [PATCH 5/6] Changelog: address explorer start index 0 instead of number 1 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b88ca28..a02c3e540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,9 @@ Simulator can now run as M5stickV, Amigo, Dock, Yahboom, and Cube. ### Files sorted in SD file explorer The SD file explorer now sorts files in ascending order, showing directories first. +### Receive or change address now starts with the index 0 +Address explorer now shows receive and change address starting at index 0 instead of number 1. + # Changelog 24.03.0 - March 12, 2024 ## Changes From 4417bcea1a0b1f9d08dbd9c6458dbe4930239f3c Mon Sep 17 00:00:00 2001 From: tadeubas Date: Fri, 12 Jul 2024 20:51:35 -0300 Subject: [PATCH 6/6] changelog: small fixes and code optimizations --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a02c3e540..8db7420f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,9 @@ The SD file explorer now sorts files in ascending order, showing directories fir ### Receive or change address now starts with the index 0 Address explorer now shows receive and change address starting at index 0 instead of number 1. +### Other Small Fixes and Code Optimizations +Bugfixes, optimizations and code refactoring. + # Changelog 24.03.0 - March 12, 2024 ## Changes