Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Errors for seemingly correct stellar transactions #414

Closed
istrau2 opened this issue Nov 15, 2018 · 7 comments
Closed

Errors for seemingly correct stellar transactions #414

istrau2 opened this issue Nov 15, 2018 · 7 comments
Assignees
Milestone

Comments

@istrau2
Copy link

istrau2 commented Nov 15, 2018

This is a continuation to trezor/connect#258

I am seeing a couple of strange error responses to transactions that seem ok to me:

  1. The following transaction:
{
  "source": "GDNAQREX5VOHMYZ2QDHDY6A7XR2OYIE67EETL5MFCT6TCGHYA7YHACEW",
  "fee": 100,
  "sequence": "89703140756029442",
  "operations": [
    {
      "type": "changeTrust",
      "line": {
        "code": "XRP",
        "issuer": "GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5"
      },
      "limit": "922337203685.4775"
    }
  ],
  "memo": {
    "type": 0
  }
}

produces:

1542214084817817 trezor.wire ERROR exception:
Traceback (most recent call last):
  File "/home/ishai/trezor-core/src/trezor/wire/__init__.py", line 128, in session_handler
  File "/home/ishai/trezor-core/src/trezor/wire/__init__.py", line 125, in session_handler
  File "/home/ishai/trezor-core/src/trezor/wire/__init__.py", line 163, in protobuf_workflow
  File "/home/ishai/trezor-core/src/trezor/wire/__init__.py", line 150, in protobuf_workflow
  File "/home/ishai/trezor-core/src/apps/stellar/sign_tx.py", line 26, in sign_tx
  File "/home/ishai/trezor-core/src/apps/stellar/sign_tx.py", line 75, in _operations
  File "/home/ishai/trezor-core/src/apps/stellar/operations/__init__.py", line 21, in process_operation
  File "/home/ishai/trezor-core/src/apps/stellar/operations/serialize.py", line 36, in write_change_trust_op
  File "/home/ishai/trezor-core/src/apps/stellar/operations/serialize.py", line 164, in _write_asset
  File "/home/ishai/trezor-core/src/apps/common/writers.py", line 37, in write_uint32_be
TypeError: unsupported types for __le__: 'int', 'NoneType'

I assume this is the 0 memo type. However, note that removing the memo entirely gives the same error.

  1. The following transaction:
{
  "source": "GDNAQREX5VOHMYZ2QDHDY6A7XR2OYIE67EETL5MFCT6TCGHYA7YHACEW",
  "fee": 100,
  "sequence": "89703140756029442",
  "operations": [
    {
      "type": "setOptions",
      "inflationDest": "GCCD6AJOYZCUAQLX32ZJF2MKFFAUJ53PVCFQI3RHWKL3V47QYE2BNAUT"
    }
  ],
  "memo": {
    "type": 0
  }
}

produces this return value (returned by trezor-connect, firmware never gets triggered):

{
  id: 2,
  payload: {
    code: undefined,
    error: "Cannot read property 'type' of undefined"
  },
  success: false
}

Thanks in advance

@tsusanka
Copy link
Contributor

In the first transaction you are not specifying the asset's type. You need to provide the type field and set it to 1 if it is 4-character maximum or 2 for 12-characters maximum, see Stellar's doc for more info.

So this passes fine then:

1. transaction json
TrezorConnect.stellarSignTransaction({
    path: "m/44'/1'/0'/0'/0'",
    networkPassphrase: "Test SDF Network ; September 2015",
    transaction: {
        "source": "GDNAQREX5VOHMYZ2QDHDY6A7XR2OYIE67EETL5MFCT6TCGHYA7YHACEW",
        "fee": 100,
        "sequence": "89703140756029442",
        "operations": [
        {
          "type": "changeTrust",
          "line": {
            "code": "XRP",
            "issuer": "GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5",
			"type": 1
          },
          "limit": "922337203685.4775"
        }
        ],
        "memo": {
        	"type": 0
        }
    }

We probably should document this better or add more checks into connect.

I'll look into the second one soon.

@tsusanka
Copy link
Contributor

For the second one there is a tiny bug in connect probably where the signer field is required. You can get around it easily by providing an empty signer. This passes okay then:

{
  "source": "GDNAQREX5VOHMYZ2QDHDY6A7XR2OYIE67EETL5MFCT6TCGHYA7YHACEW",
  "fee": 100,
  "sequence": "89703140756029442",
  "operations": [
    {
      "type": "setOptions",
      "inflationDest": "GCCD6AJOYZCUAQLX32ZJF2MKFFAUJ53PVCFQI3RHWKL3V47QYE2BNAUT",
      "signer": ""
    }
  ],
  "memo": {
    "type": 0
  }
}

@tsusanka
Copy link
Contributor

I've created issue in connect trezor/connect#265 . Please be patient, this is a low-priority bug.

I'm closing here.

@istrau2
Copy link
Author

istrau2 commented Nov 22, 2018

@tsusanka

I tried your solution:

In the first transaction you are not specifying the asset's type. You need to provide the type field and set it to 1 if it is 4-character maximum or 2 for 12-characters maximum, see Stellar's doc for more info.

which does indeed allow the trezor to complete the signing of the operation successfully. However, the trezor returns an invalid signature. The stellar network rejects the transaction when submitted with the error that signature is invalid.

@tsusanka
Copy link
Contributor

Hm, what happens if you provide a valid value for signer? So the signer is not an empty string, but something valid

@istrau2
Copy link
Author

istrau2 commented Nov 22, 2018

@tsusanka The issue isn't with that solution. Adding the signer worked fine. I am referring to the changeTrust operation where I had to make op.line.type = 1 or 2.

@tsusanka
Copy link
Contributor

Oh my bad, sorry. I've created a new issue and I'll look into this: #421

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants