Create "Ravencoin GPT"

This commit is contained in:
Elias Bachaalany 2024-02-17 08:58:50 -08:00
parent 05df4052e8
commit ac887e5ea8
7 changed files with 1549 additions and 0 deletions

View file

@ -0,0 +1,165 @@
getaddressbalance
Returns the balance for an address(es) (requires addressindex to be enabled).
Arguments:
{
"addresses:"
[
"address" (string) The base58check encoded address
,...
]
},
"includeAssets" (boolean, optional, default false) If true this will return an expanded result which includes asset balances
Result:
{
"balance" (string) The current balance in satoshis
"received" (string) The total number of satoshis received (including change)
}
OR
[
{
"assetName" (string) The asset associated with the balance (RVN for Ravencoin)
"balance" (string) The current balance in satoshis
"received" (string) The total number of satoshis received (including change)
},...
]
Examples:
> raven-cli getaddressbalance '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}'
> raven-cli getaddressbalance '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}', true
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressbalance", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressbalance", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}, true] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
getaddressdeltas
Returns all changes for an address (requires addressindex to be enabled).
Arguments:
{
"addresses"
[
"address" (string) The base58check encoded address
,...
]
"start" (number) The start block height
"end" (number) The end block height
"chainInfo" (boolean) Include chain info in results, only applies if start and end specified
"assetName" (string, optional) Get deltas for a particular asset instead of RVN.
}
Result:
[
{
"assetName" (string) The asset associated with the deltas (RVN for Ravencoin)
"satoshis" (number) The difference of satoshis
"txid" (string) The related txid
"index" (number) The related input or output index
"height" (number) The block height
"address" (string) The base58check encoded address
}
]
Examples:
> raven-cli getaddressdeltas '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}'
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressdeltas", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
> raven-cli getaddressdeltas '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"],"assetName":"MY_ASSET"}'
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressdeltas", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"],"assetName":"MY_ASSET"}] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
getaddressmempool
Returns all mempool deltas for an address (requires addressindex to be enabled).
Arguments:
{
"addresses"
[
"address" (string) The base58check encoded address
,...
]
},
"includeAssets" (boolean, optional, default false) If true this will return an expanded result which includes asset deltas
Result:
[
{
"address" (string) The base58check encoded address
"assetName" (string) The name of the associated asset (RVN for Ravencoin)
"txid" (string) The related txid
"index" (number) The related input or output index
"satoshis" (number) The difference of satoshis
"timestamp" (number) The time the transaction entered the mempool (seconds)
"prevtxid" (string) The previous txid (if spending)
"prevout" (string) The previous transaction output index (if spending)
}
]
Examples:
> raven-cli getaddressmempool '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}'
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressmempool", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
> raven-cli getaddressmempool '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}', true
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressmempool", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}, true] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
getaddresstxids
Returns the txids for an address(es) (requires addressindex to be enabled).
Arguments:
{
"addresses"
[
"address" (string) The base58check encoded address
,...
]
"start" (number, optional) The start block height
"end" (number, optional) The end block height
},
"includeAssets" (boolean, optional, default false) If true this will return an expanded result which includes asset transactions
Result:
[
"transactionid" (string) The transaction id
,...
]
Examples:
> raven-cli getaddresstxids '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}'
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddresstxids", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
> raven-cli getaddresstxids '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}', true
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddresstxids", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}, true] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
getaddressutxos
Returns all unspent outputs for an address (requires addressindex to be enabled).
Arguments:
{
"addresses"
[
"address" (string) The base58check encoded address
,...
],
"chainInfo", (boolean, optional, default false) Include chain info with results
"assetName" (string, optional) Get UTXOs for a particular asset instead of RVN ('*' for all assets).
}
Result
[
{
"address" (string) The address base58check encoded
"assetName" (string) The asset associated with the UTXOs (RVN for Ravencoin)
"txid" (string) The output txid
"height" (number) The block height
"outputIndex" (number) The output index
"script" (strin) The script hex encoded
"satoshis" (number) The number of satoshis of the output
}
]
Examples:
> raven-cli getaddressutxos '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}'
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressutxos", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"]}] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
> raven-cli getaddressutxos '{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"],"assetName":"MY_ASSET"}'
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressutxos", "params": [{"addresses": ["12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"],"assetName":"MY_ASSET"}] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/

View file

