交易相关 API


submitsendtx

多币种转账,支持WICC、WUSD、WGRT、WRC30等币种

Parameters

from 发送方地址

to 接收方地址

symbol:coin:unit 发送币种:发送金额:金额单位 至少10000 sawi

symbol:fee:unit 手续费币种(仅支持WICCWUSD中的一种):手续费金额:手续费单位

memo (string, optional) 备注,备注信息将会上链

Returns

hash 交易哈希

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "submitsendtx", "params": ["wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4", "wNDue1jHcgRSioSDL4o1AzXz3D72gCMkP6", "WICC:10000:sawi", "WICC:1000000:sawi", "Hello, WaykiChain!"] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "txid": "0ec855aeec4b06c660fd6e1ec2b2302061f22c3fe9986c2d54b7b9b137fc594c"
    },
    "error": null,
    "id": "curltest"
}

submittxraw

将交易签名数据广播至区块链

Parameters

rawtx 已创建的交易签名字段

Returns

hash 交易哈希

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc":"2.0","id":"curltext","method":"submittxraw","params":["030192af0f020008146902285df4bba1d69952f3f9e5b071ed3e4e8df4cd10aed6c1000046304402204d3ac6de164f4bdfa65075e54bcd32161fa0ae3745d7b0e3e5da7f79ec17b45802206dd239adbbe5b3cc66adbb138505327036e111283c15e046b1b5fce5d52aa295"]}' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
  "result":
  {
    "hash":"72a9ac4e3adb1ad93f7d6da59e61d9bf22918db17c4320555782fdcfe68899f8"
  },
  "error":null,
  "id":"curltext"
}


gettxdetail

根据交易哈希查询交易详情,包括已确认和未确认的交易

Parameters

txhash 交易哈希

Returns

txid 交易哈希,交易的唯一标识

tx_type 交易类型,交易所和钱包方可根据右边的交易类型列表做扫链

ver 区块版本号

tx_uid 交易发起方的regid /nickid/ 公钥

from_addr 交易发起方的地址

fee_symbol 交易所用手续费的币种,仅支持WICCWUSD中的一种

fees 手续费,单位为sawi

valid_height 创建交易时的有效高度

signature 签名字段

transfers 交易接收方列表

`to_uid`  交易接收方的regid /nickid/ 公钥
`to_addr` 交易接收方的地址
`coin_symbol` 交易的币种,支持多币种
`coin_amount` 交易得金额 ,单位为`sawi`

memo 备注信息

confirmations 交易确认数 ,=当前链上高度 - 交易被确认的区块高度

confirmed_height 交易被确认的区块高度 ,交易未被确认时无此字段

confirmed_time 交易被确认的时间戳,交易未被确认时无此字段

block_hash 交易被确认的所在区块哈希值,交易未被确认时无此字段

receipt 交易产生的相关收据,交易未被确认时无此字段

rawtx 原始交易信息

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc":"2.0","id":"curltext","method":"gettxdetail","params":["3946f8a88e2cfbee016761251237e2e19c6b6fa58a3b380ba5d6b0d480d0c6e7"]}' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "txid" : "86d86270cb82acc426f9a7b7b7c6374a5289ff53384085b850aefa15a8adad3a",
        "tx_type" : "UCOIN_TRANSFER_TX",
        "ver" : 1,
        "tx_uid" : "0-1",
        "from_addr" : "wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4",
        "fee_symbol" : "WICC",
        "fees" : 1000000,
        "valid_height" : 86668,
        "signature" : "304402205a56a3f9e3e3cf9bd49f1a991ea141fe2fa006cd41ae684a403b686d5baf5e38022078d442174868cd6b464caaaaefa6f017023da8059c4051edde32258bf64e0ea9",
        "transfers" : [
            {
                "to_uid" : "0-2",
                "to_addr" : "wNDue1jHcgRSioSDL4o1AzXz3D72gCMkP6",
                "coin_symbol" : "WICC",
                "coin_amount" : 100000000
            }
        ],
        "memo" : "",
        "confirmations" : 3,
        "confirmed_height" : 86670,
        "confirmed_time" : 1568857718,
        "block_hash" : "9faa48a2e4711aebdefb04b5a72649fa7907610b2f784e6b652e463315099647",
        "receipt" : [
        ],
        "rawtx" : "0b0184a40c0200010457494343cd10010200020457494343aed6c1000046304402205a56a3f9e3e3cf9bd49f1a991ea141fe2fa006cd41ae684a403b686d5baf5e38022078d442174868cd6b464caaaaefa6f017023da8059c4051edde32258bf64e0ea9"
    },
    "error": null,
    "id": "curltest"
}

