Internal
Summary
TxSignedShelley transactions with TxOut's containing negative Coin values are perfectly serialisable and transmissible using the cardano-api -- only to be failing to deserialise in a most cryptic manner:
ApiErrorCBOR (DecoderErrorDeserialiseFailure \"TxSigned\" (DeserialiseFailure 80 \"expected word\"))
This can be observed locally, by using a Tx with negative coin values and performing a ser/des roundtrip: txSignedFromCBOR . txSignedToCBOR.
A Shown transaction, as well as it's CBOR-ised forms are attached.
cardano-api commit id is exactly 1.13.0: 9925ef37dccbe7f423f3ceb81a5e1da3d924393b.
Additional context
I think any attempt to encode a negative amount in a transaction should be rejected by the API as an error. In fact, not even at the API level, but in ledger-specs.
We can do this validation step in the cardano-api tx construction, as part of the other sanity checks we have to do there (like Byron txs having the same number of witnesses as inputs).
But doesn't that sanity check belong in legder-specs ?
{"at":"2020-06-21T23:36:38.53Z","env":"1.13.0:25efa","ns":["cardano.node.ChainDB"],"data":{"snapshot":{"snapshot":"DiskSnapshot 84","kind":"snapshot"},"kind":"TraceLedgerEvent.InvalidSnapshot","failure":"InitFailureRead (ReadFailed (DeserialiseFailure 334 \"An error occured while decoding Negative Coin.\nError: -2970552586033663663\"))"},"app":[],"msg":"","pid":"21865","loc":null,"host":"myserver","sev":"Error","thread":"33"}
{"at":"2020-06-21T23:36:38.54Z","env":"1.13.0:25efa","ns":["cardano.node.ChainDB"],"data":{"snapshot":{"snapshot":"DiskSnapshot 83","kind":"snapshot"},"kind":"TraceLedgerEvent.InvalidSnapshot","failure":"InitFailureRead (ReadFailed (DeserialiseFailure 334 \"An error occured while decoding Negative Coin.\nError: -2970247507364504374\"))"},"app":[],"msg":"","pid":"21865","loc":null,"host":"myserver","sev":"Error","thread":"33"}
Are the above errors related to/caused by this same issue?
{"at":"2020-06-21T23:36:38.53Z","env":"1.13.0:25efa","ns":["cardano.node.ChainDB"],"data":{"snapshot":{"snapshot":"DiskSnapshot 84","kind":"snapshot"},"kind":"TraceLedgerEvent.InvalidSnapshot","failure":"InitFailureRead (ReadFailed (DeserialiseFailure 334 "An error occured while decoding Negative Coin.\nError: -2970552586033663663"))"},"app":[],"msg":"","pid":"21865","loc":null,"host":"myserver","sev":"Error","thread":"33"}
{"at":"2020-06-21T23:36:38.54Z","env":"1.13.0:25efa","ns":["cardano.node.ChainDB"],"data":{"snapshot":{"snapshot":"DiskSnapshot 83","kind":"snapshot"},"kind":"TraceLedgerEvent.InvalidSnapshot","failure":"InitFailureRead (ReadFailed (DeserialiseFailure 334 "An error occured while decoding Negative Coin.\nError: -2970247507364504374"))"},"app":[],"msg":"","pid":"21865","loc":null,"host":"myserver","sev":"Error","thread":"33"}Are the above errors related to/caused by this same issue?
Indeed. (See https://github.com/input-output-hk/cardano-node/issues/1312#issuecomment-647329374)
Most helpful comment
But doesn't that sanity check belong in
legder-specs?