我正在尝试cardano-cli
使用cardano-wallet
端点提交已签名的 tx:https://localhost:8090/v2/proxy/transactions
签署的交易如下所示:
txBody = {
"type": "Tx MaryEra",
"description": "",
"cborHex": "83a400818258202d7928a59fcba5bf71c40fe6428a301ffda4d2fa681e5357051970436462b89400018282583900c0e88694ab569f42453eb950fb4ec14cb50f4d5d26ac83fdec2c505d818bcebf1df51c84239805b8a330d68fdbc3c047c12bb4c3172cb9391a002b335f825839003d2d9ceb1a47bc1b62b7498ca496b16a7b4bbcc6d97ede81ba8621ebd6d947875fcf4845ef3a5f08dd5522581cf6de7b9c065379cbb3754d1a001e8480021a00029361031a01672b7ea1008182582073dd733cc50d594cb89d3ac67287b02dae00982fc800e9c9c9d1bb282b56122558404d0cb4e4f1cc415ddcf546871f075d0ca6e0c2620cd784b06c21c9b86e4403cb7a115038487576dcb20e7820e9d0dc93ab2a737ed9d0a71a77bc1e12f7c4dd0ef6"
}
我只是不知道如何使用 Content-Type 将其传递给端点application/octet-stream
。API 文档说有效载荷应该是:
string <binary>
Signed transaction message binary blob.
我为此使用了javascript,并尝试cborHex
直接传递,使用Buffer.from(txBody.cborHex).toString('base64')
和整个json Buffer.from(JSON.stringify(txBody)).toString('base64')
,但总是得到相同的响应:
{
"code": "malformed_tx_payload",
"message": "I couldn't verify that the payload has the c…node. Please check the format and try again."
}
此外,我从 swagger 规范中注意到端点支持 JSON 有效负载,并在此处查看cardano-wallet
源代码:
newtype PostExternalTransactionData = PostExternalTransactionData
{ payload :: ByteString
} deriving (Eq, Generic, Show)
我认为结构应该是这样的:
{
"payload": ?// some binary blob here that I can't find. I've tried with:
// Buffer.from(txBody.cborHex).toString('base64') and
// Buffer.from(JSON.stringify(txBody)).toString('base64')
}
知道如何构建有效负载并传递签名的 tx 吗?