Skip to content

cli独立模块命令 3(privacy、para)

QM edited this page Dec 21, 2020 · 1 revision

版本:V6.3.2

privacy 隐私交易合约

目前主网不支持privacy合约,可在平行链运行。
cli privacy -h

Available Commands:
  enable      enable privacy address in wallet
  list_txs    List privacy transactions in wallet
  priv2priv   Create a privacy to privacy transaction
  priv2pub    Create a privacy to public transaction
  pub2priv    Create a public to privacy transaction
  rescanOpt   rescan Utxos in wallet and query rescan utxos status
  showau      Show Amount of UTXO
  showpai     Show privacy account information
  showpas     Show privacy account spend command
  showpk      Show privacy key by address
  showutxo4a  Show specified amount UTXOs

隐私交易合约不同于BTY主网账户体系,采用UTXO账户体系。


前置操作

enable 使能钱包中的地址

对于需要进行隐私交易的地址,需要先对其使能。
cli privacy enable -a "17mFjHjMHdtTU31QhFsLGcjNWxvGaVZcPH"-"1JeVN3q938vx8Pqcg7Kodmih8sWT5eQHHs"

{
    "results": [
        {
            "addr": "17mFjHjMHdtTU31QhFsLGcjNWxvGaVZcPH",
            "IsOK": true,
            "msg": ""
        },
        {
            "addr": "1JeVN3q938vx8Pqcg7Kodmih8sWT5eQHHs",
            "IsOK": true,
            "msg": ""
        }
    ]
}

-a后对多个地址操作时,以-分隔;或用all来使能本地钱包中所有的地址。

需要向隐私合约转入供操作的代币:
cli token send_exec -e privacy -s COC -a 10000
签名并发送。

showpk 根据钱包地址查询隐私公钥

cli privacy showpk -a "1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx"

{
    "showSuccessful": true,
    "pubkeypair": "f52b540136a5c52cf032618627948773b94969a5ea994277fdcc3d9530003099e9dd7fb7cb4460172447b890e6e5a41319c4955462fbca65abfb373d5763aaf0"
}

交易相关

pub2priv 公开到隐私的交易

本质是创建了一笔UTXO的交易。
cli privacy pub2priv -a 100 -e token -s COC -p 0065aa7868353e745990395e5c3519edc18cfb44541afcdd1188a585abc69590c2d0cdf0b94abe1ea7ded23efc92f11c4964a64505cfe3c6e7e5fb6dd62970ef
-p为目标隐私地址的公钥。
该交易使目标地址获得了指定数额的UTXO,可供后续花费。

priv2priv 隐私到隐私的交易

cli privacy priv2priv -a 15 -e coins -f 1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx -m 16 -p 241c7a688def4703b7e9cd3b7a89fba133ab350c608fb9aaa06eb328f1162b1deb441c2b435c3433715176191ccf9278b7d18fc175325065831c2e4c9f2f1b22 -s BTY
-m为UTXO混淆数量,默认为16
-p为目标隐私地址的公钥。
该交易需消耗1BTY为手续费。

该交易使目标地址获得了指定数额的UTXO,可供后续花费。

priv2pub 隐私到公开的交易

cli privacy priv2pub -a 17 -e coins -f 1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx -m 17 -s BTY -t "1JeVN3q938vx8Pqcg7Kodmih8sWT5eQHHs"
由发送地址签名并发送。
该交易需消耗1BTY为手续费。

该交易使目标地址的privacy合约中获得指定数额的代币。

可使用withdraw命令将这部分代币取回。
cli coins withdraw -a 17 -e privacy


查询相关

showpai 根据地址查询隐私账户的信息

cli privacy showpai -a 1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx -s BTY -d 3

{
    "AvailableDetail": [
        {
            "Txhash": "0xef6269240bdae5bcdc8399844ab1791a5fead4441f3492e7c735f8ded359e32b",
            "Amount": "100.0000"
        }
    ],
    "AvailableAmount": "100.0000",
    "FrozenAmount": "0.0000",
    "TotalAmount": "100.0000"
}

-d为可选配置项:display mode.(0: display collect. 1:display available detail. 2:display frozen detail. 3:display all)

showau 查询UTOX的数量

cli privacy showau

{
    "amountDetail": [
        {
            "amount": 10,
            "count": 1
        },
        {
            "amount": 100,
            "count": 1
        }
    ]
}

showutxo4a 根据指定金额查询钱包地址中的UTXO

cli privacy showutxo4a -a 100

[
    {
        "Txhash": "0xef6269240bdae5bcdc8399844ab1791a5fead4441f3492e7c735f8ded359e32b",
        "OnetimePubKey": "a0ca5d2d82233361ac82a3098d61e378069e134df5018827e8f138a4c0ba250d"
    }
]

