Rippled/XRP API手册

account_channels - 获取账户支付通道

account_channels命令返回指定账户的支付通道,注意该命令只会返回指定账户为 通道源账户(所有者)的通道。所获取的信息都是相对于指定版本的账本。

API请求格式

account_channels命令支持WebSocket、JSON-RPC或命令行调用。

websocket请求示例

{
  "id": 1,
  "command": "account_channels",
  "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
  "destination_account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
  "ledger_index": "validated"
}

JSON-RPC请求示例

{
    "method": "account_channels",
    "params": [{
        "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "destination_account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
        "ledger_index": "validated"
    }]
}

命令行请求示例

Syntax: account_channels <account> [<destination_account>] [<ledger>]
rippled account_channels rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn validated

命令请求参数

account_channels命令主要包括以下参数:

  • account:通道源账户唯一标识符,通常为账户地址,字符串
  • destination_account:通道目标账户地址,字符串,可选
  • ledger_hash:要使用的账本版本,20字节长的16进制字符串,可选
  • ledger_index:要使用的账户序列号或用于自动选择账本的快捷字符串,数字或字符串,可选
  • limit:返回的最大交易数量,整数,10~400,默认值200,可选
  • marker:前序分页响应中的值,用来继续获取后续数据。可选

API响应格式

WebSocket响应示例

{
  "id": 2,
  "status": "success",
  "type": "response",
  "result": {
    "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
    "channels": [
      {
        "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "amount": "100000000",
        "balance": "1000000",
        "channel_id": "5DB01B7FFED6B67E6B0414DED11E051D2EE2B7619CE0EAA6286D67A3A4D5BDB3",
        "destination_account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
        "destination_tag": 20170428,
        "expiration": 547073182,
        "public_key": "aB44YfzW24VDEJQ2UuLPV2PvqcPCSoLnL7y5M1EzhdW4LnK5xMS3",
        "public_key_hex": "023693F15967AE357D0327974AD46FE3C127113B1110D6044FD41E723689F81CC6",
        "settle_delay": 86400
      }
    ],
    "ledger_hash": "F168208EECDAA57DDAC32780CDD8330FA3E89F0E84D27A9052AA2F88681EBD08",
    "ledger_index": 37230642,
    "validated": true
  }
}

JSON-RPC响应示例

200 OK

{
    "result": {
        "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "channels": [{
            "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "amount": "100000000",
            "balance": "0",
            "channel_id": "5DB01B7FFED6B67E6B0414DED11E051D2EE2B7619CE0EAA6286D67A3A4D5BDB3",
            "destination_account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
            "destination_tag": 20170428,
            "public_key": "aB44YfzW24VDEJQ2UuLPV2PvqcPCSoLnL7y5M1EzhdW4LnK5xMS3",
            "public_key_hex": "023693F15967AE357D0327974AD46FE3C127113B1110D6044FD41E723689F81CC6",
            "settle_delay": 86400
        }],
        "ledger_hash": "B9D3D80EDF4083A06B2D51202E0BFB63C46FC0985E015D06767C21A62853BF6D",
        "ledger_index": 37230600,
        "status": "success",
        "validated": true
    }
}

命令行响应示例

200 OK

{
    "result": {
        "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "channels": [{
            "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "amount": "100000000",
            "balance": "0",
            "channel_id": "5DB01B7FFED6B67E6B0414DED11E051D2EE2B7619CE0EAA6286D67A3A4D5BDB3",
            "destination_account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
            "destination_tag": 20170428,
            "public_key": "aB44YfzW24VDEJQ2UuLPV2PvqcPCSoLnL7y5M1EzhdW4LnK5xMS3",
            "public_key_hex": "023693F15967AE357D0327974AD46FE3C127113B1110D6044FD41E723689F81CC6",
            "settle_delay": 86400
        }],
        "ledger_hash": "B9D3D80EDF4083A06B2D51202E0BFB63C46FC0985E015D06767C21A62853BF6D",
        "ledger_index": 37230600,
        "status": "success",
        "validated": true
    }
}

命令响应字段

API响应对象遵循标准格式,主要包含如下字段:

  • account:支付通道源地址,字符串
  • channels:支付通道数组,每个成员为一个通道对象,描述见下面
  • ledger_hash:账本版本哈希,字符串
  • ledger_index:账本版本索引,数值
  • validated:是否已验证,布尔值,true表示返回的数据来自已验证账本
  • limit:实际返回的支付通道数量
  • marker:服务端的分页标记对象

支付通道对象主要包含如下字段:

  • account:通道源账户,字符串
  • amount:分配给该通道的XRP数量,单位:drop,字符串
  • balance:从该通道支付出去的XRP数量,单位:drop,字符串
  • channel_id:通道唯一biaoshiID,64字符长,16进制字符串
  • destination_account:通道目标账户,字符串
  • public_key:通道的公钥,base58格式字符串
  • public_key_hex:通道的公钥,16进制字符串
  • settle_delay:通道源账户在关闭通道前必须保持通道开放的秒数,整型
  • expiration:通道超时时间,整型
  • cancel_after:通道取消时间,整型
  • source_tag:经过此通道的支付交易附加的源标签,32位无符号整型
  • destination_tag:经过此通道的支付交易附加的目标标签,32位无符号整型