• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tari-project / tari / 19331017872

13 Nov 2025 12:08PM UTC coverage: 51.536% (+0.001%) from 51.535%
19331017872

push

github

SWvheerden
chore: new release v5.2.0-pre.3

59163 of 114799 relevant lines covered (51.54%)

82795.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/base_layer/core/src/base_node/rpc/mod.rs
1
// Copyright 2025 The Tari Project
2
// SPDX-License-Identifier: BSD-3-Clause
3

4
mod service;
5

6
pub mod sync_utxos_by_block_task;
7

8
pub use service::BaseNodeWalletRpcService;
9

10
pub mod query_service;
11

12
use std::{error::Error, fmt::Debug};
13

14
use tari_comms::{
15
    protocol::rpc::{Request, Response, RpcStatus, Streaming},
16
    types::CompressedSignature,
17
};
18
use tari_comms_rpc_macros::tari_rpc;
19
use tari_transaction_components::rpc::{models, models::GenerateKernelMerkleProofResponse};
20
use url::Url;
21

22
use crate::{
23
    base_node::StateMachineHandle,
24
    chain_storage::{async_db::AsyncBlockchainDb, BlockchainBackend},
25
    mempool::service::MempoolHandle,
26
    proto::{
27
        self,
28
        base_node::{
29
            FetchMatchingUtxos,
30
            FetchUtxosResponse,
31
            GetMempoolFeePerGramStatsRequest,
32
            GetMempoolFeePerGramStatsResponse,
33
            GetWalletQueryHttpServiceAddressResponse,
34
            QueryDeletedRequest,
35
            QueryDeletedResponse,
36
            Signatures,
37
            SyncUtxosByBlockRequest,
38
            SyncUtxosByBlockResponse,
39
            TipInfoResponse,
40
            TxQueryBatchResponses,
41
            TxQueryResponse,
42
            TxSubmissionResponse,
43
            UtxoQueryRequest,
44
            UtxoQueryResponses,
45
        },
46
        types::{Signature, Transaction},
47
    },
48
};
49

50
/// Trait that a base node wallet query service must implement.
51
/// Please note that this service is to fetch data, so read-only queries.
52
#[async_trait::async_trait]
53
pub trait BaseNodeWalletQueryService: Send + Sync + 'static {
54
    type Error: Error + 'static;
55

56
    async fn get_tip_info(&self) -> Result<models::TipInfoResponse, Self::Error>;
57

58
    async fn get_header_by_height(&self, height: u64) -> Result<models::BlockHeader, Self::Error>;
59

60
    async fn get_height_at_time(&self, epoch_time: u64) -> Result<u64, Self::Error>;
61

62
    async fn get_utxos_mined_info(
63
        &self,
64
        request: models::GetUtxosMinedInfoRequest,
65
    ) -> Result<models::GetUtxosMinedInfoResponse, Self::Error>;
66

67
    async fn get_utxos_by_block(
68
        &self,
69
        request: models::GetUtxosByBlockRequest,
70
    ) -> Result<models::GetUtxosByBlockResponse, Self::Error>;
71

72
    async fn transaction_query(&self, signature: models::Signature) -> Result<models::TxQueryResponse, Self::Error>;
73

74
    async fn sync_utxos_by_block(
75
        &self,
76
        request: models::SyncUtxosByBlockRequest,
77
    ) -> Result<models::SyncUtxosByBlockResponse, Self::Error>;
78

79
    async fn get_utxos_deleted_info(
80
        &self,
81
        request: models::GetUtxosDeletedInfoRequest,
82
    ) -> Result<models::GetUtxosDeletedInfoResponse, Self::Error>;
83

84
    async fn generate_kernel_merkle_proof(
85
        &self,
86
        excess_sig: CompressedSignature,
87
    ) -> Result<GenerateKernelMerkleProofResponse, Self::Error>;
88