list_txs 查询钱包中指定地址的隐私交易

cli privacy list_txs -a 1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx -c 1 -d 1

{
    "txDetails": [
        {
            "tx": {
                "execer": "privacy",
                "payload": {
                    "privacy2public": {
                        "tokenname": "BTY",
                        "amount": "1700000000",
                        "note": "",
                        "to": "1JeVN3q938vx8Pqcg7Kodmih8sWT5eQHHs",
                        "input": {
                            "keyinput": [
                                {
                                    "amount": "200000000",
                                    "utxoGlobalIndex": [
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 3
                                        },
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 2
                                        }
                                    ],
                                    "keyImage": "0xd1dcfeb83be78d4d6918a5cdceabdb1c11b9e9e10139c79a9b24c92879555f61"
                                },
                                {
                                    "amount": "1000000000",
                                    "utxoGlobalIndex": [
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 1
                                        },
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 6
                                        },
                                        {
                                            "txhash": "0x4bb6b0e7aee5edc559130ae261dd8523ccbd5ed87ccc65aa9b58bb90b2d4fe69",
                                            "outindex": 0
                                        }
                                    ],
                                    "keyImage": "0x8cf1bcde57e9a64b339f67d778f14da88581ddf4cb1bd180dd5c07645bf6cd68"
                                },
                                {
                                    "amount": "2000000000",
                                    "utxoGlobalIndex": [
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 5
                                        }
                                    ],
                                    "keyImage": "0x6199ac3df223f5b22f54326655b6f2d38db0d62ba09f3fc4590e643643d4ac8e"
                                }
                            ]
                        },
                        "output": {
                            "RpubKeytx": "0x04283fcf89fd6319bc8c7c14bc907b71a2e4d11d07effd5703ab2e47bb7fb23c",
                            "keyoutput": [
                                {
                                    "amount": "200000000",
                                    "onetimepubkey": "0x662c7df1a596aa9018986d946be3e9984c6188fc2620ffad622669c11280839c"
                                },
                                {
                                    "amount": "200000000",
                                    "onetimepubkey": "0xb3c2a28ac20f875bc2cc889c36b1e513f86c3b47d15cf3e9eb55de4f48814828"
                                },
                                {
                                    "amount": "1000000000",
                                    "onetimepubkey": "0x1236cbfd485981589752b20d30aa3c699203916cb4af34b147ff1b5e19f899d5"
                                }
                            ]
                        },
                        "assetExec": "coins"
                    },
                    "ty": 103
                },
                "rawpayload": "0x20671aba040a034254591080e2cfaa0622e0020a73088084af5f12241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25200312241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b2520021a20d1dcfeb83be78d4d6918a5cdceabdb1c11b9e9e10139c79a9b24c92879555f610a9801088094ebdc0312241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25200112241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25200612221a204bb6b0e7aee5edc559130ae261dd8523ccbd5ed87ccc65aa9b58bb90b2d4fe691a208cf1bcde57e9a64b339f67d778f14da88581ddf4cb1bd180dd5c07645bf6cd680a4e0880a8d6b90712241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b2520051a206199ac3df223f5b22f54326655b6f2d38db0d62ba09f3fc4590e643643d4ac8e2a9e010a2004283fcf89fd6319bc8c7c14bc907b71a2e4d11d07effd5703ab2e47bb7fb23c1227088084af5f1220662c7df1a596aa9018986d946be3e9984c6188fc2620ffad622669c11280839c1227088084af5f1220b3c2a28ac20f875bc2cc889c36b1e513f86c3b47d15cf3e9eb55de4f488148281228088094ebdc0312201236cbfd485981589752b20d30aa3c699203916cb4af34b147ff1b5e19f899d53222314a65564e337139333876783850716367374b6f646d6968387357543565514848734205636f696e73",
                "signature": {
                    "ty": 5,
                    "pubkey": "0x731fb3ab7e47a046c3f927815d89497a93bf1d1e0631a35f1d1adfd3f9cff843",
                    "signature": "0x0ac8010a20785271f38b5eb65a6be0a1d14f6497e2b0c0f21a6106acbd8c29224ea1cb91360a2000316bd33abb4e6d6919580d916d74f8ab229e2df4242a7b281d1ac93332614f124082b269f9b4dbf2059df4b6ce3198bf445e0d0035faf702bd178f4e6c1aeaa00980a86341335a4ecfc1a542aab788c1bd63516d4fd3fc6fd9530e74fb2aacc80d124036c61c7ae91297f8b6e9dfcb130f40d4a3778faebb339e9937b4f853c7e59a0ddfcbde68e1aeb78b85a17e7816afb269696f15ea1abf1d045b99a17ffb88cb060aac020a204600ec61c56b9c494177793f37e2d418eee7dca1e04429cb7a16be09115082920a20ade0d47ed49bf5a8ca99731e49666e55e1691bc62ef6ab75dabd9507d9c764480a20f303a657403023872490754678c933ae10d86b8a18adad5111a171f1321470e51240975f312b418ed668bba7e29157fc257b5ac2d81dec7328b1b336cfdf99154003fa2e68c59ba2dcbd5ea14c6f8e45a84c699a8859a6f664afeddb0bca4bff150a1240c3ca545a6407ac0dbf29db8c4beceff5cd16cfc0895afd7477270ea9c6a09e04e9767622c1e663f44777919ffad2ec1b9aebd7f0ab51879a0fc6dbc0b1d1520b1240cde95fa68fe93095686a6a8a9433ae47b5a7d7ab77e32f190923ec99b44d320bff5ebe5d54052c226e5541ae02affbe9713381b26af5f9f121b07e2e2dc231030a640a2040ab7ea557285748f0130630fb75e8a1535ee8ec715bebad9048a958407b29521240f57228307de0417fdd5d43ed55a36c3cebf74d136d02ad4296022966691f780cbc6366904ecaba3112f72c83bc36656615572dddc11d33d4616123d416a75a0a"
                },
                "fee": "1.0000",
                "expire": 1565601399,
                "nonce": 2234700166825889400,
                "to": "1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd",
                "from": "1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd",
                "hash": "0x6656dce3ef5a3ebcd012addc52bb1d6662f1581048989e291d6559c53f0b6d53"
            },
            "receipt": {
                "ty": 2,
                "tyName": "ExecOk",
                "logs": [
                    {
                        "ty": 2,
                        "tyName": "LogFee",
                        "log": {
                            "prev": {
                                "currency": 0,
                                "balance": "241300000000",
                                "frozen": "0",
                                "addr": "1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd"
                            },
                            "current": {
                                "currency": 0,
                                "balance": "241200000000",
                                "frozen": "0",
                                "addr": "1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd"
                            }
                        },
                        "rawLog": "0x0a2b10809ae7f48207222231466579453656445a34465967704b316e326f6b574d444174506b7742756f6f5164122b1080d88fc58207222231466579453656445a34465967704b316e326f6b574d444174506b7742756f6f5164"
                    },
                    {
                        "ty": 8,
                        "tyName": "LogExecDeposit",
                        "log": {
                            "execAddr": "1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd",
                            "prev": {
                                "currency": 0,
                                "balance": "0",
                                "frozen": "0",
                                "addr": "1JeVN3q938vx8Pqcg7Kodmih8sWT5eQHHs"
                            },
                            "current": {
                                "currency": 0,
                                "balance": "1700000000",
                                "frozen": "0",
                                "addr": "1JeVN3q938vx8Pqcg7Kodmih8sWT5eQHHs"
                            }
                        },
                        "rawLog": "0x0a2231466579453656445a34465967704b316e326f6b574d444174506b7742756f6f516412242222314a65564e337139333876783850716367374b6f646d6968387357543565514848731a2a1080e2cfaa062222314a65564e337139333876783850716367374b6f646d696838735754356551484873"
                    },
                    {
                        "ty": 501,
                        "tyName": "LogPrivacyInput",
                        "log": {
                            "keyinput": [
                                {
                                    "amount": "200000000",
                                    "utxoGlobalIndex": [
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 3
                                        },
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 2
                                        }
                                    ],
                                    "keyImage": "0xd1dcfeb83be78d4d6918a5cdceabdb1c11b9e9e10139c79a9b24c92879555f61"
                                },
                                {
                                    "amount": "1000000000",
                                    "utxoGlobalIndex": [
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 1
                                        },
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 6
                                        },
                                        {
                                            "txhash": "0x4bb6b0e7aee5edc559130ae261dd8523ccbd5ed87ccc65aa9b58bb90b2d4fe69",
                                            "outindex": 0
                                        }
                                    ],
                                    "keyImage": "0x8cf1bcde57e9a64b339f67d778f14da88581ddf4cb1bd180dd5c07645bf6cd68"
                                },
                                {
                                    "amount": "2000000000",
                                    "utxoGlobalIndex": [
                                        {
                                            "txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                                            "outindex": 5
                                        }
                                    ],
                                    "keyImage": "0x6199ac3df223f5b22f54326655b6f2d38db0d62ba09f3fc4590e643643d4ac8e"
                                }
                            ]
                        },
                        "rawLog": "0x0a73088084af5f12241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25200312241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b2520021a20d1dcfeb83be78d4d6918a5cdceabdb1c11b9e9e10139c79a9b24c92879555f610a9801088094ebdc0312241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25200112241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25200612221a204bb6b0e7aee5edc559130ae261dd8523ccbd5ed87ccc65aa9b58bb90b2d4fe691a208cf1bcde57e9a64b339f67d778f14da88581ddf4cb1bd180dd5c07645bf6cd680a4e0880a8d6b90712241a20cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b2520051a206199ac3df223f5b22f54326655b6f2d38db0d62ba09f3fc4590e643643d4ac8e"
                    },
                    {
                        "ty": 502,
                        "tyName": "LogPrivacyOutput",
                        "log": {
                            "RpubKeytx": "0x425459",
                            "keyoutput": [
                                {
                                    "amount": "200000000",
                                    "onetimepubkey": "0x662c7df1a596aa9018986d946be3e9984c6188fc2620ffad622669c11280839c"
                                },
                                {
                                    "amount": "200000000",
                                    "onetimepubkey": "0xb3c2a28ac20f875bc2cc889c36b1e513f86c3b47d15cf3e9eb55de4f48814828"
                                },
                                {
                                    "amount": "1000000000",
                                    "onetimepubkey": "0x1236cbfd485981589752b20d30aa3c699203916cb4af34b147ff1b5e19f899d5"
                                }
                            ]
                        },
                        "rawLog": "0x0a034254591227088084af5f1220662c7df1a596aa9018986d946be3e9984c6188fc2620ffad622669c11280839c1227088084af5f1220b3c2a28ac20f875bc2cc889c36b1e513f86c3b47d15cf3e9eb55de4f488148281228088094ebdc0312201236cbfd485981589752b20d30aa3c699203916cb4af34b147ff1b5e19f899d5"
                    }
                ]
            },
            "height": 2995030,
            "index": 1,
            "blocktime": 1565600804,
            "amount": "0.0000",
            "fromaddr": "1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx",
            "txhash": "0x6656dce3ef5a3ebcd012addc52bb1d6662f1581048989e291d6559c53f0b6d53",
            "actionname": "Privacy2Public"
        }
    ]
}

