input-output-hk / nami

Nami Wallet is a browser based wallet extension to interact with the Cardano blockchain. Support requests: https://iohk.zendesk.com/hc/en-us/requests/new
https://namiwallet.io
Apache License 2.0
373 stars 167 forks source link

[BUG] Valid transaction rejected by `signTx` with error code `-1` #827

Open michele-nuzzi opened 1 year ago

michele-nuzzi commented 1 year ago

below the cbor of the transaction

84aa00828258205ebb7fd41693ca030241d4b26f7feb31ca6760f1884170c416d912b20d42576501825820f445815a4829226f388c85fbc276ad3e6e362cfa5926b5a7c1c2a9e40871927c010184a2005839006be8e97edf291dea073bfccddb3e49b4fcf9b6a55e473afbec74d791f4c0646398c6943842fa92ce580086198de6cf0748dd25963c8ce15c01821a001e8480a1581c7392e007a94557f29c92396263fe1e9611d6855572f5436f40b09e9fa14c416666696c6961746520233701a2005839006be8e97edf291dea073bfccddb3e49b4fcf9b6a55e473afbec74d791f4c0646398c6943842fa92ce580086198de6cf0748dd25963c8ce15c011a0085e558a2005839006be8e97edf291dea073bfccddb3e49b4fcf9b6a55e473afbec74d791f4c0646398c6943842fa92ce580086198de6cf0748dd25963c8ce15c011a000ee098a2005839006be8e97edf291dea073bfccddb3e49b4fcf9b6a55e473afbec74d791f4c0646398c6943842fa92ce580086198de6cf0748dd25963c8ce15c011a038ecff2021a0007ae32031a01b54bf408000b5820690cd9a2915e8da05e9ff28d3e6574fcc4c853945a4d58a6546de2597df0e1490d81825820f445815a4829226f388c85fbc276ad3e6e362cfa5926b5a7c1c2a9e40871927c010e81581c6be8e97edf291dea073bfccddb3e49b4fcf9b6a55e473afbec74d7910f0010a2005839006be8e97edf291dea073bfccddb3e49b4fcf9b6a55e473afbec74d791f4c0646398c6943842fa92ce580086198de6cf0748dd25963c8ce15c011a03e4b22ea20581840000d87980821988a81a00a86a7c06815902b25902af010000323232323232323232322225333573466664444646466660260084660266602666026a00426ae8cd5d11bac3574200626ae8cd5d11bac30110031323232330163375e602800266e95200433574066e9520003357406ae8400ccd5d01ba8375a6ae84010cd5d01aba10023357406ae84d5d100119aba037506eb4c050010cd5d01ba8375a6026008024024266644464664a666ae68c005200010031533357346002900108020b1b8735573a0026aae78004dd50019aba1301535742002464646464646464646464646464646466e3cdd71aba1010001375c0026ae84004d55cf0009baa00135742002603e0026ae84004c074004c068004c06c004d5d08009bac3574200260300026ae84004c058020928180a1aba13758602660286ae84c050018d5d11aba200135573c6ea8018940088c8c8c8c8c8c8cccc0680040188cdc49bad357420026eb4c8d5d09aba2357446ae88d5d11aba2001301900d00635742002602c00260260026028002646ae84d5d11aba2357446ae88d5d11aba23574400260266ae84c04c01492809991980590a502223322533357340042944004c0100084c00c004dc79bae357426020008664664601646ae80c0080040052f588eb8dd6191aba1357446ae88d5d11aba2357446ae88d5d11aba2001001300f35742601e00291011c1f8d0e1cc67adec0ad6231ac540ccec1fcc310485fa68d74c9ae2db10000300200114985888cc00c84008888cc014008c00c004c0088888c8ccc018c010004c00c004008cc01000c0088894ccd55cf8008018998011aba1001357440024646004466004004002460044660040040026ec5262357426ae880048d5d09aba23574400246aae78dd5000912999ab9a00200114a0444464664a666ae68c005200010031533357346002900108020a999ab9a300148010401458dc39aab9d00135573c0026ea80101f5f6

The error message thrown by nami.signTx is:

{
    "code": -1,
    "info": "Inputs do not conform to this spec or are otherwise invalid."
}

pasting the above transaction in cbor.me is clear that the inputs (entry 0 of the transaction body) are valid (according to the cardano-ledger cddl:

82                                # array(2)
   82                             # array(2)
      58 20                       # bytes(32)
         5EBB7FD41693CA030241D4B26F7FEB31CA6760F1884170C416D912B20D425765 # "^\xBB\u007F\xD4\u0016\x93\xCA\u0003\u0002AԲo\u007F\xEB1\xCAg`\xF1\x88Ap\xC4\u0016\xD9\u0012\xB2\rBWe"
      01                          # unsigned(1)
   82                             # array(2)
      58 20                       # bytes(32)
         F445815A4829226F388C85FBC276AD3E6E362CFA5926B5A7C1C2A9E40871927C # "\xF4E\x81ZH)\"o8\x8C\x85\xFB\xC2v\xAD>n6,\xFAY&\xB5\xA7\xC1©\xE4\bq\x92|"
      01                          # unsigned(1)
yHSJ commented 11 months ago

Hey @michele-nuzzi!

I am exploring the Nami dead issues and trying to resolve at least some of them. While I assume that this is no longer an issue for you, I wanted to clarify what was happening here for you, and others who may have similar questions.

This behavior is the expected behavior, as specified in CIP-30.

I cannot be 100% sure what happened in this case, because I do not have all the information about the inputs being consumed in this transaction and what keys you were attempting to sign with. However, according to CIP-30, the wallet is expected to throw a TxSignError if partialSign is not true and the wallet cannot provide a signature for all required keys.

While I don't know the specifics of what key was signing, looking at the transaction I can see that there was a required signer. I am assuming that was different from the signer needed to consume the inputs. Therefore, the TxSignError should've been thrown, according to the specification.

The "Inputs" word in the error message is a bit complicated, since it is not referring to transaction inputs, but instead the arguments passed to the function call. That error message also comes from CIP-30, which could be improved but this is not the place.

Hopefully, that clears up confusion!