listtx

获取当前节点交易列表:包含已确认和未确认的交易

Parameters

none

Returns

confirmed_tx 已确认的交易哈希列表

unconfirmed_tx 未确认的交易哈希列表

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc":"2.0","id":"curltext","method":"listtx","params":[]}' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "confirmed_tx": [
            "25751af37271979faba87fbcbb773ee15ce55978a8f99de395161fa7659972c4",
            "0ec855aeec4b06c660fd6e1ec2b2302061f22c3fe9986c2d54b7b9b137fc594c",
            "dc3ef43ea4e7808914be324a9a7f694965af3039af5640ccda8ddee3726d01e9",
            "1b42f7e31d25c4c6848edec7569667789dbfd5e03b50ae540dde8466a91663a7",
            "fb63f24b14c4a94d656d1a66fd147f9e3b504c4f597cd60d88aa3ebc059d0c6e",
            "af29ddcb14a85b62d2dfbbc43da5b92670ee17b790092be9cef07c5821add646",
            "eaf495ede5742cf4b1bf4f579f923cf5e348e5998766938d56efc8509df76fa9",
            "3946f8a88e2cfbee016761251237e2e19c6b6fa58a3b380ba5d6b0d480d0c6e7",
            "fc0815e250da533110f0c1b4a339855f38cee8ac1c467c68d01c248d8b716776",
            "2feb411e819ca3d93600a1a5dba45a7881fbb4c1a669921fd47d97bc1ab4fe02"
        ],
        "unconfirmed_tx": []
    },
    "error": null,
    "id": "curltext"
}

decodetxraw

根据签名字段解析原始交易单

Parameters

rawtx 签名后的原始交易单

Returns

txid 交易哈希

tx_type 交易类型

ver 版本号

tx_uid 交易发起方的regid /nickid/ 公钥

from_addr 交易发起方的地址

fee_symbol 交易所用手续费的币种,仅支持WICCWUSD中的一种

fees 手续费金额 单位为sawi

valid_height 有效高度

signature 签名内容

transfers 交易接收方列表

`to_uid`  交易接收方的regid /nickid/ 公钥
`to_addr` 交易接收方的地址
`coin_symbol` 交易的币种,支持多币种
`coin_amount` 交易得金额 ,单位为`sawi`

memo (hex) 备注

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "decodetxraw", "params": ["0b0184a40c0200010457494343cd10010200020457494343aed6c1000046304402205a56a3f9e3e3cf9bd49f1a991ea141fe2fa006cd41ae684a403b686d5baf5e38022078d442174868cd6b464caaaaefa6f017023da8059c4051edde32258bf64e0ea9"] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "txid" : "86d86270cb82acc426f9a7b7b7c6374a5289ff53384085b850aefa15a8adad3a",
        "tx_type" : "UCOIN_TRANSFER_TX",
        "ver" : 1,
        "tx_uid" : "0-1",
        "from_addr" : "wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4",
        "fee_symbol" : "WICC",
        "fees" : 1000000,
        "valid_height" : 86668,
        "signature" : "304402205a56a3f9e3e3cf9bd49f1a991ea141fe2fa006cd41ae684a403b686d5baf5e38022078d442174868cd6b464caaaaefa6f017023da8059c4051edde32258bf64e0ea9",
        "transfers" : [
            {
                "to_uid" : "0-2",
                "to_addr" : "wNDue1jHcgRSioSDL4o1AzXz3D72gCMkP6",
                "coin_symbol" : "WICC",
                "coin_amount" : 100000000
            }
        ],
        "memo" : ""
    },
    "error": null,
    "id": "curltest"
}