部分可选参数:
cli privacy list_txs -h

Flags:
  -a, --addr string         account address
  -c, --count int32         number of transactions, default 10 (default 10)
  -d, --direction int32     query direction (0: pre page, 1: next page), valid with seedtxhash param (default 1)
  -h, --help                help for list_txs
      --seedtxhash string   seed trasnaction hash
      --sendrecv int32      send or recv flag (0: send, 1: recv), default 0
      --token string        token name.(BTY supported) (default "BTY")

提供了-c查询数量,-d查询方向,指定起始查询哈希,指定发送或接收,指定查询symbol等配置项。
该命令需有UTXO花费产生后可用。

showpas 查询指定地址的UTXO花费情况

cli privacy showpas -a "1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx" -s BTY

Total Privacy spend amount is 132.0000
[
    {
        "Txhash": "6656dce3ef5a3ebcd012addc52bb1d6662f1581048989e291d6559c53f0b6d53",
        "Spend": [
            {
                "Txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                "OutIndex": 3,
                "Amount": "2.0000"
            },
            {
                "Txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                "OutIndex": 6,
                "Amount": "10.0000"
            },
            {
                "Txhash": "0xcc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
                "OutIndex": 5,
                "Amount": "20.0000"
            }
        ]
    },
    {
        "Txhash": "cc439a6049f44146522dad7dd8943d6b1d63ecef68d41497fa5dc9c323dc5b25",
        "Spend": [
            {
                "Txhash": "0xef6269240bdae5bcdc8399844ab1791a5fead4441f3492e7c735f8ded359e32b",
                "Amount": "100.0000"
            }
        ]
    }
]