@ -0,0 +1,100 @@
getassetdata "asset_name"
Returns assets metadata if that asset exists
Arguments:
1. "asset_name" (string, required) the name of the asset
Result:
{
name: (string),
amount: (number),
units: (number),
reissuable: (number),
has_ipfs: (number),
ipfs_hash: (hash), (only if has_ipfs = 1 and that data is a ipfs hash)
txid_hash: (hash), (only if has_ipfs = 1 and that data is a txid hash)
verifier_string: (string)
}
Examples:
> raven-cli getassetdata "ASSET_NAME"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getassetdata", "params": ["ASSET_NAME"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
listaddressesbyasset "asset_name" (onlytotal) (count) (start)
Returns a list of all address that own the given asset (with balances)
Or returns the total size of how many address own the given asset
Arguments:
1. "asset_name" (string, required) name of asset
2. "onlytotal" (boolean, optional, default=false) when false result is just a list of addresses with balances -- when true the result is just a single number representing the number of addresses
3. "count" (integer, optional, default=50000, MAX=50000) truncates results to include only the first _count_ assets found
4. "start" (integer, optional, default=0) results skip over the first _start_ assets found (if negative it skips back from the end)
Result:
[ (address): balance,
...
]
Examples:
> raven-cli listaddressesbyasset "ASSET_NAME" false 2 0
> raven-cli listaddressesbyasset "ASSET_NAME" true
> raven-cli listaddressesbyasset "ASSET_NAME"
listassetbalancesbyaddress "address" (onlytotal) (count) (start)
Returns a list of all asset balances for an address.
Arguments:
1. "address" (string, required) a raven address
2. "onlytotal" (boolean, optional, default=false) when false result is just a list of assets balances -- when true the result is just a single number representing the number of assets
3. "count" (integer, optional, default=50000, MAX=50000) truncates results to include only the first _count_ assets found
4. "start" (integer, optional, default=0) results skip over the first _start_ assets found (if negative it skips back from the end)
Result:
{
(asset_name) : (quantity),
...
}
Examples:
> raven-cli listassetbalancesbyaddress "myaddress" false 2 0
> raven-cli listassetbalancesbyaddress "myaddress" true
> raven-cli listassetbalancesbyaddress "myaddress"
listassets "( asset )" ( verbose ) ( count ) ( start )
Returns a list of all assets
This could be a slow/expensive operation as it reads from the database
Arguments:
1. "asset" (string, optional, default="*") filters results -- must be an asset name or a partial asset name followed by '*' ('*' matches all trailing characters)
2. "verbose" (boolean, optional, default=false) when false result is just a list of asset names -- when true results are asset name mapped to metadata
3. "count" (integer, optional, default=ALL) truncates results to include only the first _count_ assets found
4. "start" (integer, optional, default=0) results skip over the first _start_ assets found (if negative it skips back from the end)
Result (verbose=false):
[
asset_name,
...
]
Result (verbose=true):
{
(asset_name):
{
amount: (number),
units: (number),
reissuable: (number),
has_ipfs: (number),
ipfs_hash: (hash) (only if has_ipfs = 1 and data is a ipfs hash)
ipfs_hash: (hash) (only if has_ipfs = 1 and data is a txid hash)
},
{...}, {...}
}
Examples:
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listassets", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
> raven-cli listassets ASSET
> raven-cli listassets "ASSET*" true 10 20

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
Interpret and handle user requests to identify the specific RPC method required. A list of categorized whitelisted methods can be found in the 'RPC-Method=Whitelist' file while the documentation for each category can be found in their respective files - 'AddressIndex RPC Methods', 'Assets RPC Methods', 'Blockchain RPC Methods', 'Rawtransactions RPC Methods', 'Restricted assets RPC Methods', 'Utility RPC Methods'.
Below in quotes is the schema structure for the whitelisted RPC methods:
"openapi: 3.0.0
info:
title: Ravencoin Mainnet API
version: "1.0"
servers:
- url: https://rvn-rpc-mainnet.ting.finance
paths:
/rpc:
post:
summary: Generic endpoint to interact with Ravencoin RPC methods
operationId: callRpcMethod
x-openai-isConsequential: true
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
jsonrpc:
type: string
example: "1.0"
id:
type: string
example: "curltest"
method:
type: string
example: "getblockchaininfo" # Replace with the actual method name
params:
type: array
description: "Array of parameters required by the RPC method"
items: {}
responses:
'200':
description: RPC call response
content:
application/json:
schema:
type: object
properties:
result:
type: object # The structure of the result will depend on the method called
error:
type: object
nullable: true
id:
type: string
security:
- basicAuth: []
components:
securitySchemes:
basicAuth:
type: http
scheme: basic
schemas: {}"
For a method like getaddressbalance, which requires an address as a parameter, the request body should include that address within the params array. Heres an example of how to structure the request for getaddressbalance:
{
"jsonrpc": "1.0",
"id": "curltest",
"method": "getaddressbalance",
"params": [{"addresses": ["address_here"]}]
}
'help' RPC method:
help ( "command" )
List all commands, or get help for a specified command.
Arguments:
1. "command" (string, optional) The command to get help on
Result:
"text" (string) The help text

View file

@ -0,0 +1,59 @@
Whitelisted methods/procedures for https://rvn-rpc-mainnet.ting.finance/rpc
/== Addressindex ==
"getaddressbalance",
"getaddressdeltas",
"getaddressmempool",
"getaddresstxids",
"getaddressutxos"
//== Assets ==
"getassetdata",
"listaddressesbyasset",
"listassetbalancesbyaddress",
"listassets"
//== Blockchain ==
"decodeblock",
"getbestblockhash",
"getblock",
"getblockchaininfo",
"getblockcount",
"getblockhash",
"getblockheader",
"getchaintips",
"getchaintxstats",
"getdifficulty",
"getmempoolancestors",
"getmempooldescendants",
"getmempoolentry",
"getmempoolinfo",
"getrawmempool",
"getspentinfo",
"gettxout",
"gettxoutproof"
//== Control ==
"help"
//== Rawtransactions ==
"combinerawtransaction",
"createrawtransaction",
"decoderawtransaction",
"decodescript",
"getrawtransaction",
"sendrawtransaction",
"signrawtransaction",
"testmempoolaccept"
//== Restricted assets ==
"checkaddressrestriction",
"checkaddresstag",
"checkglobalrestriction",
"getverifierstring",
"isvalidverifierstring",
"listaddressesfortag",
"listaddressrestrictions",
"listglobalrestrictions",
"listtagsforaddress"
//== Util ==
"estimatefee",
"estimatesmartfee",
"signmessagewithprivkey",
"validateaddress",
"verifymessage"