89
    async fn get_utxo(&self, request: models::GetUtxoRequest) -> Result<models::GetUtxoResponse, Self::Error>;
90
}
91

92
#[tari_rpc(protocol_name = b"t/bnwallet/1", server_struct = BaseNodeWalletRpcServer, client_struct = BaseNodeWalletRpcClient)]
×
93
pub trait BaseNodeWalletService: Send + Sync + 'static {
94
    #[rpc(method = 1)]
95
    async fn submit_transaction(
96
        &self,
97
        request: Request<Transaction>,
98
    ) -> Result<Response<TxSubmissionResponse>, RpcStatus>;
99

100
    #[rpc(method = 2)]
101
    async fn transaction_query(&self, request: Request<Signature>) -> Result<Response<TxQueryResponse>, RpcStatus>;
102

103
    #[rpc(method = 3)]
104
    async fn transaction_batch_query(
105
        &self,
106
        request: Request<Signatures>,
107
    ) -> Result<Response<TxQueryBatchResponses>, RpcStatus>;
108

109
    #[rpc(method = 4)]
110
    async fn fetch_matching_utxos(
111
        &self,
112
        request: Request<FetchMatchingUtxos>,
113
    ) -> Result<Response<FetchUtxosResponse>, RpcStatus>;
114

115
    #[rpc(method = 5)]
116
    async fn get_tip_info(&self, request: Request<()>) -> Result<Response<TipInfoResponse>, RpcStatus>;
117

118
    #[rpc(method = 6)]
119
    async fn get_header(&self, request: Request<u64>) -> Result<Response<proto::core::BlockHeader>, RpcStatus>;
120

121
    #[rpc(method = 7)]
122
    async fn utxo_query(&self, request: Request<UtxoQueryRequest>) -> Result<Response<UtxoQueryResponses>, RpcStatus>;
123

124
    #[rpc(method = 8)]
125
    async fn query_deleted(
126
        &self,
127
        request: Request<QueryDeletedRequest>,
128
    ) -> Result<Response<QueryDeletedResponse>, RpcStatus>;
129

130
    #[rpc(method = 9)]
131
    async fn get_header_by_height(
132
        &self,
133
        request: Request<u64>,
134
    ) -> Result<Response<proto::core::BlockHeader>, RpcStatus>;
135

136
    #[rpc(method = 10)]
137
    async fn get_height_at_time(&self, request: Request<u64>) -> Result<Response<u64>, RpcStatus>;
138

139
    #[rpc(method = 11)]
140
    async fn sync_utxos_by_block(
141
        &self,
142
        request: Request<SyncUtxosByBlockRequest>,
143
    ) -> Result<Streaming<SyncUtxosByBlockResponse>, RpcStatus>;
144

145
    #[rpc(method = 12)]
146
    async fn get_mempool_fee_per_gram_stats(
147
        &self,
148
        request: Request<GetMempoolFeePerGramStatsRequest>,
149
    ) -> Result<Response<GetMempoolFeePerGramStatsResponse>, RpcStatus>;
150

151
    #[rpc(method = 13)]
152
    async fn get_wallet_query_http_service_address(
153
        &self,
154
        request: Request<()>,
155
    ) -> Result<Response<GetWalletQueryHttpServiceAddressResponse>, RpcStatus>;
156
}
157

158
pub fn create_base_node_wallet_rpc_service<B: BlockchainBackend + 'static>(
×
159
    db: AsyncBlockchainDb<B>,
×
160
    mempool: MempoolHandle,
×
161
    state_machine: StateMachineHandle,
×
162
    wallet_query_service_address: Option<Url>,
×
163
) -> BaseNodeWalletRpcServer<BaseNodeWalletRpcService<B>> {
×
164
    BaseNodeWalletRpcServer::new(BaseNodeWalletRpcService::new(
×
165
        db,
×
166
        mempool,
×
167
        state_machine,
×
168
        wallet_query_service_address,
×
169
    ))
170
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc