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

tari-project / tari / 15280118615

27 May 2025 04:01PM UTC coverage: 73.59% (+0.4%) from 73.233%
15280118615

push

github

web-flow
feat: add base node HTTP wallet service (#7061)

Description
---
Added a new HTTP server for base node that exposes some wallet related
query functionality.

Current new endpoints (examples on **esmeralda** network):
 - http://127.0.0.1:9005/get_tip_info
 - http://127.0.0.1:9005/get_header_by_height?height=6994
 - http://127.0.0.1:9005/get_height_at_time?time=1747739959

Default ports for http service (by network):
```
MainNet: 9000,
StageNet: 9001,
NextNet: 9002,
LocalNet: 9003,
Igor: 9004,
Esmeralda: 9005,
```

New configuration needs to be set in base node:
```toml
[base_node.http_wallet_query_service]
port = 9000
external_address = "http://127.0.0.1:9000" # this is optional, but if not set, when someone requests for the external address, just returns a None, so wallets can't contact base node
```

Motivation and Context
---


How Has This Been Tested?
---
### Manually

#### Basic test
1. Build new base node
2. Set base node configuration by adding the following:
```toml
[base_node.http_wallet_query_service]
port = 9000
external_address = "http://127.0.0.1:9000"
```
This way we set the port and external address (which is sent to wallet
client when requesting, so in real world it must be public)
3. Set logging level of base node logs to DEBUG
4. Start base node
5. Build and start console wallet
6. See that it is still able to synchronize
7. Check logs of base node (with `tail -f ...` command for instance) and
see that the HTTP endpoints are used

#### Use RPC fallback test
1. Build new base node
2. Set base node configuration by adding the following:
```toml
[base_node.http_wallet_query_service]
port = 9000
external_address = "http://127.0.0.1:9001"
```
This way we set the port and external address (which is sent to wallet
client when requesting, so in real world it must be public)
3. Set logging level of base node logs to DEBUG
4. Start base node
5. Build and start console wallet
6. See that it is still able to synchronize
7. Check logs of base nod... (continued)

9 of 114 new or added lines in 4 files covered. (7.89%)

1592 existing lines in 62 files now uncovered.

82227 of 111736 relevant lines covered (73.59%)

272070.7 hits per line

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

20.0
/comms/core/src/peer_manager/error.rs
1
// Copyright 2019 The Tari Project
2
//
3
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
// following conditions are met:
5
//
6
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
// disclaimer.
8
//
9
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
// following disclaimer in the documentation and/or other materials provided with the distribution.
11
//
12
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13
// products derived from this software without specific prior written permission.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
22

23
// use std::sync::PoisonError;
24

25
use multiaddr::Multiaddr;
26
use tari_common_sqlite::error::StorageError;
27
use tari_utilities::hex::HexError;
28
use thiserror::Error;
29
use tokio::task::JoinError;
30

31
use crate::peer_manager::NodeId;
32

33
/// Error type for [PeerManager](super::PeerManager).
34
#[derive(Debug, Error, Clone)]
35
pub enum PeerManagerError {
36
    #[error("The requested peer does not exist")]
37
    PeerNotFoundError,
38
    #[error("DB Data inconsistency: {0}")]
39
    DataInconsistency(String),
40
    #[error("The peer has been banned")]
41
    BannedPeer,
42
    #[error("A problem has been encountered with the sql database: {0}")]
43
    StorageError(String),
44
    #[error("An error occurred while migrating the database: {0}")]
45
    MigrationError(String),
46
    #[error("Identity signature is invalid")]
47
    InvalidIdentitySignature,
48
    #[error("Identity signature missing")]
49
    MissingIdentitySignature,
50
    #[error("Invalid peer address: {0}")]
51
    MultiaddrError(String),
52
    #[error("Unable to parse any of the network addresses offered by the connecting peer")]
53
    PeerIdentityNoValidAddresses,
54
    #[error("Invalid peer feature bits '{bits:#x}'")]
55
    InvalidPeerFeatures { bits: u32 },
56
    #[error("Address {address} not found for peer {node_id}")]
57
    AddressNotFoundError { address: Multiaddr, node_id: NodeId },
58
    #[error("Protocol error: {0}")]
59
    ProtocolError(String),
60
    #[error("Invalid version string")]
61
    InvalidVersionString,
62
    #[error("Peer version {peer_version} to older than the minimum required version {min_version}")]
63
    PeerVersionTooOld { min_version: String, peer_version: String },
64
    #[error("Hex conversion error: `{0}`")]
65
    HexError(String),
66
    #[error("Tokio task join error: `{0}`")]
67
    JoinError(String),
68
    #[error("Process error: `{0}`")]
69
    ProcessError(String),
70
}
71

72
impl From<JoinError> for PeerManagerError {
73
    fn from(err: JoinError) -> Self {
×
74
        PeerManagerError::JoinError(err.to_string())
×
UNCOV
75
    }
×
76
}
77

78
impl From<StorageError> for PeerManagerError {
79
    fn from(err: StorageError) -> Self {
381✔
80
        PeerManagerError::StorageError(err.to_string())
381✔
81
    }
381✔
82
}
83

84
impl PeerManagerError {
85
    /// Returns true if this error indicates that the peer is not found, otherwise false
UNCOV
86
    pub fn is_peer_not_found(&self) -> bool {
×
UNCOV
87
        matches!(self, PeerManagerError::PeerNotFoundError)
×
UNCOV
88
    }
×
89
}
90

91
impl From<HexError> for PeerManagerError {
UNCOV
92
    fn from(value: HexError) -> Self {
×
UNCOV
93
        PeerManagerError::HexError(value.to_string())
×
UNCOV
94
    }
×
95
}
96

97
impl From<std::io::Error> for PeerManagerError {
UNCOV
98
    fn from(value: std::io::Error) -> Self {
×
UNCOV
99
        PeerManagerError::StorageError(value.to_string())
×
UNCOV
100
    }
×
101
}
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