• 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

0.0
/common_sqlite/src/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::{io::Error, num::TryFromIntError};
24

25
use diesel::r2d2;
26
use tari_utilities::{hex::HexError, message_format::MessageFormatError};
27
use thiserror::Error;
28
use tokio::task;
29

30
#[derive(Debug, Error)]
31
pub enum SqliteStorageError {
32
    #[error("Poolsize is too big")]
33
    PoolSize(#[from] TryFromIntError),
34
    #[error("Database error: `{0}`")]
35
    R2d2Error(#[from] r2d2::Error),
36
    #[error("Database error: `{0}`")]
37
    DieselR2d2Error(String),
38
    #[error("Database error: `{0}`")]
39
    DieselConnectionError(#[from] diesel::ConnectionError),
40
}
41

42
#[derive(Debug, Error)]
43
pub enum StorageError {
44
    #[error("ConnectionError: {0}")]
45
    ConnectionError(#[from] diesel::ConnectionError),
46
    #[error("Error when joining to tokio task: {0}")]
47
    JoinError(#[from] task::JoinError),
48
    #[error("DatabaseMigrationFailed: {0}")]
49
    DatabaseMigrationFailed(String),
50
    #[error("Diesel result error: {0}")]
51
    DieselResultError(#[from] diesel::result::Error),
52
    #[error("MessageFormatError: {0}")]
53
    MessageFormatError(String),
54
    #[error("Unexpected result: {0}")]
55
    UnexpectedResult(String),
56
    #[error("Diesel R2d2 error: `{0}`")]
57
    DieselR2d2Error(#[from] SqliteStorageError),
58
    #[error("Hex conversion error: `{0}`")]
59
    HexError(String),
60
    #[error("JSON error: {0}")]
61
    JsonError(#[from] serde_json::Error),
62
    #[error("TryFromInt conversion error: `{0}`")]
63
    TryFromIntError(#[from] TryFromIntError),
64
    #[error("IO error: `{0}`")]
65
    IoError(#[from] Error),
66
    #[error("Database migration lock error: {0}")]
67
    DatabaseMigrationLockError(String),
68
}
69

70
impl From<MessageFormatError> for StorageError {
71
    fn from(value: MessageFormatError) -> Self {
×
UNCOV
72
        StorageError::MessageFormatError(value.to_string())
×
UNCOV
73
    }
×
74
}
75

76
impl From<HexError> for StorageError {
UNCOV
77
    fn from(value: HexError) -> Self {
×
UNCOV
78
        StorageError::HexError(value.to_string())
×
UNCOV
79
    }
×
80
}
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