2022年2月

应网友要求,此法可用于relay上。下文为实现流水账,文末有参考的 win/macos上实现方法

0.前置要求

需要有个正常编译且运行中同步良好的 cardano-node, 有当前最新released版本的 cardano-submit-api
本例路径在 ~/.cabel/bin/cardano-submit-api

1.下载配置文件

cd $CNODE_HOME/files
wget https://raw.githubusercontent.com/input-output-hk/cardano-node/master/cardano-submit-api/config/tx-submit-mainnet-config.yaml

貌似在linux cnode中,参数可直接为节点的 config.json ,未验证

2. 启动API服务

对应修改各参数, 端口默认为 8090

"${HOME}"/.cabal/bin/cardano-submit-api --mainnet \
 --config "${CONFIG}"  \ 
 --socket-path "${CARDANO_NODE_SOCKET_PATH}" \ 
 --listen-address ${HOSTADDR} \ 
 --port ${HOSTPORT}

启动后见提示

[cardano-tx-submit:Info:12] [2022-02-13 19:43:43.35 UTC] Running server on 192.168.0.86:8090

为方便执行和监控,后续会把上述启动命令写进 nohup 作为一个启动脚本

3. 验证API,配置完成

本地节点IP为 192.168.0.86 , 已检查过防火墙部分

http://192.168.0.86:8090/api/submit/tx

postman 测试得到正确响应
(方式:post, header添加参数 Content-Type: application/cbor)

"transaction read error RawCborDecodeError [DecoderErrorDeserialiseFailure \"Byron Tx\" (DeserialiseFailure 0 \"end of input\"),DecoderErrorDeserialiseFailure \"Shelley Tx\" (DeserialiseFailure 0 \"end of input\"),DecoderErrorDeserialiseFailure \"Shelley Tx\" (DeserialiseFailure 0 \"end of input\"),DecoderErrorDeserialiseFailure \"Shelley Tx\" (DeserialiseFailure 0 \"end of input\"),DecoderErrorDeserialiseFailure \"Shelley Tx\" (DeserialiseFailure 0 \"end of input\")]"

如何配置wallet部分略过;

题外话,截止至 1.33.1 cntools 自带的 scripts 内有一名叫 submitapi.sh 的脚本, 简单阅读内容发现正是实现上文相同功能的,而且做了注册为系统服务的功能,不过脚本并不完备且最后执行参数是在 testnet下,看来是实验中的东西未正式普及。


参考文:

https://cardanode.com.au/reducing-transaction-connecting-nami-to-daedalus/