该命令需有UTXO花费产生后可用。

rescanOpt 指定地址加载隐私UTXO

cli privacy rescanOpt -a all -f 0

"start rescan UTXO"  

-f为0,指定地址开始加载导入地址的UTXO
cli privacy rescanOpt -a all -f 1

{
    "ShowRescanResults": [
        {
            "addr": "19S9wG9wgS2RhtZm1B5Zr24vexGYYK6QC7",
            "FlagString": "UtxoFlagNoScan"
        },
        {
            "addr": "1F5VPf3w2L3HEYoXP9g7TJNqyhCTUZZPmQ",
            "FlagString": "UtxoFlagNoScan"
        },
        {
            "addr": "1KoiQmaFg3DoZr84JehxrEWiR7SorSgbUx",
            "FlagString": "UtxoFlagNoScan"
        }
    ]
}

-f为1,显示目前地址的加载情况。


para 跨链合约

使用para合约时,需先搭建一条平行链。参考平行链搭建文档完成搭建。以下以搭建的game链完成示例。

cli para -h

Available Commands:
  asset_transfer Create a asset transfer to para-chain transaction
  asset_withdraw Create a asset withdraw to para-chain transaction
  blocks         Get blocks with main chain hash map between [start, end], the same in main
  buffer_block   Get para download-level block info
  config         parachain config cmd
  consens_status Get para chain current consensus status
  height         query consensus height
  is_sync        query parachain is sync
  nodegroup      super node group manage cmd
  para_list      Get para chain info list by titles
  super_node     super node manage cmd
  transfer       Create a transfer transaction
  transfer_exec  Create a transfer to exec transaction
  withdraw       Create a withdraw transaction

