mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
Rename API method categories
This commit is contained in:
@@ -0,0 +1,569 @@
|
||||
---
|
||||
html: subscribe.html
|
||||
parent: subscription-methods.html
|
||||
blurb: 特定のイベントが発生した場合に、定期的に通知するようサーバーに要求します。
|
||||
labels:
|
||||
- 支払い
|
||||
- アカウント
|
||||
- ブロックチェーン
|
||||
- スマートコントラクト
|
||||
---
|
||||
# subscribe
|
||||
[[ソース]](https://github.com/ripple/rippled/blob/master/src/ripple/rpc/handlers/Subscribe.cpp "Source")
|
||||
|
||||
`subscribe`メソッドは、特定のイベントが発生した場合に、定期的に通知するようサーバーに要求します。
|
||||
|
||||
## 要求フォーマット
|
||||
要求フォーマットの例:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*アカウントのサブスクライブ*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example watch Bitstamp's hot wallet",
|
||||
"command": "subscribe",
|
||||
"accounts": ["rrpNnNLKrartuEqfJGpqyDwPj1AFPg9vn1"]
|
||||
}
|
||||
```
|
||||
|
||||
*オーダーブックのサブスクライブ*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example subscribe to XRP/GateHub USD order book",
|
||||
"command": "subscribe",
|
||||
"books": [
|
||||
{
|
||||
"taker_pays": {
|
||||
"currency": "XRP"
|
||||
},
|
||||
"taker_gets": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
|
||||
},
|
||||
"snapshot": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
*レジャーストリームのサブスクライブ*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example watch for new validated ledgers",
|
||||
"command": "subscribe",
|
||||
"streams": ["ledger"]
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
[試してみる >](websocket-api-tool.html#subscribe)
|
||||
|
||||
要求には以下のパラメーターが含まれます。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:--------------------|:-------|:----------------------------------------------|
|
||||
| `streams` | 配列 | _(省略可)_ 以下に説明する、サブスクライブする汎用ストリームの文字列名の配列。 |
|
||||
| `accounts` | 配列 | _(省略可)_ 検証済みトランザクションを監視するアカウントの一意のアドレスを持つ配列。これらのアドレスはXRP Ledgerの[base58][]フォーマットで記述されている必要があります。サーバーは、1つ以上のアカウントに影響するすべてのトランザクションについて通知を送信します。 |
|
||||
| `accounts_proposed` | 配列 | _(省略可)_ `accounts`と同様ですが、まだファイナライズされていないトランザクションを含みます。 |
|
||||
| `books` | 配列 | _(省略可)_ 以下に説明するとおり、更新の監視のために[オーダーブック](http://www.investopedia.com/terms/o/order-book.asp)を定義するオブジェクトの配列。 |
|
||||
| `url` | 文字列 | (Websocketでは省略可、それ以外では必須)サーバーが各イベントのJSON-RPCコールバックを送信するURL。*管理者専用。* |
|
||||
| `url_username` | 文字列 | _(省略可)_ コールバックURLで基本認証を行うためのユーザー名。 |
|
||||
| `url_password` | 文字列 | _(省略可)_ コールバックURLで基本認証を行うためのパスワード。 |
|
||||
|
||||
以下のパラメーターは廃止予定で、今後予告なしに削除される可能性があります。`user`、`password`、`rt_accounts`。
|
||||
|
||||
`streams`パラメーターは、以下のデフォルトの情報ストリームへのアクセスを可能にします。
|
||||
|
||||
* `server` - `rippled`サーバーのステータス(ネットワーク接続など)が変更されるたびにメッセージを送信します。
|
||||
* `ledger` - コンセンサスプロセスで新しい検証済みレジャーが宣言されるたびにメッセージを送信します。
|
||||
* `transactions` - 決済済みレジャーにトランザクションが追加されるたびにメッセージを送信します。
|
||||
* `transactions_proposed` - 決済済みレジャーにトランザクションが追加される場合や、検証済みレジャーにまだ追加されておらず、今後も追加される見込みのない一部のトランザクションが決済済みレジャーに追加される場合に、メッセージを送信します。提案されたすべてのトランザクションが検証前に表示されるわけではありません。**注記:** 検証済みレジャーには[失敗したトランザクションも記録されます](transaction-results.html)。これは、このようなトランザクションにはスパム対策のトランザクション手数料が課されるためです。
|
||||
* `validations` - サーバーがバリデータを信頼しているか否かにかかわらず、サーバーが検証メッセージを受信するたびに、メッセージを送信します。(個々の`rippled`は、サーバーが少なくとも定数の信頼できるバリデータから検証メッセージを受信した時点で、レジャーが検証済みであると宣言します。)
|
||||
* `consensus` - サーバーがコンセンサスサイクルのフェーズ(open、establish、acceptedなど)を変更するたびにメッセージを送信します。
|
||||
* `peer_status` - **(管理者専用)** 接続しているピア`rippled`サーバーに関する情報(特にコンセンサスプロセスに関する情報)。
|
||||
|
||||
`books`配列が指定されている場合、この配列の各要素は、以下のフィールドを持つオブジェクトです。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:-------------|:--------|:----------------------------------------------------|
|
||||
| `taker_gets` | オブジェクト | オファーを受諾するアカウントが受け取る通貨を[金額なしの通貨オブジェクト](basic-data-types.html#金額なしでの通貨の指定)として指定します。 |
|
||||
| `taker_pays` | オブジェクト | オファーを受諾するアカウントが支払う通貨を[金額なしの通貨オブジェクト](basic-data-types.html#金額なしでの通貨の指定)として指定します。 |
|
||||
| `taker` | 文字列 | オファーを表示するパースペクティブとして使用する一意のアカウントアドレス(XRP Ledgerの[base58][]フォーマット)。(これはオファーの資金提供ステータスと手数料に影響します。) |
|
||||
| `snapshot` | ブール値 | (省略可、デフォルトではfalse)trueの場合は、更新の送信前にサブスクライブした時点でオーダーブックの現在の状態を一度返します。 |
|
||||
| `both` | ブール値 | (省略可、デフォルトではfalse)trueの場合は、オーダーブックの両サイドを返します。 |
|
||||
|
||||
## 応答フォーマット
|
||||
|
||||
処理が成功した応答の例:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example watch Bitstamp's hot wallet",
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {}
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
応答は[標準フォーマット][]に従っています。応答に含まれるフィールドは、要求に指定されたサブスクリプションに応じて異なります。
|
||||
|
||||
* `accounts`および`accounts_proposed` - フィールドが返されません。
|
||||
* *Stream: server* - `load_base`(サーバーの現在の読み込みレベル)、`random`(ランダムに生成された値)などのサーバーのステータスに関する情報。これらの情報は変更される可能性があります。
|
||||
* *Stream: transactions*、*Stream: transactions_proposed*、*Stream: validations*、および*Stream: consensus* - フィールドは返されません。
|
||||
* *Stream: ledger* - 手元にあるレジャーと現在の手数料体系に関する情報。`fee_base`(XRP単位のトランザクションの現行基本手数料)、`fee_ref`(手数料単位のトランザクションの現行基本手数料)、`ledger_hash`(最新の検証済みレジャーのハッシュ)、`reserve_base`(アカウントの最低必要準備金)などがあります。
|
||||
* `books` - フィールドはデフォルトで返されません。要求が`"snapshot": true`に設定されている場合、`offers`(オーダーブックを定義するオファー定義オブジェクトの配列)を返します。
|
||||
|
||||
## 考えられるエラー
|
||||
|
||||
* いずれかの[汎用エラータイプ][]。
|
||||
* `invalidParams` - 1つ以上のフィールドの指定が正しくないか、1つ以上の必須フィールドが指定されていません。
|
||||
* `noPermission` - 要求に`url`フィールドが指定されていますが、管理者として接続していません。
|
||||
* `unknownStream` - 要求の`streams`フィールドの1つ以上の要素が有効なストリーム名ではありません。
|
||||
* `malformedStream` - 要求の`streams`フィールドのフォーマットが適切ではありません。
|
||||
* `malformedAccount` - 要求の`accounts`または`accounts_proposed`フィールドのアドレスのいずれか1つが、適切なフォーマットのXRP Ledgerアドレスではありません。(**注記:** グローバルレジャーにまだエントリーのないアドレスのストリームをサブスクライブして、そのアドレスに資金が供給されたらメッセージを受け取るように _できます_ 。)
|
||||
* `srcCurMalformed` - 要求の`books`フィールドの1つ以上の`taker_pays`サブフィールドのフォーマットが適切ではありません。
|
||||
* `dstAmtMalformed` - 要求の`books`フィールドの1つ以上の`taker_gets`サブフィールドのフォーマットが適切ではありません。
|
||||
* `srcIsrMalformed` - 要求の`books`フィールドの1つ以上の`taker_pays`サブフィールドの`issuer`フィールドが無効です。
|
||||
* `dstIsrMalformed` - 要求の`books`フィールドの1つ以上の`taker_gets`サブフィールドの`issuer`フィールドが無効です。
|
||||
* `badMarket` - `books`フィールドに指定されている1つ以上のオーダーブックが存在していません(ある通貨とその通貨自体の交換オファーなど)。
|
||||
|
||||
特定のストリームをサブスクライブすると、サブスクライブを解除するか、WebSocket接続を閉じるまで、そのストリームに関する応答を定期的に受信します。これらの応答の内容は、サブスクライブしている内容に応じて異なります。以下に、いくつかの例を紹介します。
|
||||
|
||||
## レジャーストリーム
|
||||
|
||||
`ledger`ストリームは、[コンセンサスプロセス](consensus.html)で新しい検証済みレジャーが宣言されたときにのみ`ledgerClosed`メッセージを送信します。このメッセージはレジャーを識別し、そのレジャーの内容について何らかの情報を伝えます。
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "ledgerClosed",
|
||||
"fee_base": 10,
|
||||
"fee_ref": 10,
|
||||
"ledger_hash": "687F604EF6B2F67319E8DCC8C66EF49D84D18A1E18F948421FC24D2C7C3DB464",
|
||||
"ledger_index": 7125358,
|
||||
"ledger_time": 455751310,
|
||||
"reserve_base": 20000000,
|
||||
"reserve_inc": 5000000,
|
||||
"txn_count": 7,
|
||||
"validated_ledgers": "32570-7125358"
|
||||
}
|
||||
```
|
||||
|
||||
レジャーストリームメッセージのフィールドは次のとおりです。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:--------------------|:--------------------------|:---------------------------|
|
||||
| `type` | 文字列 | `ledgerClosed`は、このメッセージがレジャーストリームからのものであることを示します。 |
|
||||
| `fee_base` | 数値 | このレジャーバージョン時点の[Referenceトランザクションコスト](transaction-cost.html#referenceトランザクションコスト)([XRPのdrop数][])。このレジャーバージョンに[SetFee疑似トランザクション](setfee.html)が含まれている場合は、次のレジャーバージョンから新しいトランザクションコストが適用されます。 |
|
||||
| `fee_ref` | 数値 | 「手数料単位」の[Referenceトランザクションコスト](transaction-cost.html#referenceトランザクションコスト)。 |
|
||||
| `ledger_hash` | 文字列 - [ハッシュ][] | 決済されたレジャーバージョンの識別用ハッシュ。 |
|
||||
| `ledger_index` | 数値 - [レジャーインデックス][] | 決済されたレジャーのレジャーインデックス。 |
|
||||
| `ledger_time` | 数値 | レジャーが閉鎖された時刻([Rippleエポック以降の経過秒数][]) |
|
||||
| `reserve_base` | 数値 | アカウントの最低必要[準備金](reserves.html)([XRPのdrop数][])。このレジャーバージョンに[SetFee疑似トランザクション](setfee.html)が含まれる場合は、次のレジャーバージョンから新しい基本準備金が適用されます。 |
|
||||
| `reserve_inc` | 数値 | アカウントがレジャーに所有しているオブジェクトごとの[所有者準備金](reserves.html#所有者準備金)([XRPのdrop数][])。レジャーに[SetFee疑似トランザクション](setfee.html)が記録されている場合、このレジャー以降は新しい所有者準備金が適用されます。 |
|
||||
| `txn_count` | 数値 | このレジャーバージョンに含まれる新規トランザクションの数。 |
|
||||
| `validated_ledgers` | 文字列 | _(省略される場合があります)_ サーバーで使用可能なレジャーの範囲。これは連続的ではない可能性があります。サーバーがネットワークに接続されていない場合や、サーバーが接続されていてもネットワークからレジャーをまだ取得していない場合は、このフィールドは返されません。 |
|
||||
|
||||
|
||||
## 検証ストリーム
|
||||
|
||||
[新規: rippled 0.29.0][]
|
||||
|
||||
検証ストリームは、検証メッセージ(検証投票とも呼ばれる)を受信するたびにメッセージを送信します。検証メッセージが信頼できるバリデータからのものであるかどうかは関係ありません。次のようなメッセージを送信します。
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "validationReceived",
|
||||
"amendments":[
|
||||
"42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE",
|
||||
"4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373",
|
||||
"6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC",
|
||||
"C1B8D934087225F509BEB5A8EC24447854713EE447D277F69545ABFA0E0FD490",
|
||||
"DA1BD556B42D85EA9C84066D028D355B52416734D3283F85E216EA5DA6DB7E13"
|
||||
],
|
||||
"base_fee":10,
|
||||
"flags":2147483649,
|
||||
"full":true,
|
||||
"ledger_hash":"EC02890710AAA2B71221B0D560CFB22D64317C07B7406B02959AD84BAD33E602",
|
||||
"ledger_index":"6",
|
||||
"load_fee":256000,
|
||||
"master_key": "nHUon2tpyJEHHYGmxqeGu37cvPYHzrMtUNQFVdCgGNvEkjmCpTqK",
|
||||
"reserve_base":20000000,
|
||||
"reserve_inc":5000000,
|
||||
"signature":"3045022100E199B55643F66BC6B37DBC5E185321CF952FD35D13D9E8001EB2564FFB94A07602201746C9A4F7A93647131A2DEB03B76F05E426EC67A5A27D77F4FF2603B9A528E6",
|
||||
"signing_time":515115322,
|
||||
"validation_public_key":"n94Gnc6svmaPPRHUAyyib1gQUov8sYbjLoEwUBYPH39qHZXuo8ZT"
|
||||
}
|
||||
```
|
||||
|
||||
検証ストリームメッセージのフィールドは次のとおりです。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:------------------------|:-----------------|:--------------------------------|
|
||||
| `type` | 文字列 | 値`validationReceived`は、このメッセージが検証ストリームからであることを示します。 |
|
||||
| `amendments` | 文字列の配列 | (省略される場合があります)このサーバーがプロトコルへの追加を求める[Amendment](amendments.html)。[新規: rippled 0.32.0][] |
|
||||
| `base_fee` | 整数 | (省略される場合があります)サーバーが[手数料投票](fee-voting.html)による設定を希望するスケーリングされていないトランザクションコスト(`reference_fee`値)。[新規: rippled 0.32.0][] |
|
||||
| `flags` | 数値 | この検証メッセージに追加されるフラグのビットマスク。フラグ0x80000000は、検証の署名が完全に正規であることを示します。フラグ0x00000001は、完全な検証であることを示します。それ以外の場合は部分検証です。部分検証とは、特定のレジャーに対する投票ではありません。部分検証は、バリデータがオンラインであるがコンセンサスにまだ同意していないことを示します。[新規: rippled 0.32.0][] |
|
||||
| `full` | ブール値 | `true`の場合は、完全な検証です。それ以外の場合は部分検証です。部分検証とは、特定のレジャーに対する投票ではありません。部分検証は、バリデータがオンラインであるがコンセンサスにまだ同意していないことを示します。[新規: rippled 0.32.0][] |
|
||||
| `ledger_hash` | 文字列 | 提案されたレジャーの識別ハッシュを検証中です。 |
|
||||
| `ledger_index` | 文字列 - 整数 | 提案されたレジャーの[レジャーインデックス][]。[新規: rippled 0.31.0][] |
|
||||
| `load_fee` | 整数 | (省略される場合があります)このバリデータにより現在施行されているローカルの負荷スケーリングされたトランザクションコスト(手数料単位)。[新規: rippled 0.32.0][] |
|
||||
| `master_key` | 文字列 | _(省略される場合があります)_ バリデータのマスター公開鍵(バリデータがXRP Ledgerの[base58][]フォーマットのバリデータトークンを使用している場合)。(関連項目: [`rippled`サーバーで検証を有効化](run-rippled-as-a-validator.html#3-rippledサーバーで検証を有効化)。)[新規: rippled 1.4.0][] |
|
||||
| `reserve_base` | 整数 | (省略される場合があります)このバリデータが[手数料投票](fee-voting.html)による設定を希望する最低必要準備金(`account_reserve`値)。[新規: rippled 0.32.0][] |
|
||||
| `reserve_inc` | 整数 | (省略される場合があります)このバリデータが[手数料投票](fee-voting.html)による設定を希望する必要準備金(`owner_reserve`値)の増分。[新規: rippled 0.32.0][] |
|
||||
| `signature` | 文字列 | バリデータがこのレジャーへの投票に署名するときに使用する署名。 |
|
||||
| `signing_time` | 数値 | この検証投票が署名された時刻([Rippleエポック以降の経過秒数][])。[新規: rippled 0.32.0][] |
|
||||
| `validation_public_key` | 文字列 | バリデータがメッセージの署名に使用したキーペアの公開鍵(XRP Ledgerの[base58][]形式)。このフィールドは、メッセージを送信するバリデータを特定します。また`signature`の検証にも使用できます。バリデータがトークンを使用している場合は一時的な公開鍵です。 |
|
||||
|
||||
|
||||
## トランザクションストリーム
|
||||
|
||||
サブスクリプションの多くは、次のようなトランザクションに関するメッセージをもたらします。
|
||||
|
||||
* `transactions`ストリーム
|
||||
* `transactions_proposed`ストリーム
|
||||
* `accounts`サブスクリプション
|
||||
* `accounts_proposed`サブスクリプション
|
||||
* `book`(オーダーブック)サブスクリプション
|
||||
|
||||
`transactions_proposed`ストリームは、厳密には`transactions`ストリームのスーパーセットです。このストリームにはすべての検証済みトランザクションと、検証済みレジャーにまだ記録されておらず、今後も記録される見込みのない提案されたトランザクションがいくつか記録されます。このような「処理中」のトランザクションはそのフィールドから判断できます。
|
||||
|
||||
* `validated`フィールドがないか、または値`false`が指定されている。
|
||||
* `meta`フィールドまたは`metadata`フィールドがない。
|
||||
* トランザクションがファイナライズされたレジャーバージョンを指定する`ledger_index`フィールドと`ledger_hash`フィールドの代わりに、現在これらのトランザクションに提案されているレジャーバージョンを指定する`ledger_current_index`フィールドが存在する。
|
||||
|
||||
上記に該当しない場合、`transactions_proposed`ストリームからのメッセージは`transactions`ストリームからのメッセージと同じです。
|
||||
|
||||
アカウントまたはオーダーブックを変更できるのはトランザクションだけであるため、特定の`accounts`または`books`をサブスクライブすることにより送信されるメッセージも、トランザクションメッセージの形式(`transactions`ストリームのメッセージと同じ形式)となります。唯一の異なる点は、監視中のアカウントまたはオーダーブックに影響するトランザクションに対するメッセージだけを受信することです。
|
||||
|
||||
`accounts_proposed`サブスクリプションも同様に機能しますが、このサブスクリプションには、`transactions_proposed`ストリームと同様、監視中のアカウントの未確定トランザクションも記録される点が異なります。
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "closed",
|
||||
"type": "transaction",
|
||||
"engine_result": "tesSUCCESS",
|
||||
"engine_result_code": 0,
|
||||
"engine_result_message": "The transaction was applied.",
|
||||
"ledger_hash": "989AFBFD65D820C6BD85301B740F5D592F060668A90EEF5EC1815EBA27D58FE8",
|
||||
"ledger_index": 7125442,
|
||||
"meta": {
|
||||
"AffectedNodes": [
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Flags": 0,
|
||||
"IndexPrevious": "0000000000000000",
|
||||
"Owner": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"RootIndex": "ABD8CE2D1205D0C062876E9E1F3CBDC902ED8EF4E8D3D071B962C7ED0E113E68"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "0BBDEE7D0BE120F7BF27640B5245EBFE0C5FD5281988BA823C44477A70262A4D"
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"BookDirectory": "892E892DC63D8F70DCF5C9ECF29394FF7DD3DC6F47DB8EB34A03920BFC5E99BE",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 0,
|
||||
"OwnerNode": "000000000000006E",
|
||||
"PreviousTxnID": "58A17D95770F8D07E08B81A85896F4032A328B6C2BDCDEC0A00F3EF3914DCF0A",
|
||||
"PreviousTxnLgrSeq": 7125330,
|
||||
"Sequence": 540691,
|
||||
"TakerGets": "4401967683",
|
||||
"TakerPays": {
|
||||
"currency": "BTC",
|
||||
"issuer": "rNPRNzBB92BVpAhhZr4iXDTveCgV5Pofm9",
|
||||
"value": "0.04424"
|
||||
}
|
||||
},
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "386B7803A9210747941B0D079BB408F31ACB1CB98832184D0287A1CBF4FE6D00"
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"ExchangeRate": "4A03920BFC5E99BE",
|
||||
"Flags": 0,
|
||||
"RootIndex": "892E892DC63D8F70DCF5C9ECF29394FF7DD3DC6F47DB8EB34A03920BFC5E99BE",
|
||||
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
|
||||
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
|
||||
"TakerPaysCurrency": "0000000000000000000000004254430000000000",
|
||||
"TakerPaysIssuer": "92D705968936C419CE614BF264B5EEB1CEA47FF4"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "892E892DC63D8F70DCF5C9ECF29394FF7DD3DC6F47DB8EB34A03920BFC5E99BE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"Balance": "11133297300",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 9,
|
||||
"Sequence": 540706
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "A6C2532E1008A513B3F822A92B8E5214BD0D413DC20AD3631C1A39AD6B36CD07",
|
||||
"PreviousFields": {
|
||||
"Balance": "11133297310",
|
||||
"OwnerCount": 10,
|
||||
"Sequence": 540705
|
||||
},
|
||||
"PreviousTxnID": "484D57DFC4E446DA83B4540305F0CE836D4E007361542EC12CC0FFB5F0A1BE3A",
|
||||
"PreviousTxnLgrSeq": 7125358
|
||||
}
|
||||
}
|
||||
],
|
||||
"TransactionIndex": 1,
|
||||
"TransactionResult": "tesSUCCESS"
|
||||
},
|
||||
"transaction": {
|
||||
"Account": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"Fee": "10",
|
||||
"Flags": 2147483648,
|
||||
"OfferSequence": 540691,
|
||||
"Sequence": 540705,
|
||||
"SigningPubKey": "030BB49C591C9CD65C945D4B78332F27633D7771E6CF4D4B942D26BA40748BB8B4",
|
||||
"TransactionType": "OfferCancel",
|
||||
"TxnSignature": "30450221008223604A383F3AED25D53CE7C874700619893A6EEE4336508312217850A9722302205E0614366E174F2DFF78B879F310DB0B3F6DA1967E52A32F65E25DCEC622CD68",
|
||||
"date": 455751680,
|
||||
"hash": "94CF924C774DFDBE474A2A7E40AEA70E7E15D130C8CBEF8AF1D2BE97A8269F14"
|
||||
},
|
||||
"validated": true
|
||||
}
|
||||
```
|
||||
|
||||
トランザクションストリームメッセージには次のフィールドがあります。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:------------------------|:--------------------------|:-----------------------|
|
||||
| `type` | 文字列 | `transaction`は、トランザクションの通知であることを示します。この通知はさまざまなストリームから送信される可能性があります。 |
|
||||
| `engine_result` | 文字列 | 文字列の[トランザクション結果コード](transaction-results.html) |
|
||||
| `engine_result_code` | 数値 | 数値の[トランザクション応答コード](transaction-results.html)(該当する場合) |
|
||||
| `engine_result_message` | 文字列 | 人間が読み取れる形式のトランザクション応答の説明 |
|
||||
| `ledger_current_index` | 数値 - [レジャーインデックス][] | _(未検証のトランザクションのみ)_ このトランザクションが現在提案されている現在進行中の[レジャーバージョン](ledgers.html)のレジャーインデックス。 |
|
||||
| `ledger_hash` | 文字列 - [ハッシュ][] | _(検証済みのトランザクションのみ)_ このトランザクションを含む レジャーバージョンの識別用ハッシュ。 |
|
||||
| `ledger_index` | 数値 - [レジャーインデックス][] | _(検証済みのトランザクションのみ)_ このトランザクションを含むレジャーバージョンのレジャーインデックス。 |
|
||||
| `meta` | オブジェクト | _(検証済みのトランザクションのみ)_ [トランザクションのメタデータ](transaction-metadata.html)。トランザクションの正確な結果を詳細に表示します。 |
|
||||
| `transaction` | オブジェクト | JSONフォーマットの[トランザクションの定義](transaction-formats.html)。 |
|
||||
| `validated` | ブール値 | `true`の場合、このトランザクションは検証済みのレジャーに含まれており、最終的な結果であることを意味します。`transaction`ストリームからの応答は常に検証される必要があります。 |
|
||||
|
||||
|
||||
## ピアステータスストリーム
|
||||
|
||||
管理者専用の`peer_status`ストリームは、このサーバーが接続している他の`rippled`サーバーの活動に関する大量の情報、特にコンセンサスプロセスでのサーバーのステータスを報告します。
|
||||
|
||||
ピアステータスストリームメッセージの例:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "CLOSING_LEDGER",
|
||||
"date": 508546525,
|
||||
"ledger_hash": "4D4CD9CD543F0C1EF023CC457F5BEFEA59EEF73E4552542D40E7C4FA08D3C320",
|
||||
"ledger_index": 18853106,
|
||||
"ledger_index_max": 18853106,
|
||||
"ledger_index_min": 18852082,
|
||||
"type": "peerStatusChange"
|
||||
}
|
||||
```
|
||||
|
||||
ピアステータスストリームメッセージは、ピア`rippled`サーバーのステータスが変化したイベントを表します。これらのメッセージは、次のフィールドを持つJSONオブジェクトです。
|
||||
|
||||
| `Field` | 値 | 説明 |
|
||||
|:-------------------|:-------|:-----------------------------------------------|
|
||||
| `type` | 文字列 | `peerStatusChange`は、ピアステータスストリームからのメッセージであることを示します。 |
|
||||
| `action` | 文字列 | このメッセージが送信される原因となったイベントのタイプ。有効な値については、[ピアステータスイベント](#ピアステータスイベント)を参照してください。 |
|
||||
| `date` | 数値 | このイベントが発生した時刻([Rippleエポック以降の経過秒数][]) |
|
||||
| `ledger_hash` | 文字列 | (省略される場合があります)このメッセージに関連するレジャーバージョンの識別用[ハッシュ][]。 |
|
||||
| `ledger_index` | 数値 | (省略される場合があります)このメッセージに関連するレジャーバージョンの[レジャーインデックス][]。 |
|
||||
| `ledger_index_max` | 数値 | (省略される場合があります)ピアで現在使用可能な最大[レジャーインデックス][]。 |
|
||||
| `ledger_index_min` | 数値 | (省略される場合があります)ピアで現在使用可能な最小[レジャーインデックス][]。 |
|
||||
|
||||
### ピアステータスイベント
|
||||
|
||||
ピアステータスストリームメッセージの`action`フィールドには次のいずれかの値が含まれます。
|
||||
|
||||
| `Value` | 意味 |
|
||||
|:------------------|:---------------------------------------------------------|
|
||||
| `CLOSING_LEDGER` | ピアがこの[レジャーインデックス][]のレジャーバージョンを閉鎖しました。 |
|
||||
| `ACCEPTED_LEDGER` | ピアがコンセンサスラウンドの結果としてこのレジャーバージョンを作成しました。**注記:** このレジャーが不変的に検証済みになるかどうかはまだ確実ではありません。 |
|
||||
| `SWITCHED_LEDGER` | ピアは、ネットワークの他の部分に従っていないと結論付け、異なるレジャーバージョンに切り替えました。 |
|
||||
| `LOST_SYNC` | ピアは検証済みのレジャーバージョンとコンセンサス処理中のレジャーバージョンの追跡でネットワークの他の部分に遅れをとりました。 |
|
||||
|
||||
|
||||
## オーダーブックストリーム
|
||||
|
||||
`books`フィールドを使用して1つ以上のオーダーブックをサブスクライブすると、これらのオーダーブックに影響するすべてのトランザクションを取得します。
|
||||
|
||||
オーダーブックストリームメッセージの例:
|
||||
|
||||
```json
|
||||
{
|
||||
"engine_result": "tesSUCCESS",
|
||||
"engine_result_code": 0,
|
||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
||||
"ledger_hash": "08547DD866F099CCB3666F113116B7AA2DF520FA2E3011DD1FF9C9C04A6C7C3E",
|
||||
"ledger_index": 18852105,
|
||||
"meta": {
|
||||
"AffectedNodes": [{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"AccountTxnID": "D295E2BE50E3B78AED24790D7B9096996DAF43F095BF17DB83EEACC283D14050",
|
||||
"Balance": "3070332374272",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 23,
|
||||
"RegularKey": "r9S56zu6QeJD5d8A7QMfLAeYavgB9dhaX4",
|
||||
"Sequence": 12142921
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "2880A9B4FB90A306B576C2D532BFE390AB3904642647DCF739492AA244EF46D1",
|
||||
"PreviousFields": {
|
||||
"AccountTxnID": "3CA3422B0E42D76A7A677B0BA0BE72DFCD93676E0C80F8D2EB27C04BD8457A0F",
|
||||
"Balance": "3070332385272",
|
||||
"Sequence": 12142920
|
||||
},
|
||||
"PreviousTxnID": "3CA3422B0E42D76A7A677B0BA0BE72DFCD93676E0C80F8D2EB27C04BD8457A0F",
|
||||
"PreviousTxnLgrSeq": 18852102
|
||||
}
|
||||
}, {
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Flags": 0,
|
||||
"IndexPrevious": "00000000000022D2",
|
||||
"Owner": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"RootIndex": "F435FBBEC9654204D7151A01E686BAA8CB325A472D7B61C7916EA58B59355767"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "29A543B6681AD7FC8AFBD1386DAE7385F02F9B8C4756A467DF6834AB54BBC9DB"
|
||||
}
|
||||
}, {
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"ExchangeRate": "4C1BA999A513EF78",
|
||||
"Flags": 0,
|
||||
"RootIndex": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78",
|
||||
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
|
||||
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
|
||||
"TakerPaysCurrency": "0000000000000000000000005553440000000000",
|
||||
"TakerPaysIssuer": "2ADB0B3959D60A6E6991F729E1918B7163925230"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78"
|
||||
}
|
||||
}, {
|
||||
"CreatedNode": {
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "92E235EE80D2B28A89BEE2C905D4545C2A004FD5D4097679C8A3FB25507FD9EB",
|
||||
"NewFields": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"BookDirectory": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78",
|
||||
"Expiration": 508543674,
|
||||
"OwnerNode": "00000000000022F4",
|
||||
"Sequence": 12142920,
|
||||
"TakerGets": "6537121438",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"value": "50.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"BookDirectory": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78",
|
||||
"BookNode": "0000000000000000",
|
||||
"Expiration": 508543133,
|
||||
"Flags": 0,
|
||||
"OwnerNode": "00000000000022F4",
|
||||
"PreviousTxnID": "58B3279C2D56AAC3D9B06106E637C01E3D911E9D31E2FE4EA0D886AC9F4DEE1E",
|
||||
"PreviousTxnLgrSeq": 18851945,
|
||||
"Sequence": 12142889,
|
||||
"TakerGets": "6537121438",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"value": "50.9"
|
||||
}
|
||||
},
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "D3436CE21925E1CB12C5C444963B47D7EA0CD9A0E387926DC76B23FE5CD1C15F"
|
||||
}
|
||||
}],
|
||||
"TransactionIndex": 26,
|
||||
"TransactionResult": "tesSUCCESS"
|
||||
},
|
||||
"status": "closed",
|
||||
"transaction": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"Expiration": 508543674,
|
||||
"Fee": "11000",
|
||||
"Flags": 2147483648,
|
||||
"LastLedgerSequence": 18852106,
|
||||
"OfferSequence": 12142889,
|
||||
"Sequence": 12142920,
|
||||
"SigningPubKey": "034841BF24BD72C7CC371EBD87CCBF258D8ADB05C18DE207130364A97D8A3EA524",
|
||||
"TakerGets": "6537121438",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"value": "50.9"
|
||||
},
|
||||
"TransactionType": "OfferCreate",
|
||||
"TxnSignature": "3045022100B9AD678A773FB61F8F9B565713C80CBF187A2F9EB8E9CE0DAC7B839CA6F4B04C02200613D173A0636CD9BE13F2E3EBD13A16932B5B7D8A96BB5F6D561CA5CDBC4AD3",
|
||||
"date": 508543090,
|
||||
"hash": "D295E2BE50E3B78AED24790D7B9096996DAF43F095BF17DB83EEACC283D14050",
|
||||
"owner_funds": "3070197374272"
|
||||
},
|
||||
"type": "transaction",
|
||||
"validated": true
|
||||
}
|
||||
```
|
||||
|
||||
オーダーブックストリームメッセージの形式は、[トランザクションストリームメッセージ](#トランザクションストリーム)と同様ですが、`OfferCreate`トランザクションに以下のフィールドも含まれている点が異なります。
|
||||
|
||||
| `Field` | 値 | 説明 |
|
||||
|:--------------------------|:-------|:----------------------------------------|
|
||||
| `transaction.owner_funds` | 文字列 | このOfferCreateトランザクションを送信する`Account`が、このトランザクション実行後に有する`TakerGets`通貨の金額。この通貨額が[凍結](freezes.html)されているかどうかはチェックされません。 |
|
||||
|
||||
|
||||
## コンセンサスストリーム
|
||||
|
||||
[新規: rippled 1.4.0][]
|
||||
|
||||
`consensus`ストリームは、[コンセンサスプロセス](consensus.html)でフェーズが変更されると、`consensusPhase`メッセージを送信します。このメッセージには、サーバーで実行されているコンセンサスの新しいフェーズが含まれます。
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "consensusPhase",
|
||||
"consensus": "accepted"
|
||||
}
|
||||
```
|
||||
|
||||
コンセンサスストリームメッセージのフィールドは次のとおりです。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:--------------------|:--------------------------|:---------------------------|
|
||||
| `type` | 文字列 | `consensusPhase`は、このメッセージがコンセンサスストリームからのものであることを示します。 |
|
||||
| `consensus` | 文字列 | サーバーで実行されている新しいコンセンサスフェーズ。値には、open、establish、acceptedなどがあります。 |
|
||||
|
||||
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
@@ -0,0 +1,576 @@
|
||||
---
|
||||
html: subscribe.html
|
||||
parent: subscription-methods.html
|
||||
blurb: Listen for updates about a particular subject.
|
||||
labels:
|
||||
- Payments
|
||||
- Blockchain
|
||||
- Accounts
|
||||
- Smart Contracts
|
||||
---
|
||||
# subscribe
|
||||
[[Source]](https://github.com/ripple/rippled/blob/master/src/ripple/rpc/handlers/Subscribe.cpp "Source")
|
||||
|
||||
The `subscribe` method requests periodic notifications from the server when certain events happen.
|
||||
|
||||
## Request Format
|
||||
An example of the request format:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*Subscribe to accounts*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example watch Bitstamp's hot wallet",
|
||||
"command": "subscribe",
|
||||
"accounts": ["rrpNnNLKrartuEqfJGpqyDwPj1AFPg9vn1"]
|
||||
}
|
||||
```
|
||||
|
||||
*Subscribe to order book*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example subscribe to XRP/GateHub USD order book",
|
||||
"command": "subscribe",
|
||||
"books": [
|
||||
{
|
||||
"taker_pays": {
|
||||
"currency": "XRP"
|
||||
},
|
||||
"taker_gets": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
|
||||
},
|
||||
"snapshot": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
*Subscribe to ledger stream*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example watch for new validated ledgers",
|
||||
"command": "subscribe",
|
||||
"streams": ["ledger"]
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
[Try it! >](websocket-api-tool.html#subscribe)
|
||||
|
||||
The request includes the following parameters:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:--------------------|:-------|:----------------------------------------------|
|
||||
| `streams` | Array | _(Optional)_ Array of string names of generic streams to subscribe to, as explained below |
|
||||
| `accounts` | Array | _(Optional)_ Array with the unique addresses of accounts to monitor for validated transactions. The addresses must be in the XRP Ledger's [base58][] format. The server sends a notification for any transaction that affects at least one of these accounts. |
|
||||
| `accounts_proposed` | Array | _(Optional)_ Like `accounts`, but include transactions that are not yet finalized. |
|
||||
| `books` | Array | _(Optional)_ Array of objects defining [order books](http://www.investopedia.com/terms/o/order-book.asp) to monitor for updates, as detailed below. |
|
||||
| `url` | String | (Optional for Websocket; Required otherwise) URL where the server sends a JSON-RPC callbacks for each event. *Admin-only.* |
|
||||
| `url_username` | String | _(Optional)_ Username to provide for basic authentication at the callback URL. |
|
||||
| `url_password` | String | _(Optional)_ Password to provide for basic authentication at the callback URL. |
|
||||
|
||||
The following parameters are deprecated and may be removed without further notice: `user`, `password`, `rt_accounts`.
|
||||
|
||||
The `streams` parameter provides access to the following default streams of information:
|
||||
|
||||
- `consensus` - Sends a message whenever the server changes phase in the consensus cycle (open, establish, accepted, and so forth)
|
||||
- `ledger` - Sends a message whenever the consensus process declares a new validated ledger
|
||||
- `manifests` - Sends a message whenever the server receives an update to a validator's ephemeral signing key.
|
||||
- `peer_status` - **(Admin only)** Information about connected peer `rippled` servers, especially with regards to the consensus process.
|
||||
- `transactions` - Sends a message whenever a transaction is included in a closed ledger
|
||||
- `transactions_proposed` - Sends a message whenever a transaction is included in a closed ledger, as well as some transactions that have not yet been included in a validated ledger and may never be. Not all proposed transactions appear before validation.
|
||||
**Note:** [Even some transactions that don't succeed are included](transaction-results.html) in validated ledgers, because they take the anti-spam transaction fee.
|
||||
- `server` - Sends a message whenever the status of the `rippled` server (for example, network connectivity) changes
|
||||
- `validations` - Sends a message whenever the server receives a validation message, regardless of if the server trusts the validator. (An individual `rippled` declares a ledger validated when the server receives validation messages from at least a quorum of trusted validators.)
|
||||
|
||||
**Note:** The following streams are not available from servers in [Reporting Mode][]: `server`, `peer_status`, `consensus`. Reporting Mode servers return the error `reportingUnsupported` if you request one of these streams. [Updated in: rippled 1.8.1][]
|
||||
|
||||
Each member of the `books` array, if provided, is an object with the following fields:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:-------------|:--------|:----------------------------------------------------|
|
||||
| `taker_gets` | Object | Specification of which currency the account taking the Offer would receive, as a [currency object with no amount](currency-formats.html#specifying-without-amounts). |
|
||||
| `taker_pays` | Object | Specification of which currency the account taking the Offer would pay, as a [currency object with no amount](currency-formats.html#specifying-without-amounts). |
|
||||
| `taker` | String | Unique [account address](accounts.html) to use as a perspective for viewing offers, in the XRP Ledger's [base58][] format. (This affects the funding status and fees of [Offers](offers.html).) |
|
||||
| `snapshot` | Boolean | _(Optional)_ If `true`, return the current state of the order book once when you subscribe before sending updates. The default is `false`. |
|
||||
| `both` | Boolean | _(Optional)_ If `true`, return both sides of the order book. The default is `false`. |
|
||||
|
||||
## Response Format
|
||||
|
||||
An example of a successful response:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Example watch Bitstamp's hot wallet",
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {}
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
The response follows the [standard format][]. The fields contained in the response vary depending on what subscriptions were included in the request.
|
||||
|
||||
* `accounts` and `accounts_proposed` - No fields returned.
|
||||
* *Stream: `server`* - Information about the server status, such as `load_base` (the current load level of the server), `random` (a randomly-generated value), and others, subject to change.
|
||||
* *Stream: `transactions`*, *Stream: `transactions_proposed`*, *Stream: `validations`*, and *Stream: `consensus`* - No fields returned.
|
||||
* *Stream: `ledger`* - Information about the ledgers on hand and current fee schedule. This includes the same fields as a [ledger stream message](#ledger-stream), except that it omits the `type` and `txn_count` fields.
|
||||
* `books` - No fields returned by default. If `"snapshot": true` is set in the request, returns `offers` (an array of offer definition objects defining the order book).
|
||||
|
||||
## Possible Errors
|
||||
|
||||
* Any of the [universal error types][].
|
||||
* `invalidParams` - One or more fields are specified incorrectly, or one or more required fields are missing.
|
||||
* `noPermission` - The request included the `url` field, but you are not connected as an admin.
|
||||
* `unknownStream` - One or more the members of the `streams` field of the request is not a valid stream name.
|
||||
* `malformedStream` - The `streams` field of the request is not formatted properly.
|
||||
* `malformedAccount` - One of the addresses in the `accounts` or `accounts_proposed` fields of the request is not a properly-formatted XRP Ledger address. (**Note:**: You _can_ subscribe to the stream of an address that does not yet have an entry in the global ledger to get a message when that address becomes funded.)
|
||||
* `srcCurMalformed` - One or more `taker_pays` sub-fields of the `books` field in the request is not formatted properly.
|
||||
* `dstAmtMalformed` - One or more `taker_gets` sub-fields of the `books` field in the request is not formatted properly.
|
||||
* `srcIsrMalformed` - The `issuer` field of one or more `taker_pays` sub-fields of the `books` field in the request is not valid.
|
||||
* `dstIsrMalformed` - The `issuer` field of one or more `taker_gets` sub-fields of the `books` field in the request is not valid.
|
||||
* `badMarket` - One or more desired order books in the `books` field does not exist; for example, offers to exchange a currency for itself.
|
||||
|
||||
When you subscribe to a particular stream, you receive periodic responses on that stream until you unsubscribe or close the WebSocket connection. The content of those responses depends on what you subscribed to. Here are some examples:
|
||||
|
||||
## Ledger Stream
|
||||
|
||||
The `ledger` stream only sends `ledgerClosed` messages when [the consensus process](consensus.html) declares a new validated ledger. The message identifies the ledger and provides some information about its contents.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "ledgerClosed",
|
||||
"fee_base": 10,
|
||||
"fee_ref": 10,
|
||||
"ledger_hash": "687F604EF6B2F67319E8DCC8C66EF49D84D18A1E18F948421FC24D2C7C3DB464",
|
||||
"ledger_index": 7125358,
|
||||
"ledger_time": 455751310,
|
||||
"reserve_base": 20000000,
|
||||
"reserve_inc": 5000000,
|
||||
"txn_count": 7,
|
||||
"validated_ledgers": "32570-7125358"
|
||||
}
|
||||
```
|
||||
|
||||
The fields from a ledger stream message are as follows:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:--------------------|:--------------------------|:---------------------------|
|
||||
| `type` | String | `ledgerClosed` indicates this is from the ledger stream |
|
||||
| `fee_base` | Number | The [reference transaction cost](transaction-cost.html#reference-transaction-cost) as of this ledger version, in [drops of XRP][]. If this ledger version includes a [SetFee pseudo-transaction](setfee.html) the new transaction cost applies starting with the following ledger version. |
|
||||
| `fee_ref` | Number | The [reference transaction cost](transaction-cost.html#reference-transaction-cost) in "fee units". |
|
||||
| `ledger_hash` | String - [Hash][] | The identifying hash of the ledger version that was closed. |
|
||||
| `ledger_index` | Number - [Ledger Index][] | The ledger index of the ledger that was closed. |
|
||||
| `ledger_time` | Number | The time this ledger was closed, in [seconds since the Ripple Epoch][] |
|
||||
| `reserve_base` | Number | The minimum [reserve](reserves.html), in [drops of XRP][], that is required for an account. If this ledger version includes a [SetFee pseudo-transaction](setfee.html) the new base reserve applies starting with the following ledger version. |
|
||||
| `reserve_inc` | Number | The [owner reserve](reserves.html#owner-reserves) for each object an account owns in the ledger, in [drops of XRP][]. If the ledger includes a [SetFee pseudo-transaction](setfee.html) the new owner reserve applies after this ledger. |
|
||||
| `txn_count` | Number | Number of new transactions included in this ledger version. |
|
||||
| `validated_ledgers` | String | _(May be omitted)_ Range of ledgers that the server has available. This may be a disjoint sequence such as `24900901-24900984,24901116-24901158`. This field is not returned if the server is not connected to the network, or if it is connected but has not yet obtained a ledger from the network. |
|
||||
|
||||
|
||||
## Validations Stream
|
||||
|
||||
[New in: rippled 0.29.0][]
|
||||
|
||||
The validations stream sends messages whenever it receives validation messages, also called validation votes, regardless of whether or not the validation message is from a trusted validator. The message looks like the following:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "validationReceived",
|
||||
"amendments":[
|
||||
"42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE",
|
||||
"4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373",
|
||||
"6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC",
|
||||
"C1B8D934087225F509BEB5A8EC24447854713EE447D277F69545ABFA0E0FD490",
|
||||
"DA1BD556B42D85EA9C84066D028D355B52416734D3283F85E216EA5DA6DB7E13"
|
||||
],
|
||||
"base_fee":10,
|
||||
"flags":2147483649,
|
||||
"full":true,
|
||||
"ledger_hash":"EC02890710AAA2B71221B0D560CFB22D64317C07B7406B02959AD84BAD33E602",
|
||||
"ledger_index":"6",
|
||||
"load_fee":256000,
|
||||
"master_key": "nHUon2tpyJEHHYGmxqeGu37cvPYHzrMtUNQFVdCgGNvEkjmCpTqK",
|
||||
"reserve_base":20000000,
|
||||
"reserve_inc":5000000,
|
||||
"signature":"3045022100E199B55643F66BC6B37DBC5E185321CF952FD35D13D9E8001EB2564FFB94A07602201746C9A4F7A93647131A2DEB03B76F05E426EC67A5A27D77F4FF2603B9A528E6",
|
||||
"signing_time":515115322,
|
||||
"validation_public_key":"n94Gnc6svmaPPRHUAyyib1gQUov8sYbjLoEwUBYPH39qHZXuo8ZT"
|
||||
}
|
||||
```
|
||||
|
||||
The fields from a validations stream message are as follows:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:------------------------|:-----------------|:--------------------------------|
|
||||
| `type` | String | The value `validationReceived` indicates this is from the validations stream. |
|
||||
| `amendments` | Array of Strings | _(May be omitted)_ The [amendments](amendments.html) this server wants to be added to the protocol. [New in: rippled 0.32.0][] |
|
||||
| `base_fee` | Integer | _(May be omitted)_ The unscaled transaction cost (`reference_fee` value) this server wants to set by [Fee Voting](fee-voting.html). [New in: rippled 0.32.0][] |
|
||||
| `cookie` | String - Number | _(May be omitted)_ An arbitrary value chosen by the server at startup. If the same validation key pair signs validations with different cookies concurrently, that usually indicates that multiple servers are incorrectly configured to use the same validation key pair. [New in: rippled 1.8.1][] |
|
||||
| `flags` | Number | Bit-mask of flags added to this validation message. The flag `0x80000000` indicates that the validation signature is fully-canonical. The flag `0x00000001` indicates that this is a full validation; otherwise it's a partial validation. Partial validations are not meant to vote for any particular ledger. A partial validation indicates that the validator is still online but not keeping up with consensus. [New in: rippled 0.32.0][] |
|
||||
| `full` | Boolean | If `true`, this is a full validation. Otherwise, this is a partial validation. Partial validations are not meant to vote for any particular ledger. A partial validation indicates that the validator is still online but not keeping up with consensus. [New in: rippled 0.32.0][] |
|
||||
| `ledger_hash` | String | The identifying hash of the proposed ledger is being validated. |
|
||||
| `ledger_index` | String - Number | The [Ledger Index][] of the proposed ledger. [New in: rippled 0.31.0][] |
|
||||
| `load_fee` | Integer | _(May be omitted)_ The local load-scaled transaction cost this validator is currently enforcing, in fee units. [New in: rippled 0.32.0][] |
|
||||
| `master_key` | String | _(May be omitted)_ The validator's master public key, if the validator is using a validator token, in the XRP Ledger's [base58][] format. (See also: [Enable Validation on your `rippled` Server](run-rippled-as-a-validator.html#3-enable-validation-on-your-rippled-server).) [New in: rippled 1.4.0][] |
|
||||
| `reserve_base` | Integer | _(May be omitted)_ The minimum reserve requirement (`account_reserve` value) this validator wants to set by [Fee Voting](fee-voting.html). [New in: rippled 0.32.0][] |
|
||||
| `reserve_inc` | Integer | _(May be omitted)_ The increment in the reserve requirement (`owner_reserve` value) this validator wants to set by [Fee Voting](fee-voting.html). [New in: rippled 0.32.0][] |
|
||||
| `server_version` | String - Number | _(May be omitted)_ An 64-bit integer that encodes the version number of the validating server. For example, `"1745990410175512576"`. Only provided once every 256 ledgers. [New in: rippled 1.8.1][] |
|
||||
| `signature` | String | The signature that the validator used to sign its vote for this ledger. |
|
||||
| `signing_time` | Number | When this validation vote was signed, in [seconds since the Ripple Epoch][]. [New in: rippled 0.32.0][] |
|
||||
| `validated_hash` | String | The unique hash of the proposed ledger this validation applies to. [New in: rippled 1.8.1][] |
|
||||
| `validation_public_key` | String | The public key from the key-pair that the validator used to sign the message, in the XRP Ledger's [base58][] format. This identifies the validator sending the message and can also be used to verify the `signature`. If the validator is using a token, this is an ephemeral public key. |
|
||||
|
||||
|
||||
## Transaction Streams
|
||||
|
||||
Many subscriptions result in messages about transactions, including the following:
|
||||
|
||||
* The `transactions` stream
|
||||
* The `transactions_proposed` stream
|
||||
* `accounts` subscriptions
|
||||
* `accounts_proposed` subscriptions
|
||||
* `book` (Order Book) subscriptions
|
||||
|
||||
The `transactions_proposed` stream, strictly speaking, is a superset of the `transactions` stream: it includes all validated transactions, as well as some suggested transactions that have not yet been included in a validated ledger and may never be. You can identify these "in-flight" transactions by their fields:
|
||||
|
||||
* The `validated` field is missing or has a value of `false`.
|
||||
* There is no `meta` or `metadata` field.
|
||||
* Instead of `ledger_hash` and `ledger_index` fields specifying in which ledger version the transactions were finalized, there is a `ledger_current_index` field specifying in which ledger version they are currently proposed.
|
||||
|
||||
Otherwise, the messages from the `transactions_proposed` stream are the same as ones from the `transactions` stream.
|
||||
|
||||
Since the only thing that can modify an account or an order book is a transaction, the messages that are sent as a result of subscribing to particular `accounts` or `books` also take the form of transaction messages, the same as the ones in the `transactions` stream. The only difference is that you only receive messages for transactions that affect the accounts or order books you're watching.
|
||||
|
||||
The `accounts_proposed` subscription works the same way, except it also includes unconfirmed transactions, like the `transactions_proposed` stream, for the accounts you're watching.
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "closed",
|
||||
"type": "transaction",
|
||||
"engine_result": "tesSUCCESS",
|
||||
"engine_result_code": 0,
|
||||
"engine_result_message": "The transaction was applied.",
|
||||
"ledger_hash": "989AFBFD65D820C6BD85301B740F5D592F060668A90EEF5EC1815EBA27D58FE8",
|
||||
"ledger_index": 7125442,
|
||||
"meta": {
|
||||
"AffectedNodes": [
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Flags": 0,
|
||||
"IndexPrevious": "0000000000000000",
|
||||
"Owner": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"RootIndex": "ABD8CE2D1205D0C062876E9E1F3CBDC902ED8EF4E8D3D071B962C7ED0E113E68"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "0BBDEE7D0BE120F7BF27640B5245EBFE0C5FD5281988BA823C44477A70262A4D"
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"BookDirectory": "892E892DC63D8F70DCF5C9ECF29394FF7DD3DC6F47DB8EB34A03920BFC5E99BE",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 0,
|
||||
"OwnerNode": "000000000000006E",
|
||||
"PreviousTxnID": "58A17D95770F8D07E08B81A85896F4032A328B6C2BDCDEC0A00F3EF3914DCF0A",
|
||||
"PreviousTxnLgrSeq": 7125330,
|
||||
"Sequence": 540691,
|
||||
"TakerGets": "4401967683",
|
||||
"TakerPays": {
|
||||
"currency": "BTC",
|
||||
"issuer": "rNPRNzBB92BVpAhhZr4iXDTveCgV5Pofm9",
|
||||
"value": "0.04424"
|
||||
}
|
||||
},
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "386B7803A9210747941B0D079BB408F31ACB1CB98832184D0287A1CBF4FE6D00"
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"ExchangeRate": "4A03920BFC5E99BE",
|
||||
"Flags": 0,
|
||||
"RootIndex": "892E892DC63D8F70DCF5C9ECF29394FF7DD3DC6F47DB8EB34A03920BFC5E99BE",
|
||||
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
|
||||
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
|
||||
"TakerPaysCurrency": "0000000000000000000000004254430000000000",
|
||||
"TakerPaysIssuer": "92D705968936C419CE614BF264B5EEB1CEA47FF4"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "892E892DC63D8F70DCF5C9ECF29394FF7DD3DC6F47DB8EB34A03920BFC5E99BE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"Balance": "11133297300",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 9,
|
||||
"Sequence": 540706
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "A6C2532E1008A513B3F822A92B8E5214BD0D413DC20AD3631C1A39AD6B36CD07",
|
||||
"PreviousFields": {
|
||||
"Balance": "11133297310",
|
||||
"OwnerCount": 10,
|
||||
"Sequence": 540705
|
||||
},
|
||||
"PreviousTxnID": "484D57DFC4E446DA83B4540305F0CE836D4E007361542EC12CC0FFB5F0A1BE3A",
|
||||
"PreviousTxnLgrSeq": 7125358
|
||||
}
|
||||
}
|
||||
],
|
||||
"TransactionIndex": 1,
|
||||
"TransactionResult": "tesSUCCESS"
|
||||
},
|
||||
"transaction": {
|
||||
"Account": "rRh634Y6QtoqkwTTrGzX66UYoCAvgE6jL",
|
||||
"Fee": "10",
|
||||
"Flags": 2147483648,
|
||||
"OfferSequence": 540691,
|
||||
"Sequence": 540705,
|
||||
"SigningPubKey": "030BB49C591C9CD65C945D4B78332F27633D7771E6CF4D4B942D26BA40748BB8B4",
|
||||
"TransactionType": "OfferCancel",
|
||||
"TxnSignature": "30450221008223604A383F3AED25D53CE7C874700619893A6EEE4336508312217850A9722302205E0614366E174F2DFF78B879F310DB0B3F6DA1967E52A32F65E25DCEC622CD68",
|
||||
"date": 455751680,
|
||||
"hash": "94CF924C774DFDBE474A2A7E40AEA70E7E15D130C8CBEF8AF1D2BE97A8269F14"
|
||||
},
|
||||
"validated": true
|
||||
}
|
||||
```
|
||||
|
||||
Transaction stream messages have the following fields:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:------------------------|:--------------------------|:-----------------------|
|
||||
| `type` | String | `transaction` indicates this is the notification of a transaction, which could come from several possible streams. |
|
||||
| `engine_result` | String | String [Transaction result code](transaction-results.html) |
|
||||
| `engine_result_code` | Number | Numeric [transaction response code](transaction-results.html), if applicable. |
|
||||
| `engine_result_message` | String | Human-readable explanation for the transaction response |
|
||||
| `ledger_current_index` | Number - [Ledger Index][] | _(Unvalidated transactions only)_ The ledger index of the current in-progress [ledger version](ledgers.html) for which this transaction is currently proposed. |
|
||||
| `ledger_hash` | String - [Hash][] | _(Validated transactions only)_ The identifying hash of the ledger version that includes this transaction |
|
||||
| `ledger_index` | Number - [Ledger Index][] | _(Validated transactions only)_ The ledger index of the ledger version that includes this transaction. |
|
||||
| `meta` | Object | _(Validated transactions only)_ The [transaction metadata](transaction-metadata.html), which shows the exact outcome of the transaction in detail. |
|
||||
| `transaction` | Object | The [definition of the transaction](transaction-formats.html) in JSON format |
|
||||
| `validated` | Boolean | If `true`, this transaction is included in a validated ledger and its outcome is final. Responses from the `transaction` stream should always be validated. |
|
||||
|
||||
|
||||
## Peer Status Stream
|
||||
|
||||
The admin-only `peer_status` stream reports a large amount of information on the activities of other `rippled` servers to which this server is connected, in particular their status in the consensus process.
|
||||
|
||||
Example of a Peer Status stream message:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "CLOSING_LEDGER",
|
||||
"date": 508546525,
|
||||
"ledger_hash": "4D4CD9CD543F0C1EF023CC457F5BEFEA59EEF73E4552542D40E7C4FA08D3C320",
|
||||
"ledger_index": 18853106,
|
||||
"ledger_index_max": 18853106,
|
||||
"ledger_index_min": 18852082,
|
||||
"type": "peerStatusChange"
|
||||
}
|
||||
```
|
||||
|
||||
Peer Status stream messages represent some event where the status of the peer `rippled` server changed. These messages are JSON objects with the following fields:
|
||||
|
||||
| `Field` | Value | Description |
|
||||
|:-------------------|:-------|:-----------------------------------------------|
|
||||
| `type` | String | `peerStatusChange` indicates this comes from the Peer Status stream. |
|
||||
| `action` | String | The type of event that prompted this message. See [Peer Status Events](#peer-status-events) for possible values. |
|
||||
| `date` | Number | The time this event occurred, in [seconds since the Ripple Epoch][]. |
|
||||
| `ledger_hash` | String | (May be omitted) The identifying [Hash][] of a ledger version to which this message pertains. |
|
||||
| `ledger_index` | Number | (May be omitted) The [Ledger Index][] of a ledger version to which this message pertains. |
|
||||
| `ledger_index_max` | Number | (May be omitted) The largest [Ledger Index][] the peer has currently available. |
|
||||
| `ledger_index_min` | Number | (May be omitted) The smallest [Ledger Index][] the peer has currently available. |
|
||||
|
||||
### Peer Status Events
|
||||
|
||||
The `action` field of a Peer Status stream message can have the following values:
|
||||
|
||||
| `Value` | Meaning |
|
||||
|:------------------|:---------------------------------------------------------|
|
||||
| `CLOSING_LEDGER` | The peer closed a ledger version with this [Ledger Index][], which usually means it is about to start consensus. |
|
||||
| `ACCEPTED_LEDGER` | The peer built this ledger version as the result of a consensus round. **Note:** This ledger is still not certain to become immutably validated. |
|
||||
| `SWITCHED_LEDGER` | The peer concluded it was not following the rest of the network and switched to a different ledger version. |
|
||||
| `LOST_SYNC` | The peer fell behind the rest of the network in tracking which ledger versions are validated and which are undergoing consensus. |
|
||||
|
||||
|
||||
## Order Book Streams
|
||||
|
||||
When you subscribe to one or more order books with the `books` field, you get back any transactions that affect those order books.
|
||||
|
||||
Example order book stream message:
|
||||
|
||||
```json
|
||||
{
|
||||
"engine_result": "tesSUCCESS",
|
||||
"engine_result_code": 0,
|
||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
||||
"ledger_hash": "08547DD866F099CCB3666F113116B7AA2DF520FA2E3011DD1FF9C9C04A6C7C3E",
|
||||
"ledger_index": 18852105,
|
||||
"meta": {
|
||||
"AffectedNodes": [{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"AccountTxnID": "D295E2BE50E3B78AED24790D7B9096996DAF43F095BF17DB83EEACC283D14050",
|
||||
"Balance": "3070332374272",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 23,
|
||||
"RegularKey": "r9S56zu6QeJD5d8A7QMfLAeYavgB9dhaX4",
|
||||
"Sequence": 12142921
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "2880A9B4FB90A306B576C2D532BFE390AB3904642647DCF739492AA244EF46D1",
|
||||
"PreviousFields": {
|
||||
"AccountTxnID": "3CA3422B0E42D76A7A677B0BA0BE72DFCD93676E0C80F8D2EB27C04BD8457A0F",
|
||||
"Balance": "3070332385272",
|
||||
"Sequence": 12142920
|
||||
},
|
||||
"PreviousTxnID": "3CA3422B0E42D76A7A677B0BA0BE72DFCD93676E0C80F8D2EB27C04BD8457A0F",
|
||||
"PreviousTxnLgrSeq": 18852102
|
||||
}
|
||||
}, {
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Flags": 0,
|
||||
"IndexPrevious": "00000000000022D2",
|
||||
"Owner": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"RootIndex": "F435FBBEC9654204D7151A01E686BAA8CB325A472D7B61C7916EA58B59355767"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "29A543B6681AD7FC8AFBD1386DAE7385F02F9B8C4756A467DF6834AB54BBC9DB"
|
||||
}
|
||||
}, {
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"ExchangeRate": "4C1BA999A513EF78",
|
||||
"Flags": 0,
|
||||
"RootIndex": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78",
|
||||
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
|
||||
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
|
||||
"TakerPaysCurrency": "0000000000000000000000005553440000000000",
|
||||
"TakerPaysIssuer": "2ADB0B3959D60A6E6991F729E1918B7163925230"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78"
|
||||
}
|
||||
}, {
|
||||
"CreatedNode": {
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "92E235EE80D2B28A89BEE2C905D4545C2A004FD5D4097679C8A3FB25507FD9EB",
|
||||
"NewFields": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"BookDirectory": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78",
|
||||
"Expiration": 508543674,
|
||||
"OwnerNode": "00000000000022F4",
|
||||
"Sequence": 12142920,
|
||||
"TakerGets": "6537121438",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"value": "50.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"BookDirectory": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784C1BA999A513EF78",
|
||||
"BookNode": "0000000000000000",
|
||||
"Expiration": 508543133,
|
||||
"Flags": 0,
|
||||
"OwnerNode": "00000000000022F4",
|
||||
"PreviousTxnID": "58B3279C2D56AAC3D9B06106E637C01E3D911E9D31E2FE4EA0D886AC9F4DEE1E",
|
||||
"PreviousTxnLgrSeq": 18851945,
|
||||
"Sequence": 12142889,
|
||||
"TakerGets": "6537121438",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"value": "50.9"
|
||||
}
|
||||
},
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "D3436CE21925E1CB12C5C444963B47D7EA0CD9A0E387926DC76B23FE5CD1C15F"
|
||||
}
|
||||
}],
|
||||
"TransactionIndex": 26,
|
||||
"TransactionResult": "tesSUCCESS"
|
||||
},
|
||||
"status": "closed",
|
||||
"transaction": {
|
||||
"Account": "rfCFLzNJYvvnoGHWQYACmJpTgkLUaugLEw",
|
||||
"Expiration": 508543674,
|
||||
"Fee": "11000",
|
||||
"Flags": 2147483648,
|
||||
"LastLedgerSequence": 18852106,
|
||||
"OfferSequence": 12142889,
|
||||
"Sequence": 12142920,
|
||||
"SigningPubKey": "034841BF24BD72C7CC371EBD87CCBF258D8ADB05C18DE207130364A97D8A3EA524",
|
||||
"TakerGets": "6537121438",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"value": "50.9"
|
||||
},
|
||||
"TransactionType": "OfferCreate",
|
||||
"TxnSignature": "3045022100B9AD678A773FB61F8F9B565713C80CBF187A2F9EB8E9CE0DAC7B839CA6F4B04C02200613D173A0636CD9BE13F2E3EBD13A16932B5B7D8A96BB5F6D561CA5CDBC4AD3",
|
||||
"date": 508543090,
|
||||
"hash": "D295E2BE50E3B78AED24790D7B9096996DAF43F095BF17DB83EEACC283D14050",
|
||||
"owner_funds": "3070197374272"
|
||||
},
|
||||
"type": "transaction",
|
||||
"validated": true
|
||||
}
|
||||
```
|
||||
|
||||
The format of an order book stream message is the same as that of [transaction stream messages](#transaction-streams), except that `OfferCreate` transactions also contain the following field:
|
||||
|
||||
| `Field` | Value | Description |
|
||||
|:--------------------------|:-------|:----------------------------------------|
|
||||
| `transaction.owner_funds` | String | Numeric amount of the `TakerGets` currency that the `Account` sending this OfferCreate transaction has after executing this transaction. This does not check whether the currency amount is [frozen](freezes.html). |
|
||||
|
||||
|
||||
## Consensus Stream
|
||||
|
||||
[New in: rippled 1.4.0][]
|
||||
|
||||
The `consensus` stream sends `consensusPhase` messages when [the consensus process](consensus.html) changes phase. The message contains the new phase of consensus the server is in.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "consensusPhase",
|
||||
"consensus": "accepted"
|
||||
}
|
||||
```
|
||||
|
||||
The fields from a consensus stream message are as follows:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:--------------------|:--------------------------|:---------------------------|
|
||||
| `type` | String | `consensusPhase` indicates this is from the consensus stream |
|
||||
| `consensus` | String | The new consensus phase the server is in. Possible values are open, establish, and accepted. |
|
||||
|
||||
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
@@ -0,0 +1,105 @@
|
||||
---
|
||||
html: unsubscribe.html
|
||||
parent: subscription-methods.html
|
||||
blurb: 特定のサブスクリプションまたは一連のサブスクリプションへのメッセージ送信の停止を指示します。
|
||||
labels:
|
||||
- 支払い
|
||||
- アカウント
|
||||
- ブロックチェーン
|
||||
- スマートコントラクト
|
||||
---
|
||||
# unsubscribe
|
||||
[[ソース]](https://github.com/ripple/rippled/blob/master/src/ripple/rpc/handlers/Unsubscribe.cpp "Source")
|
||||
|
||||
`unsubscribe`コマンドはサーバーに対して、特定のサブスクリプションまたは一連のサブスクリプションへのメッセージ送信の停止を指示します。
|
||||
|
||||
## 要求フォーマット
|
||||
要求フォーマットの例:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```json
|
||||
{
|
||||
"id":"Unsubscribe a lot of stuff",
|
||||
"command":"unsubscribe",
|
||||
"streams":["ledger","server","transactions","transactions_proposed"],
|
||||
"accounts":["rrpNnNLKrartuEqfJGpqyDwPj1AFPg9vn1"],
|
||||
"accounts_proposed":["rrpNnNLKrartuEqfJGpqyDwPj1AFPg9vn1"],
|
||||
"books":[
|
||||
{
|
||||
"taker_pays":{
|
||||
"currency":"XRP"
|
||||
},
|
||||
"taker_gets":{
|
||||
"currency":"USD",
|
||||
"issuer":"rUQTpMqAF5jhykj4FExVeXakrZpiKF6cQV"
|
||||
},
|
||||
"both": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
[試してみる >](websocket-api-tool.html#unsubscribe)
|
||||
|
||||
この要求のパラメーターは、[subscribeメソッド][]のパラメーターとほぼ同様の方法で指定されますが、終了するサブスクリプションを定義するために使用される点が異なります。これらのパラメーターを以下に示します。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:--------------------|:------|:-----------------------------------------------|
|
||||
| `streams` | 配列 | _(省略可)_ サブスクライブを解除する汎用ストリームの文字列名の配列(`ledger`、`server`、`transactions`、`transactions_proposed`など)。 |
|
||||
| `accounts` | 配列 | _(省略可)_ 更新の受信を停止する一意のアカウントアドレスの配列(XRP Ledgerの[base58][]フォーマット)。(以前にこれらのアカウントをサブスクライブしていた場合にのみ、メッセージが停止されます。一般のトランザクションストリームからアカウントを除外する目的では使用できません。) |
|
||||
| `accounts_proposed` | 配列 | _(省略可)_`accounts`と同様ですが、未検証のトランザクションを含む`accounts_proposed`サブスクリプションを対象としています。 |
|
||||
| `books` | 配列 | _(省略可)_ 以下に説明するように、サブスクライブ解除するオーダーブックを定義するオブジェクトの配列。 |
|
||||
|
||||
`rt_accounts`パラメーター、`url`パラメーター、`rt_transactions`ストリーム名は廃止予定であり、今後予告なしに削除される可能性があります。
|
||||
|
||||
`books`配列のオブジェクトは、subscribeのオブジェクトと同様に定義されますが、一部のフィールドが含まれていない点が異なります。このオブジェクトのフィールドを次に示します。
|
||||
|
||||
| `Field` | 型 | 説明 |
|
||||
|:-------------|:--------|:----------------------------------------------------|
|
||||
| `taker_gets` | オブジェクト | オファーを受諾するアカウントが受け取る通貨を、[通貨額][]と同様、`currency`フィールドと`issuer`フィールドを持つオブジェクトとして指定します(XRPの場合はissuerを省略)。 |
|
||||
| `taker_pays` | オブジェクト | オファーを受諾するアカウントが支払う通貨を、[通貨額][]と同様、`currency`フィールドと`issuer`フィールドを持つオブジェクトとして指定します(XRPの場合はissuerを省略)。 |
|
||||
| `both` | ブール値 | (省略可、デフォルトではfalse)trueの場合は、オーダーブックの両サイドからサブスクリプションを削除します。 |
|
||||
|
||||
## 応答フォーマット
|
||||
|
||||
処理が成功した応答の例:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```json
|
||||
{
|
||||
"id":"Unsubscribe a lot of stuff",
|
||||
"result":{},
|
||||
"status":"success",
|
||||
"type":"response"
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
この応答は[標準フォーマット][]に従っており、正常に完了した場合は結果にフィールドが含まれません。
|
||||
|
||||
## 考えられるエラー
|
||||
|
||||
* [汎用エラータイプ][]のすべて。
|
||||
* `invalidParams` - 1つ以上のフィールドの指定が正しくないか、1つ以上の必須フィールドが指定されていません。
|
||||
* `noPermission` - 要求に`url`フィールドが指定されていますが、管理者として接続していません。
|
||||
* `malformedStream` - 要求の`streams`フィールドのフォーマットが適切ではありません。
|
||||
* `malformedAccount` - 要求の`accounts`または`accounts_proposed`フィールドのアドレスの1つが、適切なフォーマットのXRP Ledgerアドレスではありません。
|
||||
* **注記:** グローバルレジャーにエントリーがまだ作成されていないアドレスのストリームをサブスクライブ _できます_ 。このようにサブスクライブして、そのアドレスに資金が供給されたらメッセージを受け取ることができます。
|
||||
* `srcCurMalformed` - 要求の`books`フィールドの1つ以上の`taker_pays`サブフィールドのフォーマットが適切ではありません。
|
||||
* `dstAmtMalformed` - 要求の`books`フィールドの1つ以上の`taker_gets`サブフィールドのフォーマットが適切ではありません。
|
||||
* `srcIsrMalformed` - 要求の`books`フィールドの1つ以上の`taker_pays`サブフィールドの`issuer`フィールドが無効です。
|
||||
* `dstIsrMalformed` - 要求の`books`フィールドの1つ以上の`taker_gets`サブフィールドの`issuer`フィールドが無効です。
|
||||
* `badMarket` - `books` フィールドに指定されている1つ以上のオーダーブックが存在していません(ある通貨をその通貨自体と交換するオファーなど)。
|
||||
|
||||
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
@@ -0,0 +1,105 @@
|
||||
---
|
||||
html: unsubscribe.html
|
||||
parent: subscription-methods.html
|
||||
blurb: Stop listening for updates about a particular subject.
|
||||
labels:
|
||||
- Payments
|
||||
- Blockchain
|
||||
- Accounts
|
||||
- Smart Contracts
|
||||
---
|
||||
# unsubscribe
|
||||
[[Source]](https://github.com/ripple/rippled/blob/master/src/ripple/rpc/handlers/Unsubscribe.cpp "Source")
|
||||
|
||||
The `unsubscribe` command tells the server to stop sending messages for a particular subscription or set of subscriptions.
|
||||
|
||||
## Request Format
|
||||
An example of the request format:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Unsubscribe a lot of stuff",
|
||||
"command": "unsubscribe",
|
||||
"streams": ["ledger","server","transactions","transactions_proposed"],
|
||||
"accounts": ["rrpNnNLKrartuEqfJGpqyDwPj1AFPg9vn1"],
|
||||
"accounts_proposed": ["rrpNnNLKrartuEqfJGpqyDwPj1AFPg9vn1"],
|
||||
"books": [
|
||||
{
|
||||
"taker_pays": {
|
||||
"currency": "XRP"
|
||||
},
|
||||
"taker_gets": {
|
||||
"currency": "USD",
|
||||
"issuer": "rUQTpMqAF5jhykj4FExVeXakrZpiKF6cQV"
|
||||
},
|
||||
"both": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
[Try it! >](websocket-api-tool.html#unsubscribe)
|
||||
|
||||
The parameters in the request are specified almost exactly like the parameters to the [subscribe method][], except that they are used to define which subscriptions to end instead. The parameters are:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:--------------------|:------|:-----------------------------------------------|
|
||||
| `streams` | Array | _(Optional)_ Array of string names of generic streams to unsubscribe from, including `ledger`, `server`, `transactions`, and `transactions_proposed`. |
|
||||
| `accounts` | Array | _(Optional)_ Array of unique account addresses to stop receiving updates for, in the XRP Ledger's [base58][] format. (This only stops those messages if you previously subscribed to those accounts specifically. You cannot use this to filter accounts out of the general transactions stream.) |
|
||||
| `accounts_proposed` | Array | _(Optional)_ Like `accounts`, but for `accounts_proposed` subscriptions that included not-yet-validated transactions. |
|
||||
| `books` | Array | _(Optional)_ Array of objects defining order books to unsubscribe from, as explained below. |
|
||||
|
||||
The `rt_accounts` and `url` parameters, and the `rt_transactions` stream name, are deprecated and may be removed without further notice.
|
||||
|
||||
The objects in the `books` array are defined almost like the ones from subscribe, except that they don't have all the fields. The fields they have are as follows:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:-------------|:--------|:----------------------------------------------------|
|
||||
| `taker_gets` | Object | Specification of which currency the account taking the offer would receive, as an object with `currency` and `issuer` fields (omit issuer for XRP), like [currency amounts][Currency Amount]. |
|
||||
| `taker_pays` | Object | Specification of which currency the account taking the offer would pay, as an object with `currency` and `issuer` fields (omit issuer for XRP), like [currency amounts][Currency Amount]. |
|
||||
| `both` | Boolean | (Optional, defaults to false) If true, remove a subscription for both sides of the order book. |
|
||||
|
||||
## Response Format
|
||||
|
||||
An example of a successful response:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "Unsubscribe a lot of stuff",
|
||||
"result": {},
|
||||
"status": "success",
|
||||
"type": "response"
|
||||
}
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
The response follows the [standard format][], with a successful result containing no fields.
|
||||
|
||||
## Possible Errors
|
||||
|
||||
* Any of the [universal error types][].
|
||||
* `invalidParams` - One or more fields are specified incorrectly, or one or more required fields are missing.
|
||||
* `noPermission` - The request included the `url` field, but you are not connected as an admin.
|
||||
* `malformedStream` - The `streams` field of the request is not formatted properly.
|
||||
* `malformedAccount` - One of the addresses in the `accounts` or `accounts_proposed` fields of the request is not a properly-formatted XRP Ledger address.
|
||||
* **Note:** You _can_ subscribe to the stream of an address that does not yet have an entry in the global ledger to get a message when that address becomes funded.
|
||||
* `srcCurMalformed` - One or more `taker_pays` sub-fields of the `books` field in the request is not formatted properly.
|
||||
* `dstAmtMalformed` - One or more `taker_gets` sub-fields of the `books` field in the request is not formatted properly.
|
||||
* `srcIsrMalformed` - The `issuer` field of one or more `taker_pays` sub-fields of the `books` field in the request is not valid.
|
||||
* `dstIsrMalformed` - The `issuer` field of one or more `taker_gets` sub-fields of the `books` field in the request is not valid.
|
||||
* `badMarket` - One or more desired order books in the `books` field does not exist; for example, offers to exchange a currency for itself.
|
||||
|
||||
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
Reference in New Issue
Block a user