Version
Show / Hide Table of Contents

sendrawtransaction 方法

广播交易。

参数说明

hex:在程序中构造的已签名的交易序列化后的 16 进制字符串。

调用示例

请求正文:

{
  "jsonrpc": "2.0",
  "method": "sendrawtransaction",
  "params": ["80000001195876cb34364dc38b730077156c6bc3a7fc570044a66fbfeeea56f71327e8ab0000029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500c65eaf440000000f9a23e06f74cf86b8827a9108ec2e0f89ad956c9b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50092e14b5e00000030aab52ad93f6ce17ca07fa88fc191828c58cb71014140915467ecd359684b2dc358024ca750609591aa731a0b309c7fb3cab5cd0836ad3992aa0a24da431f43b68883ea5651d548feb6bd3c8e16376e6e426f91f84c58232103322f35c7819267e721335948d385fae5be66e7ba8c748ac15467dcca0693692dac"],
  "id": 1
}

成功的响应正文:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}

失败的响应正文:

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -501,
        "message": "Block or transaction already exists and cannot be sent repeatedly."
    }
}

响应说明:

当 result 为 true 时表明当前交易广播成功,

当 result 为 false 时表示当前交易广播失败,原因可能有双重花费、签名不完整等。

本示例中广播了一个已经确认的交易,因为双重花费所以广播失败。可能会遇到以下错误码:

错误码消息
-501Block or transaction already exists and cannot be sent repeatedly.
-502The memory pool is full and no more transactions can be sent.
-503The block cannot be validated.
-504Block or transaction validation failed.
-505One of the Policy filters failed.
-500Unknown error.