Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to get the aggsig additional data from full node RPC #17241

Merged
merged 9 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions chia/rpc/full_node_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def get_routes(self) -> Dict[str, Endpoint]:
"/get_unfinished_block_headers": self.get_unfinished_block_headers,
"/get_network_space": self.get_network_space,
"/get_additions_and_removals": self.get_additions_and_removals,
"/get_aggsig_additional_data": self.get_aggsig_additional_data,
# this function is just here for backwards-compatibility. It will probably
# be removed in the future
"/get_initial_freeze_period": self.get_initial_freeze_period,
Expand Down Expand Up @@ -806,6 +807,9 @@ async def get_additions_and_removals(self, request: Dict[str, Any]) -> EndpointR
"removals": [coin_record_dict_backwards_compat(cr.to_json_dict()) for cr in removals],
}

async def get_aggsig_additional_data(self, _: Dict[str, Any]) -> EndpointResult:
return {"additional_data": self.service.constants.AGG_SIG_ME_ADDITIONAL_DATA.hex()}

async def get_all_mempool_tx_ids(self, _: Dict[str, Any]) -> EndpointResult:
ids = list(self.service.mempool_manager.mempool.all_item_ids())
return {"tx_ids": ids}
Expand Down
6 changes: 6 additions & 0 deletions chia/rpc/full_node_rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ async def get_coin_records_by_parent_ids(
response = await self.fetch("get_coin_records_by_parent_ids", d)
return [CoinRecord.from_json_dict(coin_record_dict_backwards_compat(coin)) for coin in response["coin_records"]]

async def get_aggsig_additional_data(self) -> str:
matt-o-how marked this conversation as resolved.
Show resolved Hide resolved
result = await self.fetch("get_aggsig_additional_data", {})
add_data: str = result["additional_data"]
assert add_data is not None
matt-o-how marked this conversation as resolved.
Show resolved Hide resolved
return add_data

async def get_coin_records_by_hint(
self,
hint: bytes32,
Expand Down
2 changes: 2 additions & 0 deletions tests/core/test_full_node_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@ async def test_get_blockchain_state(one_wallet_and_one_simulator_services, self_
# When supplying genesis block, there are no older blocks so `None` should be returned
assert await get_average_block_time(full_node_api_1.full_node.blockchain, block_records[0], 4608) is None
assert await get_average_block_time(full_node_api_1.full_node.blockchain, block_records[-1], 4608) is not None
# Test that get_aggsig_additional_data() returns correctly
assert full_node_api_1.full_node.constants.AGG_SIG_ME_ADDITIONAL_DATA == bytes.fromhex(await client.get_aggsig_additional_data())

finally:
# Checks that the RPC manages to stop the node
Expand Down