1

I'm learning how to use cardano-rosetta and I'd like to make the send-transaction-example.ts script work with addresses that I've derived beforehand. The addresses have been derived using the cardano-addresses tool, which I then convert to Uint8 arrays. This is because we need to derive batches of addresses that may be used in future.

The transaction is constructed and signed, seemingly without any issue. The server log is below. However, the transaction is rejected. The API response isn't very descriptive, I get only a 500 error, but the server log is below. The issue seems to be in this line:

[53047783:cardano.node.Mempool:Info:38002] [2021-03-30 15:55:43.90 UTC] fromList [("tx",Object (fromList [("txid",String "txid: TxId {_unTxId = \"831f0e898a7d6653149bf2f6fc6ea7b482deb04f49251a1edd612051f42617b2\"}")])),("kind",String "TraceMempoolRejectedTx"),("mempoolSize",Object (fromList [("numTxs",Number 0.0),("bytes",Number 0.0)])),("err",Object (fromList [("kind",String "InvalidWitnessesUTXOW"),("invalidWitnesses",Array [String "VKey (VerKeyEd25519DSIGN (PublicKey \"\\158\\238W\\128\\184$:E\\231\\FSa\\152I$\\EM\\b\\134\\CAN\\140\\157N\\154\\238r\\EOT\\173\\204\\172c4cr\"))"])]))]

I don't know why the witness is invalid. could anyone help?