创建多重签名转账交易

1. 使用createmulsig 生成多签地址与脚本

Parameters

num_signatures 要求签名的地址个数

keys 多签地址列表

Returns

addr 多签地址

script 多签脚本

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0","id": "curltest","method": "createmulsig","params": [2,["wNDue1jHcgRSioSDL4o1AzXz3D72gCMkP6","wNuJM44FPC5NxearNLP98pg295VqP7hsqu","wP64X59EoRmeq2M5GrJ23UVttE9uxnuoFa"]]}' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "addr": "wgssS9uNcEBEgbYfwexTb5zGgY7jppmsuK",
        "script": "020321025a37cb6ec9f63bb17e562865e006f0bafa9afbd8a846bd87fc8ff9e35db1252e210376de6a21f63c35a053c849a339598016a0261d6bdc5567adeda0af78b750c4cc2103f52925f191c77bb1d16b19387bcfcb83380f1622d643a11038cf4867c4578696"
    },
    "error": null,
    "id": "curltest"
}

2. 向多签地址转账 1000 WICC

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "submitsendtx", "params": ["wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4", "wgssS9uNcEBEgbYfwexTb5zGgY7jppmsuK", "WICC:1000:wi", "WICC:1000000:sawi", "Hello, WaykiChain!"] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "txid": "0ec855aeec4b06c660fd6e1ec2b2302061f22c3fe9986c2d54b7b9b137fc594c"
    },
    "error": null,
    "id": "curltest"
}

3. 区块确认后,查询多签地址余额

// Request
curl -u Waykichain:admin -d '{"jsonrpc":"2.0","id":"curltext","method":"getaccountinfo","params":["wgssS9uNcEBEgbYfwexTb5zGgY7jppmsuK"]}' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "address": "wgssS9uNcEBEgbYfwexTb5zGgY7jppmsuK",
        "keyid": "4acedbdda642eed93e203113534f976ef85ee5dd",
        "nickid": "",
        "regid": "22415-2",
        "regid_mature": true,
        "owner_pubkey": "033f7fa29a83a8ad46c0d52caa3b2e271e24e71f7d8cf328471d759f71ca5e4e2c",
        "miner_pubkey": "",
        "tokens": {
            "WICC": {
                "free_amount": 100000000000,
                "staked_amount": 0,
                "frozen_amount": 0,
                "voted_amount": 0
            }
        },
        "received_votes": 0,
        "vote_list": [],
        "position": "inblock",
        "cdp_list": [
        ]
    },
    "error": null,
    "id": "curltext"
}

4. 使用 genmulsigtx 创建转账多签的原生rawtx

Parameters

multisigscript 第一步中的生成的多签脚本

to 转账接收者地址

symbol:coin:unit 转账币种金额单位

symbol:fee:unit 手续费币种金额单位

Returns

rawtx 原生rawtx

ExamplewgcSFDbJpJoPJ2DgejEoWDD3iw1ezE8Mbv转账 1 WICC

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "genmulsigtx", "params": ["020321025a37cb6ec9f63bb17e562865e006f0bafa9afbd8a846bd87fc8ff9e35db1252e210376de6a21f63c35a053c849a339598016a0261d6bdc5567adeda0af78b750c4cc2103f52925f191c77bb1d16b19387bcfcb83380f1622d643a11038cf4867c4578696", "wgcSFDbJpJoPJ2DgejEoWDD3iw1ezE8Mbv", "WICC:100000000:sawi", "WICC:10000000:sawi"] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "rawtx": "0701949912045749434383e1ac000103ab25020457494343aed6c100000203000300000200000400"
    },
    "error": null,
    "id": "curltest"
}

5. 使用signtxraw 对原生rawtx进行签名

Parameters

str 上一步生成的 rawtx