asset_transfer 资产转移

进行para资产转移前需在paracross合约中存有足额的资产。
cli para asset_transfer --ptitle user.p.game. -a 10 -n test -t 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d
签名并完成发送。

ptitle为目标平行链的标题,注意格式为最后有一点。 该类接口后续逐渐弃用。

通过调用平行链的余额查询,查询余额。
cli asset balance -a 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d --asset_exec paracross --asset_symbol coins.bty -e paracross --rpc_laddr="http://114.55.11.139:1195"

{
    "balance": "10.0000",
    "frozen": "0.0000",
    "addr": "12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
}

若未编译指定平行链专用的cli,因cli默认调用8801端口,需在调用时指定具体的调用端口,由--rpc_laddr= 指定。
跨链转入的bty存在paracross合约中,名称更改为了coins.bty的格式。若转移的是主链token,则名称相应的为token.xxx

asset_withdraw 取回资产

进行平行链资产取回前,需在平行链的paracross合约中有足额的备转移资产。
cli para asset_withdraw -a 1 --ptitle user.p.game. -t 1xUdxvnZoBpnWwnUSuNQN9ts3mWi1MZrc 签名并发送。
从平行链取回一样需要输入指定的ptitle。取回后的资产存放于paracross合约中。
执行平行链资产取回,需要对应的平行链开启共识。未开启共识的平行链无法取回。

blocks 根据高度返回获取平行链和对应主链区块哈希

cli para blocks -e 10000 -s 9999 --rpc_laddr="http://114.55.11.139:1195"

{
    "items": [
        {
            "height": 9999,
            "blockHash": "0x69d1fe567f5f72397bc85f9547697f358e4c499a24b4aa86ceed0b59f03a1a0a",
            "mainHeight": 3847377,
            "mainHash": "0x882086a3324a2046755b53d6c0426c7087aa8c58728947e7cdd6846f1baf0e9d"
        },
        {
            "height": 10000,
            "blockHash": "0x9559671bdfbbc876eba722449f5a64d457b9f462db9af2a16d9d55da51201211",
            "mainHeight": 3847577,
            "mainHash": "0x7ef088ccb85b775f5482f47ee35e37ec93a99c766c4f325258b097cccb81db0a"
        }
    ]
}

调用时需调用对应平行链端口。返回信息中返回平行链及主链的对应高度和区块哈希。 该类接口后续逐渐弃用。

buffer_block 根据高度获取指定平行链区块的信息

cli para buffer_block -t -1 --rpc_laddr="http://114.55.11.139:1195"

{
    "height": 11472,
    "mainHash": "0x9a990c48aaf76409dd0f8c9eb6b6bf4356eb32494906f80e6d8521d4c055a88a",
    "mainHeight": 3981201,
    "parentMainHash": "0x567d344f3be247c13c70d8212459f53b5f8d8356189a6092cdccd366913a1898",
    "blockTime": 1574306182,
    "txs": [
        "0xccfa6a51a8d29beb27c24e1b533ee6e82f179f3aa594ca0d22e263ec4478ab51",
        "0x8f80fe47b42039339fe5d43cb275f303053095edf6449e62a515e741f3f4f7c8",
        "0x3b6695b7189f907ef63877b5e6736898ca16748db1e835c601810f9302a213b1",
        "0x9c63c65c912a8e05d9945ab87182d6e76231b45366416ae090989fadeea012f7",
        "0x5ef453dfd914c7f1b5341b4fe4bc8841cddf50fc809f03e57b98c6c01061f810",
        "0xeafb4b6aa67e3915383d4a017ed65020850f19082561ccda3da644569c447215",
        "0x89e4825d05aa72160b054ee98905d8a8b58cfb7749f9371bebb41266a18f1311",
        "0xc3dcb74d9bb3c4c473134e65b46654f33233fcfb09d082170055e624dc195188",
        "0x557ee0e9a461e1354fc5a2aff5cd2bc34fc1301f42aad5cbd76789546b67f67b",
        "0xac48f9c5c8ef047f39b197f075e9c39dda3f5c1bea19392d7ee0995d93b14f51",
        "0x314d3e212c403de04eb5374df1dbe0cdd7bb500c59d04f8899f8ac4a3072bac0",
        "0xec73cc9e128101bc2c0c8a44311906c25c61cc6df4090fef7d894e7f3dec56c9"
    ]
}

-t为指定平行链高度,-1代表最新高度。

config 配置

平行链配置项,目前只支持自共识配置。
cli para config stages -h

Available Commands:
  all         Get para chain self consensus stages
  cancel      cancel for config cmd
  new         apply for para chain's self consensus stages cmd
  one         query para chain one self consensus stage
  query       show self consensus stage apply info
  vote        vote for config cmd

需在平行链已配置超级节点后可使用。

consens_done 根据平行链高度查询共识信息

cli para consens_done -g 1000 --paraName user.p.gamenew.

{
    "totalNodes": 4,
    "totalCommit": 3,
    "mostSameCommit": 3,
    "title": "user.p.gamenew.",
    "height": 1000,
    "chainExecHeight": 4618623
}

consens_status 根据高度查询平行链共识状态

cli para consens_status -g 10000 --paraName user.p.game.

{
    "status": 1,
    "title": "user.p.game.",
    "height": 10000,
    "mainHeight": 3847577,
    "mainHash": "0x7ef088ccb85b775f5482f47ee35e37ec93a99c766c4f325258b097cccb81db0a",
    "commitAddrs": [
        "1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR",
        "1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4",
        "1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
    ],
    "commitBlockHash": [
        "0x9559671bdfbbc876eba722449f5a64d457b9f462db9af2a16d9d55da51201211",
        "0x9559671bdfbbc876eba722449f5a64d457b9f462db9af2a16d9d55da51201211",
        "0x9559671bdfbbc876eba722449f5a64d457b9f462db9af2a16d9d55da51201211"
    ]
}

cross_transfer 资产转移统一接口

cli para cross_transfer -a 2 -e coins -n 11 -s bty -t 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv --paraName user.p.gamenew. 签名并发送。后续资产转移逐渐使用该统一接口。
-e后为资产原生合约 -s为资产标志。

height 查询当前平行链的链高度及共识高度

cli para height --paraName user.p.gamenew.

{
    "title": "user.p.gamenew.",
    "chainHeight": 3509,
    "consensHeight": 3509,
    "consensBlockHash": "0xc457eeb0cd9de5bdf3b5608c426d7eb4fd4cfcd1d8035b465130ab37bacdbb8a"
}

将这部分bty取回的操作调用同样的接口,合约名及symbol不同:
cli send para cross_transfer -a 0.1 -e user.p.gamenew.paracross -n 11 -s coins.bty -t 19kCYYJnvdsXLUxY5DqKL3yCiweNMzeMxE --paraName user.p.gamenew. --rpc_laddr="http://114.55.11.139:1195"

将平行链主代币转移到主链:
cli send para cross_transfer -a 0.1 -e user.p.gamenew.coins -n 11 -s GBTY -t 19kCYYJnvdsXLUxY5DqKL3yCiweNMzeMxE --paraName user.p.gamenew. --rpc_laddr="http://114.55.11.139:1195"