{"level":30,"time":1617119743744,"pid":106,"hostname":"530477839db5","reqId":1392,"msg":"[constructionCombine] Request received to sign a transaction","v":1}
{"level":30,"time":1617119743745,"pid":106,"hostname":"530477839db5","reqId":1392,"msg":"[buildTransaction] About to signed a transaction with 1 signatures","v":1}
{"level":30,"time":1617119743745,"pid":106,"hostname":"530477839db5","reqId":1392,"msg":"[getWitnessesForTransaction] Extracting witnesses from signatures","v":1}
{"level":30,"time":1617119743745,"pid":106,"hostname":"530477839db5","reqId":1392,"msg":"[getWitnessesForTransaction] 1 witnesses were extracted to sign transaction","v":1}
{"level":30,"time":1617119743745,"pid":106,"hostname":"530477839db5","reqId":1392,"msg":"[buildTransaction] Instantiating transaction body from unsigned transaction bytes","v":1}
{"level":30,"time":1617119743745,"pid":106,"hostname":"530477839db5","reqId":1392,"msg":"[buildTransaction] Creating transaction using transaction body and extracted witnesses","v":1}
{"level":30,"time":1617119743745,"pid":106,"hostname":"530477839db5","reqId":1392,"signedTransaction":"83a400818258204bc397faa17b5f7972cfd6acf2729eb950b5756c8ea2f704ec8ef11d8a3718fb000181825839000c6d3e4ad14b5ac97656fe56cae3d46e4474af25f6f4d25268b8a168474ac229ab36f3ebb93da86e068f35f5a64bcc0e4ed40cc295fca2df1a389fd980021a02faf080031a015b291ba100818258209eee5780b8243a45e71c61984924190886188c9d4e9aee7204adccac633463725840b2e842c390b4142c46e9d08dd5fc366cb37fc960ab48bdeb083134d79858928775e8304f8c25a5cd5d531f9fd7579188fdb659a27e8f418c12a6aada0fda7600f6","msg":"[constructionCombine] About to return signed transaction","v":1}
{"level":30,"time":1617119743747,"pid":106,"hostname":"530477839db5","reqId":1392,"res":{"statusCode":200},"responseTime":3.006010055541992,"msg":"request completed","v":1}
{"level":30,"time":1617119743887,"pid":106,"hostname":"530477839db5","reqId":1393,"req":{"method":"POST","url":"/construction/submit","hostname":"35.214.159.230:8080","remoteAddress":"84.247.50.48","remotePort":55196},"msg":"incoming request","v":1}
{"level":30,"time":1617119743888,"pid":106,"hostname":"530477839db5","reqId":1393,"msg":"[constructionSubmit] About to submit 83a400818258204bc397faa17b5f7972cfd6acf2729eb950b5756c8ea2f704ec8ef11d8a3718fb000181825839000c6d3e4ad14b5ac97656fe56cae3d46e4474af25f6f4d25268b8a168474ac229ab36f3ebb93da86e068f35f5a64bcc0e4ed40cc295fca2df1a389fd980021a02faf080031a015b291ba100818258209eee5780b8243a45e71c61984924190886188c9d4e9aee7204adccac633463725840b2e842c390b4142c46e9d08dd5fc366cb37fc960ab48bdeb083134d79858928775e8304f8c25a5cd5d531f9fd7579188fdb659a27e8f418c12a6aada0fda7600f6","v":1}
[53047783:cardano.node.Mempool:Info:38002] [2021-03-30 15:55:43.90 UTC] fromList [("tx",Object (fromList [("txid",String "txid: TxId {_unTxId = \"831f0e898a7d6653149bf2f6fc6ea7b482deb04f49251a1edd612051f42617b2\"}")])),("kind",String "TraceMempoolRejectedTx"),("mempoolSize",Object (fromList [("numTxs",Number 0.0),("bytes",Number 0.0)])),("err",Object (fromList [("kind",String "InvalidWitnessesUTXOW"),("invalidWitnesses",Array [String "VKey (VerKeyEd25519DSIGN (PublicKey \"\\158\\238W\\128\\184$:E\\231\\FSa\\152I$\\EM\\b\\134\\CAN\\140\\157N\\154\\238r\\EOT\\173\\204\\172c4cr\"))"])]))]
{"level":50,"time":1617119743909,"pid":106,"hostname":"530477839db5","reqId":1393,"shortMessage":"Command failed with exit code 1: /usr/local/bin/cardano-cli transaction submit --tx-file /tmp/6edd9e54-ea83-420c-b5b8-c0c2ea722dc6 --testnet-magic 1097911063","command":"/usr/local/bin/cardano-cli transaction submit --tx-file /tmp/6edd9e54-ea83-420c-b5b8-c0c2ea722dc6 --testnet-magic 1097911063","exitCode":1,"stdout":"","stderr":"Shelley command failed: transaction submit  Error: Error while submitting tx: ApplyTxError [LedgerFailure (UtxowFailure (InvalidWitnessesUTXOW [VKey (VerKeyEd25519DSIGN (PublicKey \"\\158\\238W\\128\\184$:E\\231\\FSa\\152I$\\EM\\b\\134\\CAN\\140\\157N\\154\\238r\\EOT\\173\\204\\172c4cr\"))]))]","failed":true,"timedOut":false,"isCanceled":false,"killed":false,"msg":"[submitTransaction] Command failed","stack":"Error: Command failed with exit code 1: /usr/local/bin/cardano-cli transaction submit --tx-file /tmp/6edd9e54-ea83-420c-b5b8-c0c2ea722dc6 --testnet-magic 1097911063\nShelley command failed: transaction submit  Error: Error while submitting tx: ApplyTxError [LedgerFailure (UtxowFailure (InvalidWitnessesUTXOW [VKey (VerKeyEd25519DSIGN (PublicKey \"\\158\\238W\\128\\184$:E\\231\\FSa\\152I$\\EM\\b\\134\\CAN\\140\\157N\\154\\238r\\EOT\\173\\204\\172c4cr\"))]))]\n    at makeError (/cardano-rosetta-server/node_modules/execa/lib/error.js:59:11)\n    at handlePromise (/cardano-rosetta-server/node_modules/execa/index.js:114:26)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)","type":"Error","v":1}
{"level":50,"time":1617119743910,"pid":106,"hostname":"530477839db5","reqId":1393,"msg":"Shelley command failed: transaction submit  Error: Error while submitting tx: ApplyTxError [LedgerFailure (UtxowFailure (InvalidWitnessesUTXOW [VKey (VerKeyEd25519DSIGN (PublicKey \"\\158\\238W\\128\\184$:E\\231\\FSa\\152I$\\EM\\b\\134\\CAN\\140\\157N\\154\\238r\\EOT\\173\\204\\172c4cr\"))]))]","stack":"Error: Shelley command failed: transaction submit  Error: Error while submitting tx: ApplyTxError [LedgerFailure (UtxowFailure (InvalidWitnessesUTXOW [VKey (VerKeyEd25519DSIGN (PublicKey \"\\158\\238W\\128\\184$:E\\231\\FSa\\152I$\\EM\\b\\134\\CAN\\140\\157N\\154\\238r\\EOT\\173\\204\\172c4cr\"))]))]\n    at Object.<anonymous> (/cardano-rosetta-server/dist/src/server/utils/cardano/cli/cardanonode-cli.js:60:31)\n    at Generator.throw (<anonymous>)\n    at rejected (/cardano-rosetta-server/dist/src/server/utils/cardano/cli/cardanonode-cli.js:6:65)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)","type":"Error","v":1}
{"level":50,"time":1617119743910,"pid":106,"hostname":"530477839db5","reqId":1393,"code":5006,"retriable":true,"details":{"message":"Shelley command failed: transaction submit  Error: Error while submitting tx: ApplyTxError [LedgerFailure (UtxowFailure (InvalidWitnessesUTXOW [VKey (VerKeyEd25519DSIGN (PublicKey \"\\158\\238W\\128\\184$:E\\231\\FSa\\152I$\\EM\\b\\134\\CAN\\140\\157N\\154\\238r\\EOT\\173\\204\\172c4cr\"))]))]"},"msg":"[errorHandler] An error ocurred and will be sent as response","stack":"Error: Error when sending the transaction\n    at Object.exports.buildApiError (/cardano-rosetta-server/dist/src/server/utils/errors.js:86:56)\n    at Object.sendTransactionError (/cardano-rosetta-server/dist/src/server/utils/errors.js:108:51)\n    at /cardano-rosetta-server/dist/src/server/controllers/construction-controller.js:170:46\n    at Generator.throw (<anonymous>)\n    at rejected (/cardano-rosetta-server/dist/src/server/controllers/construction-controller.js:6:65)","type":"Error","v":1}
{"level":30,"time":1617119743911,"pid":106,"hostname":"530477839db5","reqId":1393,"res":{"statusCode":500},"responseTime":23.158724784851074,"msg":"request completed","v":1}

