我正在学习如何使用cardano-rosetta
,我想让send-transaction-example.ts
脚本使用我事先派生的地址。地址是使用cardano-addresses
工具导出的,然后我将其转换为Uint8数组。这是因为我们需要派生出未来可能使用的一批地址。
交易是构建和签署的,似乎没有任何问题。服务器日志如下。但是,交易被拒绝。API的响应不是很有描述性,我只得到500个错误,但服务器日志如下。问题似乎是这样的:
[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":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 1097911063nShelley 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 transactionn 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:46n 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}
要使用send-transaction-example.ts
和cardano-address
执行发送事务,只需为您希望使用的UTXO生成正确的私钥,然后使用该私钥编辑.ts脚本即可。
从助记符短语中,做:
$ 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
其中CCD_ 6对应于您希望从中消费的所需密钥对/UTXO。
然后,运行
$ cardano-address key inspect < utxo.prv
{
"chain_code": "cd3aca54d3b1f34613d9f54224a1a6d2369e4f3cfb8d67ae342b33ee3692dffb",
"key_type": "private",
"extended_key": "084dd7af554b9c8c7e5a777dc528ed570cfd36db32bc2be359cc208dc947a94333daaf32256a61be975d1f7908a50ebfae96459309906f7ec40b1969450137bd"
}
并将send-transaction-example.ts
中的PRIVATE_KEY
替换为上述extended_key
值:
const PRIVATE_KEY =
"084dd7af554b9c8c7e5a777dc528ed570cfd36db32bc2be359cc208dc947a94333daaf32256a61be975d1f7908a50ebfae96459309906f7ec40b1969450137bd";
并运行脚本。