2026-05-24 17:56:57 +00:00
|
|
|
use crate::blocks::burn::BurnTransaction;
|
|
|
|
|
use crate::blocks::collateral::CollateralClaimTransaction;
|
|
|
|
|
use crate::blocks::genesis::GenesisTransaction;
|
|
|
|
|
use crate::blocks::issue_token::IssueTokenTransaction;
|
|
|
|
|
use crate::blocks::loan_payment::ContractPaymentTransaction;
|
|
|
|
|
use crate::blocks::loans::LoanContractTransaction;
|
|
|
|
|
use crate::blocks::marketing::MarketingTransaction;
|
|
|
|
|
use crate::blocks::nft::CreateNftTransaction;
|
|
|
|
|
use crate::blocks::rewards::RewardsTransaction;
|
|
|
|
|
use crate::blocks::swap::SwapTransaction;
|
|
|
|
|
use crate::blocks::token::CreateTokenTransaction;
|
|
|
|
|
use crate::blocks::transfer::TransferTransaction;
|
|
|
|
|
use crate::blocks::vanity::VanityAddressTransaction;
|
|
|
|
|
|
|
|
|
|
pub const RPC_NETWORK_INFO: u8 = 1;
|
|
|
|
|
pub const RPC_BLOCK_HEIGHT: u8 = 2;
|
|
|
|
|
pub const RPC_RANDOM_NODE: u8 = 3;
|
|
|
|
|
pub const RPC_TIME: u8 = 4;
|
|
|
|
|
pub const RPC_DIFFICULTY: u8 = 5;
|
|
|
|
|
pub const RPC_VALIDATE_TORRENT: u8 = 6;
|
|
|
|
|
pub const RPC_BLOCK_PIECE: u8 = 7;
|
|
|
|
|
pub const RPC_SUBMIT_TRANSACTION: u8 = 8;
|
|
|
|
|
pub const RPC_BLOCK_BY_HEIGHT: u8 = 9;
|
|
|
|
|
pub const RPC_BLOCK_BY_HASH: u8 = 10;
|
|
|
|
|
pub const RPC_LATEST_BLOCK: u8 = 11;
|
|
|
|
|
pub const RPC_TORRENT_BY_HEIGHT: u8 = 12;
|
|
|
|
|
pub const RPC_LARGEST_TX_FEE: u8 = 13;
|
|
|
|
|
pub const RPC_MEMPOOL_TX_BY_SIGNATURE: u8 = 14;
|
|
|
|
|
pub const RPC_MEMPOOL_TX_COUNT: u8 = 15;
|
|
|
|
|
pub const RPC_MEMPOOL_TX_BY_ADDRESS: u8 = 16;
|
|
|
|
|
pub const RPC_TRANSACTION_BY_TXID: u8 = 17;
|
|
|
|
|
pub const RPC_TOTAL_CONFIRMED_TX: u8 = 18;
|
|
|
|
|
pub const RPC_HEADER_BY_HEIGHT: u8 = 19;
|
|
|
|
|
pub const RPC_HEADER_BY_HASH: u8 = 20;
|
|
|
|
|
pub const RPC_ALL_HEADERS: u8 = 21;
|
|
|
|
|
pub const RPC_ADDRESS_COIN_BALANCE: u8 = 22;
|
|
|
|
|
pub const RPC_ADDRESS_TOTAL_BALANCE: u8 = 23;
|
|
|
|
|
pub const RPC_VALIDATE_ADDRESS: u8 = 24;
|
|
|
|
|
pub const RPC_VALIDATE_MESSAGE: u8 = 25;
|
|
|
|
|
pub const RPC_BLOCK_IP: u8 = 26;
|
|
|
|
|
pub const RPC_UNBLOCK_IP: u8 = 27;
|
|
|
|
|
pub const RPC_ADD_NETWORK_NODE: u8 = 28;
|
|
|
|
|
pub const RPC_REQUEST_NODE_LIST: u8 = 30;
|
|
|
|
|
pub const RPC_TOKEN_LIST: u8 = 31;
|
|
|
|
|
pub const RPC_NFT_LIST: u8 = 32;
|
|
|
|
|
pub const RPC_LOAN_CONTRACT: u8 = 33;
|
|
|
|
|
pub const RPC_SUBMIT_TORRENT: u8 = 34;
|
|
|
|
|
pub const RPC_TOKEN_DETAILS: u8 = 35;
|
|
|
|
|
pub const RPC_NFT_DETAILS: u8 = 36;
|
|
|
|
|
pub const RPC_CONTRACT_BY_ADDRESS: u8 = 37;
|
|
|
|
|
pub const RPC_REGISTER_WALLET: u8 = 38;
|
|
|
|
|
pub const RPC_WALLET_REGISTRY_SYNC: u8 = 39;
|
|
|
|
|
pub const RPC_VANITY_LOOKUP: u8 = 40;
|
|
|
|
|
pub const RPC_TORRENT_CANDIDATES: u8 = 41;
|
2026-06-01 14:29:11 +00:00
|
|
|
pub const RPC_BLOCK_HASH_AT_HEIGHT: u8 = 42;
|
2026-06-12 16:27:28 +00:00
|
|
|
pub const RPC_WALLET_REGISTRATION_STATUS: u8 = 43;
|
|
|
|
|
pub const RPC_ADDRESS_HISTORY: u8 = 44;
|
2026-06-04 15:06:51 +00:00
|
|
|
pub const RPC_VANITY_OWNER_LOOKUP: u8 = 45;
|
2026-06-21 00:49:22 +00:00
|
|
|
pub const RPC_LATEST_ADDRESS_TRANSACTIONS: u8 = 46;
|
2026-05-24 17:56:57 +00:00
|
|
|
pub const RPC_REPLY: u8 = 255;
|
|
|
|
|
pub const MAX_RPC_REPLY_BYTES: usize = 64 * 1024 * 1024;
|
|
|
|
|
|
|
|
|
|
// this allows us to define the byte size of the expected messagew
|
|
|
|
|
// so we can have different transaction types have different bytes
|
|
|
|
|
// and easily read them from stream as well as calculate the position
|
|
|
|
|
// in the binary file.
|
|
|
|
|
pub fn get_bytes(tx_type: u8) -> usize {
|
|
|
|
|
// These sizes include the leading tx type byte stored in the saved block format.
|
|
|
|
|
match tx_type {
|
|
|
|
|
0 => GenesisTransaction::BYTE_LENGTH,
|
|
|
|
|
1 => RewardsTransaction::BYTE_LENGTH,
|
|
|
|
|
2 => TransferTransaction::BYTE_LENGTH,
|
|
|
|
|
3 => CreateTokenTransaction::BYTE_LENGTH,
|
|
|
|
|
4 => CreateNftTransaction::BYTE_LENGTH,
|
|
|
|
|
5 => MarketingTransaction::BYTE_LENGTH,
|
|
|
|
|
6 => SwapTransaction::BYTE_LENGTH,
|
|
|
|
|
7 => LoanContractTransaction::BYTE_LENGTH,
|
|
|
|
|
8 => ContractPaymentTransaction::BYTE_LENGTH,
|
|
|
|
|
9 => CollateralClaimTransaction::BYTE_LENGTH,
|
|
|
|
|
10 => BurnTransaction::BYTE_LENGTH,
|
|
|
|
|
11 => IssueTokenTransaction::BYTE_LENGTH,
|
|
|
|
|
12 => VanityAddressTransaction::BYTE_LENGTH,
|
|
|
|
|
_ => 0,
|
|
|
|
|
}
|
|
|
|
|
}
|