John
  • 949
  • 1
  • 9
  • 20

1 Answers1

3

To perform a send transaction using send-transaction-example.ts and cardano-address, it is enough to generate the correct private key for the UTXO you wish to spend from, and then edit the .ts script with this private key.

From a mnemonic phrase, do:

$ cat phrase.prv
exercise club noble adult miracle awkward problem olympic puppy private goddess piano fatal fashion vacuum

$ cardano-address key from-recovery-phrase Shelley < phrase.prv | tee root.xsk
root_xsk1hqzfzrgskgnpwskxxrv5khs7ess82ecy8za9l5ef7e0afd2849p3zryje8chk39nxtva0sww5me3pzkej4rvd5cae3q3v8eu7556n6pdrp4fdu8nsglynpmcppxxvfdyzdz5gfq3fefjepxhvqspmuyvmvqg8983

$ cardano-address key child 1852H/1815H/0H/0/0 < root.xsk | tee utxo.prv
addr_xsk1ppxa0t64fwwgclj6wa7u228d2ux06dkmx27zhc6eessgmj2849pn8k40xgjk5cd7jaw377gg558tlt5kgkfsnyr00mzqkxtfg5qn00wd8t99f5a37drp8k04ggj2rfkjx60y708m34n6udptx0hrdykllv9n5zcs

where 1852H/1815H/0H/0/0 corresponds to the desired keypair/UTXO that you wish to spend from.

Then, run

$ cardano-address key inspect < utxo.prv                                                                                     
{
    "chain_code": "cd3aca54d3b1f34613d9f54224a1a6d2369e4f3cfb8d67ae342b33ee3692dffb",
    "key_type": "private",
    "extended_key": "084dd7af554b9c8c7e5a777dc528ed570cfd36db32bc2be359cc208dc947a94333daaf32256a61be975d1f7908a50ebfae96459309906f7ec40b1969450137bd"
}

and replace the PRIVATE_KEY in send-transaction-example.ts, with the extended_key value above:

const PRIVATE_KEY =
  "084dd7af554b9c8c7e5a777dc528ed570cfd36db32bc2be359cc208dc947a94333daaf32256a61be975d1f7908a50ebfae96459309906f7ec40b1969450137bd";

and run the script.

soccer193
  • 413
  • 2
  • 7
  • Thanks for your help, the problem is partly solved. Cardano-rosetta will use the extended_key as the private key and derive the public key from it (simply the second half of the string). It can then call the `/construction/derive` endpoint with this public key to get a payment address. This payment address is different to the payment address derived using cardano-addresses. If I use the payment address derived using cardano-addresses rosetta gives an UtxowFailure (InvalidWitnessesUTXOW ..) error. How can I derive offline the same payment address that cardano-rosetta will derive? – John Apr 07 '21 at 15:36
  • The address generated by send-transaction-example.ts should match the output of `cat utxo.prv | cardano-address key public --with-chain-code | cardano-address address payment --network-tag testnet`. – soccer193 Apr 08 '21 at 03:03
  • Perhaps its because cardano-rosetta is returning an enterprise address and cardano-addresses is returning some other type. – John Apr 08 '21 at 20:02