Module Pool
RPC Module Pool for transaction memory pool.
Method send_transaction
send_transaction(tx, outputs_validator)tx:Transactionoutputs_validator:OutputsValidator|null
- result:
H256
Submits a new transaction into the transaction pool. If the transaction is already in the pool, rebroadcast it to peers.
Please note that send_transaction is an asynchronous process.
The return of send_transaction does NOT indicate that the transaction have been fully verified.
If you want to track the status of the transaction, please use the get_transactionrpc.
Params
transaction- The transaction.outputs_validator- Validates the transaction outputs before entering the tx-pool. (Optional, default is "passthrough").
Errors
PoolRejectedTransactionByOutputsValidator (-1102)- The transaction is rejected by the validator specified byoutputs_validator. If you really want to send transactions with advanced scripts, please setoutputs_validatorto "passthrough".PoolRejectedTransactionByMinFeeRate (-1104)- The transaction fee rate must be greater than or equal to the config optiontx_pool.min_fee_rate.PoolRejectedTransactionByMaxAncestorsCountLimit (-1105)- The ancestors count must be greater than or equal to the config optiontx_pool.max_ancestors_count.PoolIsFull (-1106)- Pool is full.PoolRejectedDuplicatedTransaction (-1107)- The transaction is already in the pool.TransactionFailedToResolve (-301)- Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.TransactionFailedToVerify (-302)- Failed to verify the transaction.
Example
Use a native SQIsign transaction with a signed witness and current unspent inputs. Save just the transaction object to signed-transaction.json before calling this method.
jq -c '{jsonrpc:"2.0",id:1,method:"send_transaction",params:[., "well_known_scripts_only"]}' signed-transaction.json |
curl -fsS http://127.0.0.1:8114 -H 'Content-Type: application/json' --data-binary @-
Method test_tx_pool_accept
test_tx_pool_accept(tx, outputs_validator)tx:Transactionoutputs_validator:OutputsValidator|null
- result:
EntryCompleted
Test if a transaction can be accepted by the transaction pool without inserting it into the pool or rebroadcasting it to peers.
The parameters and errors of this method are the same as send_transaction.
Params
transaction- The transaction.outputs_validator- Validates the transaction outputs before entering the tx-pool. (Optional, default is "passthrough").
Errors
PoolRejectedTransactionByOutputsValidator (-1102)- The transaction is rejected by the validator specified byoutputs_validator. If you really want to send transactions with advanced scripts, please setoutputs_validatorto "passthrough".PoolRejectedTransactionByMinFeeRate (-1104)- The transaction fee rate must be greater than or equal to the config optiontx_pool.min_fee_rate.PoolRejectedTransactionByMaxAncestorsCountLimit (-1105)- The ancestors count must be greater than or equal to the config optiontx_pool.max_ancestors_count.PoolIsFull (-1106)- Pool is full.PoolRejectedDuplicatedTransaction (-1107)- The transaction is already in the pool.TransactionFailedToResolve (-301)- Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.TransactionFailedToVerify (-302)- Failed to verify the transaction.
Example
Use a native SQIsign transaction with a signed witness and current unspent inputs. Save just the transaction object to signed-transaction.json before calling this method.
jq -c '{jsonrpc:"2.0",id:1,method:"test_tx_pool_accept",params:[., "well_known_scripts_only"]}' signed-transaction.json |
curl -fsS http://127.0.0.1:8114 -H 'Content-Type: application/json' --data-binary @-
Method remove_transaction
remove_transaction(tx_hash)tx_hash:H256
- result:
boolean
Removes a transaction and all transactions which depends on it from tx pool if it exists.
Params
tx_hash- Hash of a transaction.
Returns
If the transaction exists, return true; otherwise, return false.
Method tx_pool_info
-
tx_pool_info() -
result:
TxPoolInfo
Returns the transaction pool information.
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tx_pool_info",
"params": []
}
Response
{
"jsonrpc": "2.0",
"result": {
"last_txs_updated_at": "0x0",
"max_tx_pool_size": "0xaba9500",
"min_fee_rate": "0x3e8",
"min_rbf_rate": "0x5dc",
"orphan": "0x0",
"pending": "0x0",
"proposed": "0x0",
"tip_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
"tip_number": "0x0",
"total_tx_cycles": "0x0",
"total_tx_size": "0x0",
"tx_size_limit": "0x7d000",
"verify_queue_size": "0x0"
},
"id": 1
}
Method clear_tx_pool
-
clear_tx_pool() -
result:
null
Removes all transactions from the transaction pool.
Method clear_tx_verify_queue
-
clear_tx_verify_queue() -
result:
null
Removes all transactions from the verification queue.
Method get_raw_tx_pool
get_raw_tx_pool(verbose)verbose:boolean|null
- result:
RawTxPool
Returns all transaction ids in tx pool as a json array of string transaction ids.
Params
verbose- True for a json object, false for array of transaction ids, default=false
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "get_raw_tx_pool",
"params": [
true
]
}
Response
{
"jsonrpc": "2.0",
"result": {
"conflicted": [],
"pending": {},
"proposed": {}
},
"id": 1
}
Method get_pool_tx_detail_info
get_pool_tx_detail_info(tx_hash)tx_hash:H256
- result:
PoolTxDetailInfo
Query and returns the details of a transaction in the pool, only for trouble shooting
Params
tx_hash- Hash of a transaction
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "get_pool_tx_detail_info",
"params": [
"0xd43a26b1897c98a5917cd7f8af629e2f749ac37142068ef93c11048e208eff42"
]
}
Response
{
"jsonrpc": "2.0",
"result": {
"ancestors_count": "0x0",
"descendants_count": "0x0",
"entry_status": "unknown",
"pending_count": "0x0",
"proposed_count": "0x0",
"rank_in_pending": "0x0",
"score_sortkey": {
"ancestors_fee": "0x0",
"ancestors_weight": "0x0",
"fee": "0x0",
"weight": "0x0"
},
"timestamp": "0x0"
},
"id": 1
}
Method tx_pool_ready
-
tx_pool_ready() -
result:
boolean
Returns whether tx-pool service is started, ready for request.
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tx_pool_ready",
"params": []
}
Response
{
"jsonrpc": "2.0",
"result": true,
"id": 1
}