2022-09-30 11:40:22 +03:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2019-11-18 07:49:39 +03:00
|
|
|
from dataclasses import dataclass
|
2021-03-10 05:27:27 +03:00
|
|
|
from typing import List, Optional, Tuple
|
2019-11-18 07:49:39 +03:00
|
|
|
|
2023-05-04 21:16:33 +03:00
|
|
|
import chia_rs
|
2022-08-18 20:20:09 +03:00
|
|
|
|
2022-10-18 17:12:22 +03:00
|
|
|
from chia.full_node.fee_estimate import FeeEstimateGroup
|
2021-04-04 06:55:26 +03:00
|
|
|
from chia.types.blockchain_format.coin import Coin
|
2023-01-28 02:20:23 +03:00
|
|
|
from chia.types.blockchain_format.serialized_program import SerializedProgram
|
2021-04-04 06:55:26 +03:00
|
|
|
from chia.types.blockchain_format.sized_bytes import bytes32
|
|
|
|
from chia.types.header_block import HeaderBlock
|
|
|
|
from chia.types.spend_bundle import SpendBundle
|
2022-10-18 17:12:22 +03:00
|
|
|
from chia.util.ints import uint8, uint32, uint64, uint128
|
2021-04-04 06:55:26 +03:00
|
|
|
from chia.util.streamable import Streamable, streamable
|
2019-08-05 11:10:40 +03:00
|
|
|
|
|
|
|
"""
|
|
|
|
Protocol between wallet (SPV node) and full node.
|
2021-02-09 10:14:37 +03:00
|
|
|
Note: When changing this file, also change protocol_message_types.py, and the protocol version in shared_protocol.py
|
2019-08-05 11:10:40 +03:00
|
|
|
"""
|
|
|
|
|
2020-04-17 15:50:24 +03:00
|
|
|
|
2023-05-04 21:16:33 +03:00
|
|
|
CoinState = chia_rs.CoinState
|
|
|
|
RespondToPhUpdates = chia_rs.RespondToPhUpdates
|
2022-08-18 20:20:09 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RequestPuzzleSolution(Streamable):
|
2021-01-02 06:13:08 +03:00
|
|
|
coin_name: bytes32
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2021-01-02 06:13:08 +03:00
|
|
|
|
|
|
|
|
2020-12-10 20:11:26 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-01-02 06:13:08 +03:00
|
|
|
class PuzzleSolutionResponse(Streamable):
|
|
|
|
coin_name: bytes32
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2022-06-13 19:40:58 +03:00
|
|
|
puzzle: SerializedProgram
|
|
|
|
solution: SerializedProgram
|
2021-01-02 06:13:08 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RespondPuzzleSolution(Streamable):
|
2021-01-02 06:13:08 +03:00
|
|
|
response: PuzzleSolutionResponse
|
2020-12-10 20:11:26 +03:00
|
|
|
|
|
|
|
|
2020-04-17 09:17:28 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RejectPuzzleSolution(Streamable):
|
2021-01-02 06:13:08 +03:00
|
|
|
coin_name: bytes32
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2020-04-17 09:17:28 +03:00
|
|
|
|
2019-08-05 11:10:40 +03:00
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class SendTransaction(Streamable):
|
2020-02-07 23:57:41 +03:00
|
|
|
transaction: SpendBundle
|
2019-08-05 11:10:40 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class TransactionAck(Streamable):
|
2020-02-13 03:16:57 +03:00
|
|
|
txid: bytes32
|
2021-02-09 10:14:37 +03:00
|
|
|
status: uint8 # MempoolInclusionStatus
|
2020-03-27 17:30:07 +03:00
|
|
|
error: Optional[str]
|
2020-02-13 03:16:57 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class NewPeakWallet(Streamable):
|
2020-10-30 12:38:56 +03:00
|
|
|
header_hash: bytes32
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2020-03-04 11:53:51 +03:00
|
|
|
weight: uint128
|
2020-11-30 10:29:15 +03:00
|
|
|
fork_point_with_previous_peak: uint32
|
2020-03-04 11:53:51 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-12 23:24:33 +03:00
|
|
|
class RequestBlockHeader(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2019-12-02 21:38:00 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-12 23:24:33 +03:00
|
|
|
class RespondBlockHeader(Streamable):
|
2020-03-04 11:53:51 +03:00
|
|
|
header_block: HeaderBlock
|
2019-08-05 11:10:40 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RejectHeaderRequest(Streamable):
|
2020-02-13 23:15:36 +03:00
|
|
|
height: uint32
|
2020-02-12 00:00:41 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RequestRemovals(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2020-03-04 11:53:51 +03:00
|
|
|
header_hash: bytes32
|
|
|
|
coin_names: Optional[List[bytes32]]
|
2020-02-12 00:00:41 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RespondRemovals(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2020-03-04 11:53:51 +03:00
|
|
|
header_hash: bytes32
|
|
|
|
coins: List[Tuple[bytes32, Optional[Coin]]]
|
|
|
|
proofs: Optional[List[Tuple[bytes32, bytes]]]
|
2020-02-23 11:11:31 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RejectRemovalsRequest(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2020-02-23 11:11:31 +03:00
|
|
|
header_hash: bytes32
|
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RequestAdditions(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2021-09-18 20:27:34 +03:00
|
|
|
header_hash: Optional[bytes32]
|
2020-03-04 11:53:51 +03:00
|
|
|
puzzle_hashes: Optional[List[bytes32]]
|
2020-02-23 11:11:31 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RespondAdditions(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2020-02-23 11:11:31 +03:00
|
|
|
header_hash: bytes32
|
2020-03-04 11:53:51 +03:00
|
|
|
coins: List[Tuple[bytes32, List[Coin]]]
|
|
|
|
proofs: Optional[List[Tuple[bytes32, bytes, Optional[bytes]]]]
|
2020-02-23 11:11:31 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RejectAdditionsRequest(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
height: uint32
|
2020-04-09 05:54:42 +03:00
|
|
|
header_hash: bytes32
|
2021-01-11 08:30:42 +03:00
|
|
|
|
|
|
|
|
2022-06-11 09:35:41 +03:00
|
|
|
@streamable
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
class RespondBlockHeaders(Streamable):
|
|
|
|
start_height: uint32
|
|
|
|
end_height: uint32
|
|
|
|
header_blocks: List[HeaderBlock]
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
class RejectBlockHeaders(Streamable):
|
|
|
|
start_height: uint32
|
|
|
|
end_height: uint32
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
class RequestBlockHeaders(Streamable):
|
|
|
|
start_height: uint32
|
|
|
|
end_height: uint32
|
|
|
|
return_filter: bool
|
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RequestHeaderBlocks(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
start_height: uint32
|
|
|
|
end_height: uint32
|
2021-01-11 08:30:42 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RejectHeaderBlocks(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
start_height: uint32
|
|
|
|
end_height: uint32
|
2021-01-11 08:30:42 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class RespondHeaderBlocks(Streamable):
|
2021-02-10 07:49:47 +03:00
|
|
|
start_height: uint32
|
|
|
|
end_height: uint32
|
2021-01-11 08:30:42 +03:00
|
|
|
header_blocks: List[HeaderBlock]
|
2021-09-18 20:27:34 +03:00
|
|
|
|
|
|
|
|
2022-08-18 20:20:09 +03:00
|
|
|
# This class is implemented in Rust
|
|
|
|
# @streamable
|
|
|
|
# @dataclass(frozen=True)
|
|
|
|
# class CoinState(Streamable):
|
|
|
|
# coin: Coin
|
|
|
|
# spent_height: Optional[uint32]
|
|
|
|
# created_height: Optional[uint32]
|
2021-09-18 20:27:34 +03:00
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-18 20:27:34 +03:00
|
|
|
class RegisterForPhUpdates(Streamable):
|
|
|
|
puzzle_hashes: List[bytes32]
|
|
|
|
min_height: uint32
|
|
|
|
|
|
|
|
|
2022-08-18 20:20:09 +03:00
|
|
|
# This class is implemented in Rust
|
|
|
|
# @streamable
|
|
|
|
# @dataclass(frozen=True)
|
|
|
|
# class RespondToPhUpdates(Streamable):
|
|
|
|
# puzzle_hashes: List[bytes32]
|
|
|
|
# min_height: uint32
|
|
|
|
# coin_states: List[CoinState]
|
2021-09-18 20:27:34 +03:00
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-18 20:27:34 +03:00
|
|
|
class RegisterForCoinUpdates(Streamable):
|
|
|
|
coin_ids: List[bytes32]
|
|
|
|
min_height: uint32
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-18 20:27:34 +03:00
|
|
|
class RespondToCoinUpdates(Streamable):
|
|
|
|
coin_ids: List[bytes32]
|
|
|
|
min_height: uint32
|
|
|
|
coin_states: List[CoinState]
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-18 20:27:34 +03:00
|
|
|
class CoinStateUpdate(Streamable):
|
|
|
|
height: uint32
|
|
|
|
fork_height: uint32
|
|
|
|
peak_hash: bytes32
|
|
|
|
items: List[CoinState]
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-18 20:27:34 +03:00
|
|
|
class RequestChildren(Streamable):
|
|
|
|
coin_name: bytes32
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-18 20:27:34 +03:00
|
|
|
class RespondChildren(Streamable):
|
|
|
|
coin_states: List[CoinState]
|
2021-09-30 01:04:29 +03:00
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-30 01:04:29 +03:00
|
|
|
class RequestSESInfo(Streamable):
|
|
|
|
start_height: uint32
|
|
|
|
end_height: uint32
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-09-30 01:04:29 +03:00
|
|
|
class RespondSESInfo(Streamable):
|
|
|
|
reward_chain_hash: List[bytes32]
|
|
|
|
heights: List[List[uint32]]
|
2022-10-18 17:12:22 +03:00
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
class RequestFeeEstimates(Streamable):
|
|
|
|
"""
|
|
|
|
time_targets (List[uint64]): Epoch timestamps in seconds to estimate FeeRates for.
|
|
|
|
"""
|
|
|
|
|
|
|
|
time_targets: List[uint64]
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
class RespondFeeEstimates(Streamable):
|
|
|
|
estimates: FeeEstimateGroup
|