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

tari-project / tari / 19424872350

17 Nov 2025 09:33AM UTC coverage: 51.544% (+1.0%) from 50.497%
19424872350

push

github

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

59181 of 114817 relevant lines covered (51.54%)

8061.81 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::{
20
    rpc::{models, models::GenerateKernelMerkleProofResponse},
21
    transaction_components::TransactionOutput,
22
};
23
use url::Url;
24

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

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

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

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

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

65
    async fn get_utxos_mined_info(
66
        &self,
67
        request: models::GetUtxosMinedInfoRequest,
68
    ) -> Result<models::GetUtxosMinedInfoResponse, Self::Error>;
69

70
    async fn get_utxos_by_block(
71
        &self,
72
        request: models::GetUtxosByBlockRequest,
73
    ) -> Result<models::GetUtxosByBlockResponse, Self::Error>;
74

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

77
    async fn sync_utxos_by_block(
78
        &self,
79
        request: models::SyncUtxosByBlockRequest,
80
    ) -> Result<models::SyncUtxosByBlockResponse, Self::Error>;
81

82
    async fn get_utxos_deleted_info(
83
        &self,
84
        request: models::GetUtxosDeletedInfoRequest,
85
    ) -> Result<models::GetUtxosDeletedInfoResponse, Self::Error>;
86

87
    async fn generate_kernel_merkle_proof(
88
        &self,
89
        excess_sig: CompressedSignature,
90
    ) -> Result<GenerateKernelMerkleProofResponse, Self::Error>;
91

92
    async fn get_utxo(&self, request: models::GetUtxoRequest) -> Result<Option<TransactionOutput>, Self::Error>;
93
}
94

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

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

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

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

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

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

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

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

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

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

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

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

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

161
pub fn create_base_node_wallet_rpc_service<B: BlockchainBackend + 'static>(
×
162
    db: AsyncBlockchainDb<B>,
×
163
    mempool: MempoolHandle,
×
164
    state_machine: StateMachineHandle,
×
165
    wallet_query_service_address: Option<Url>,
×
166
) -> BaseNodeWalletRpcServer<BaseNodeWalletRpcService<B>> {
×
167
    BaseNodeWalletRpcServer::new(BaseNodeWalletRpcService::new(
×
168
        db,
×
169
        mempool,
×
170
        state_machine,
×
171
        wallet_query_service_address,
×
172
    ))
173
}
×
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