pwa_validate
(Added by the PWALoader amendment.)
The pwa_validate method checks whether a document a client was served is the account’s current AppLoader document, as of the validated ledger. It is intended for clients such as browser extensions that want to vet a document served by one node against a second node.
Request Format
Section titled “Request Format”{ "command": "pwa_validate", "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "hash": "<hex SHA-512Half of the document bytes served>", "domain": "app.example.org"}Command line:
xahaud pwa_validate <account> <hash> [<domain>]Request Parameters
Section titled “Request Parameters”| Field | JSON Type | Required? | Description |
|---|---|---|---|
account | String | Yes | The address of the account that published the document. |
hash | String | Yes | The SHA-512Half of the document bytes that were served, as hex. |
domain | String | No | The host the document was served from. If given, the account’s Domain must equal it or be a parent of it (case-insensitive). For example, an account with Domain example.org endorses example.org and app.example.org. |
Response Format
Section titled “Response Format”{ "result": { "ledger_index": 12345678, "app_loader_sequence": 4, "valid": true, "status": "success" }}Response Fields
Section titled “Response Fields”| Field | JSON Type | Description |
|---|---|---|
ledger_index | Number | The validated ledger the check was made against. |
app_loader_sequence | Number | The AppLoaderSequence of the account’s current document. |
valid | Boolean | true if the hash matches the current document (and the domain, if given, is endorsed by the account). |
reason | String | (Only when valid is false) One of "no loader", "hash mismatch" or "domain not endorsed by account". |
If the client was served from an older ledger (the X-LedgerSeq response header) than the returned ledger_index and gets "hash mismatch", it should simply reload the document.
Possible Errors
Section titled “Possible Errors”- Any of the universal error types.
actMalformed: theaccountis not a valid address.invalidParams: thehashis not a valid 32-byte hex value.notSynced: the server is not synced to the network.