将这部分资产转移回平行链:
cli send para cross_transfer -a 0.01 -e paracross -n 11 -s user.p.gamenew.coins.GBTY -t 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv --paraName user.p.gamenew.
详细参考:[资产转移](https://chain.33.cn/document/266)

is_sync 查询当前平行链是否同步至最高

cli para is_sync --rpc_laddr="http://114.55.11.139:1195"
返回true or false。

nodegroup 平行链超级节点相关配置

后面详述超级节点相关操作及配置。

para_list 查询当前主链下所有开启共识的平行链相关信息

cli para para_list

{
    "titles": [
        {
            "totalNodes": 4,
            "totalCommit": 3,
            "mostSameCommit": 3,
            "title": "user.p.game.",
            "height": 11498
        },
        {
            "totalNodes": 1,
            "totalCommit": 1,
            "mostSameCommit": 1,
            "title": "user.p.issuance.",
            "height": 6063
        },
        {
            "totalNodes": 5,
            "totalCommit": 4,
            "mostSameCommit": 4,
            "title": "user.p.magic.",
            "height": 1802,
            "txResult": "3166"
        },
        {
            "totalNodes": 4,
            "totalCommit": 3,
            "mostSameCommit": 3,
            "title": "user.p.para.",
            "height": 89778
        },
        {
            "totalNodes": 1,
            "totalCommit": 1,
            "mostSameCommit": 1,
            "title": "user.p.testuwallet.",
            "height": 11572
        }
    ]
}

super_node 超级节点相关配置

后面详述超级节点相关配置。

transfer 转账

para转账是将平行链paracross中的资产转移到其他地址。
cli para transfer -a 1.1 -s coins.bty -t 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj --rpc_laddr="http://114.55.11.139:1195"
可通过资产查询接口查看余额。
cli asset balance -a 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj --asset_exec paracross --asset_symbol coins.bty -e paracross --rpc_laddr="http://114.55.11.139:1195"

{
    "balance": "1.1000",
    "frozen": "0.0000",
    "addr": "1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
}

transfer_exec 向执行器转账

同主链一样,向具体的执行器转账。
cli send para transfer_exec -a 0.2 -e trade -s coins.bty --rpc_laddr="http://114.55.11.139:1195"
查询余额
cli asset balance -a 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d --asset_exec paracross --asset_symbol coins.bty -e trade --rpc_laddr="http://114.55.11.139:1195"

{
    "balance": "0.2000",
    "frozen": "0.0000",
    "addr": "12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
}

withdraw 取回资产

同主链一样,从具体的执行器取回资产到paracross合约。
cli para withdraw -a 0.1 -s coins.bty -e trade --rpc_laddr="http://114.55.11.139:1195"


node 平行链超级节点相关

配置平行链超级节点,需要在配置文件中配置挖矿地址:
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount="1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"

超级节点组申请:
nodegroup相关命令:
cli para nodegroup -h

Available Commands:
  addrs       Query super node group's current addrs by title
  apply       apply for para chain's super node group
  approve     approve for para chain's super node group application
  list        query super node group apply list by status
  modify      modify for para chain's super node group parameters
  quit        quit for para chain's super node group application
  status      query super node group apply status by title

apply 申请超级节点账户组

平行链开链后,需要申请第一批超级节点账户组。
cli para nodegroup apply -a 13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn -c 0 --paraName user.p.tank. --rpc_laddr="http://localhost:8901"
-c为申请超级节点抵押的主链币数量,需大于等于后续审批阶段要求的数量。目前可以设置为0。 -a后为申请的账户组地址,多个时用,分隔。

list 查询超级节点账户组申请状态

cli para nodegroup list -s 1

{
    "ids": [
        {
            "id": "0xefdb14372362d382592d7e1ea0ee3460d0a9122301dda171c26a9128747bd334",
            "status": 1,
            "title": "user.p.tank.",
            "targetAddrs": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
            "fromAddr": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
            "height": 4140014
        }
    ]
}

-s后为申请状态,status:1:apply,2:approve,3:quit,根据状态查询

quit 取消超级节点账户组申请

clip para nodegroup quit -i 0xefdb14372362d382592d7e1ea0ee3460d0a9122301dda171c26a9128747bd334 --rpc_laddr="http://localhost:8901" --paraName user.p.tank.
根据查询得到的申请id来取消申请。

modify 修改超级节点账户组申请的抵押金额

cli para nodegroup modify -c 1 --rpc_laddr="http://localhost:8901" --paraName user.p.super.

approve 审批超级节点账户组申请

cli para nodegroup approve -c 0 --id 0x937e04945863ebf6241bef20e19e4d1ceb014a7235ce97725b3abf1137535786 --rpc_laddr="http://localhost:8901" --paraName user.p.tank.
针对id进行审批。-c为抵押的主链币数量,申请者不能低于该数量。签名需由管理员签名完成。因为该交易需在主链和平行链都执行成功,所以该管理员需在主链和平行链都配置。

查询完成申请的超级节点状态:
cli para nodegroup list -s 2

{
    "ids": [
        {
            "id": "0x215d2184e8709caf6a2a11aa4d1de55337e1eef83297a60259dbe627ddb312af",
            "status": 2,
            "title": "user.p.magic.",
            "targetAddrs": "1Prx7vUMqqhWN6iaE4iijdxKZbAwLzfweC,1KpZCQqZF1mNAghWUmC3Y7FR9Uoa8gj3XK",
            "coinsFrozen": 1000000000,
            "fromAddr": "1Prx7vUMqqhWN6iaE4iijdxKZbAwLzfweC",
            "height": 1850156
        },
        {
            "id": "0x886a5c040e99fd3783f7ca2b38367809a50b33d0c8a52970ce56001fed2cb144",
            "status": 2,
            "title": "user.p.super.",
            "targetAddrs": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
            "fromAddr": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
            "height": 4141281
        },
        {
            "id": "0x937e04945863ebf6241bef20e19e4d1ceb014a7235ce97725b3abf1137535786",
            "status": 2,
            "title": "user.p.tank.",
            "targetAddrs": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
            "fromAddr": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
            "height": 4140879
        }
    ]
}

addrs 根据平行链名称查询超级节点账户组

cli para nodegroup addrs --paraName user.p.super.

{
    "key": "mavl-paracross-nodes-title-user.p.super.",
    "value": "[13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn]"
}

status 根据平行链名称查询超级节点账户组状态

cli para nodegroup status --paraName user.p.super.

{
    "id": "0x886a5c040e99fd3783f7ca2b38367809a50b33d0c8a52970ce56001fed2cb144",
    "status": 2,
    "title": "user.p.super.",
    "targetAddrs": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
    "fromAddr": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
    "height": 4141281
}

超级节点操作:
cli para super_node -h

Available Commands:
  addr_status Get node current status:10:joined,11:quited from nodegroup
  cancel      super node cancel join or quit action by id cmd
  id_list     Get node apply id list info by status
  id_status   Get node id current vote status:1:joining,2:quiting,3:closed,4:canceled
  join        super node apply for join nodegroup cmd
  quit        super node apply for quit nodegroup cmd
  vote        nodegroup nodes vote for new join node cmd

addr_status 根据地址查询地址在超级节点组的状态

cli para super_node addr_status -a 13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn --paraName user.p.super.

{
    "addr": "13H84ZwW36bHqvxTrSENmFaa5zqsfBL8Fn",
    "proposalId": "0x886a5c040e99fd3783f7ca2b38367809a50b33d0c8a52970ce56001fed2cb144-0",
    "status": 10,
    "title": "user.p.super."
}

其中:
status:10:joined,11:quited

join 申请加入超级节点组

cli para super_node join -a 1EKWC81hrPFPK3rfGiD4g9cQ1o9ohR62Sa -c 0 --rpc_laddr="http://localhost:8901" --paraName user.p.super.
-c同上,为超级节点抵押的主链币,可设为0。

id_list 根据状态查询超级节点申请信息

cli para super_node id_list -s 1 --paraName user.p.super.

{
    "ids": [
        {
            "id": "0x1eafc50600d4dab5e941f6761b1a685c2991bc1ba63471ecb7a34397b9c31405",
            "status": 1,
            "title": "user.p.super.",
            "targetAddr": "1EKWC81hrPFPK3rfGiD4g9cQ1o9ohR62Sa",
            "votes": {},
            "fromAddr": "1EKWC81hrPFPK3rfGiD4g9cQ1o9ohR62Sa",
            "height": 4153693
        }
    ]
}

-s为指定的status:0:all,1:joining,2:quiting,3:closed,4:canceled

id_status 根据id查询超级节点申请信息

cli para super_node id_status --id 0x1eafc50600d4dab5e941f6761b1a685c2991bc1ba63471ecb7a34397b9c31405 --paraName user.p.super.

{
    "id": "0x1eafc50600d4dab5e941f6761b1a685c2991bc1ba63471ecb7a34397b9c31405",
    "status": 1,
    "title": "user.p.super.",
    "targetAddr": "1EKWC81hrPFPK3rfGiD4g9cQ1o9ohR62Sa",
    "votes": {},
    "fromAddr": "1EKWC81hrPFPK3rfGiD4g9cQ1o9ohR62Sa",
    "height": 4153693
}

cancel 取消申请加入或退出

cli para super_node cancel -i 0x1eafc50600d4dab5e941f6761b1a685c2991bc1ba63471ecb7a34397b9c31405 --rpc_laddr="http://localhost:8901" --paraName user.p.super.
可以取消join加入和quit退出的申请。

vote 对申请加入的账号投票

cli para super_node vote -v 1 -i 0xa64bb366b1bea81814e844b149379b339a743cc01d0074545dfc98e5d2d8ec63 --rpc_laddr="http://localhost:8901" --paraName user.p.super.
-v为投票的值,1位赞成,2为反对。
投票需由超级节点账户组内地址完成。

quit 退出超级节点账户组申请

cli para super_node quit -a 1EKWC81hrPFPK3rfGiD4g9cQ1o9ohR62Sa --rpc_laddr="http://localhost:8901" --paraName user.p.super. 可以由任何地址提出,由超级节点账户组进行投票。


配置相关

config

cli para config stages -h

Available Commands:
  all         Get para chain self consensus stages
  cancel      cancel for config cmd
  new         apply for para chain's self consensus stages cmd
  one         query para chain one self consensus stage
  query       show self consensus stage apply info
  vote        vote for config cmd

目前支持自共识查询

Clone this wiki locally