addr 参与签名的地址列表

Returns

rawtx 签名后的rawtx

Example

wgcSFDbJpJoPJ2DgejEoWDD3iw1ezE8Mbv转账 1 WICC,任选2个参与签名的地址

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "signtxraw", "params": ["0701949912045749434383e1ac000103ab25020457494343aed6c100000203000300000200000400", ["wNDue1jHcgRSioSDL4o1AzXz3D72gCMkP6", "wNuJM44FPC5NxearNLP98pg295VqP7hsqu"]] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "rawtx": "0701949912045749434383e1ac000103ab25020457494343aed6c100000203000346304402206cb6c22f0a3e4785488718874816ae797290aa9a18f096f783fdf5b4e3da89bc022033f8a8f59b815dc3d650638f77694d9a67e382e71c61501bcae621383e7588950002463044022047635f54e9cc87c82437474b781b323c891cb1ece18c1df5ef90a5f8cfee98bd0220342e47e610233108bd4f5e25b83a0ce6d636ecb26ab23b84d1bdfa51d00d9391000400"
    },
    "error": null,
    "id": "curltest"
}

6. 广播rawtx之前进行签名解析确认无误

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "decodetxraw", "params": ["0701949912045749434383e1ac000103ab25020457494343aed6c100000203000346304402206cb6c22f0a3e4785488718874816ae797290aa9a18f096f783fdf5b4e3da89bc022033f8a8f59b815dc3d650638f77694d9a67e382e71c61501bcae621383e7588950002463044022047635f54e9cc87c82437474b781b323c891cb1ece18c1df5ef90a5f8cfee98bd0220342e47e610233108bd4f5e25b83a0ce6d636ecb26ab23b84d1bdfa51d00d9391000400"] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "txid": "377c251bb8b9c4cf0771b3015472385cc5edc6f3b3dd71fd2b872067f2f68593",
        "tx_type": "UCOIN_TRANSFER_MTX",
        "ver": 1,
        "required_sigs": 2,
        "signatures": [
            {
                "regid": "0-3",
                "signature": "304402206cb6c22f0a3e4785488718874816ae797290aa9a18f096f783fdf5b4e3da89bc022033f8a8f59b815dc3d650638f77694d9a67e382e71c61501bcae621383e758895"
            },
            {
                "regid": "0-2",
                "signature": "3044022047635f54e9cc87c82437474b781b323c891cb1ece18c1df5ef90a5f8cfee98bd0220342e47e610233108bd4f5e25b83a0ce6d636ecb26ab23b84d1bdfa51d00d9391"
            },
            {
                "regid": "0-4",
                "signature": ""
            }
        ],
        "from_addr": "wgssS9uNcEBEgbYfwexTb5zGgY7jppmsuK",
        "fee_symbol": "WICC",
        "fees": 10000000,
        "valid_height": 347410,
        "transfers": [
            {
                "to_uid": "5669-2",
                "to_addr": "wgcSFDbJpJoPJ2DgejEoWDD3iw1ezE8Mbv",
                "coin_symbol": "WICC",
                "coin_amount": 100000000
            }
        ],
        "memo": ""
    },
    "error": null,
    "id": "curltest"
}

7. 使用submittxraw 广播多重签名交易

Parameters

rawtx 签名后的rawtx

Returns

txid 交易哈希

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "submittxraw", "params": ["0701949912045749434383e1ac000103ab25020457494343aed6c100000203000346304402206cb6c22f0a3e4785488718874816ae797290aa9a18f096f783fdf5b4e3da89bc022033f8a8f59b815dc3d650638f77694d9a67e382e71c61501bcae621383e7588950002463044022047635f54e9cc87c82437474b781b323c891cb1ece18c1df5ef90a5f8cfee98bd0220342e47e610233108bd4f5e25b83a0ce6d636ecb26ab23b84d1bdfa51d00d9391000400"] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "txid": "0ec855aeec4b06c660fd6e1ec2b2302061f22c3fe9986c2d54b7b9b137fc594c"
    },
    "error": null,