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

tari-project / tari / 15853103462

24 Jun 2025 02:21PM UTC coverage: 71.683% (-0.7%) from 72.398%
15853103462

push

github

web-flow
feat: offline signing (#7122)

Description
---

Adds the following features.

### CLI `--skip-recovery` option.

Cold wallets need to run in environments without Internet connection.
Console wallet created from seed words will require full initial
recovery to proceed with other functionality.
This switch allows to skip the recovery step.

### "prepare-one-sided-transaction-for-signing" CLI command

```sh
minotari_console_wallet prepare-one-sided-transaction-for-signing --output-file <unsigned_tx_file> <amount> <recipient_address>
```

Supposed to be run on _hot side_. This will create an unsigned
transaction request, which needs to be signed on cold side.

### "sign-one-sided-transaction" CLI command

```sh
minotari_console_wallet sign-one-sided-transaction --input-file <unsigned_tx_file> --output-file <signed_tx_file>
```

Supposed to be run on _cold side_. Signs the transaction using **private
spend key**.

### "broadcast-signed-one-sided-transaction" CLI command

```sh
minotari_console_wallet broadcast-signed-one-sided-transaction --input-file <signed_tx_file>
```

Supposed to be run on _hot side_. Broadcasts the signed transaction to
Tari network (mempool)

### GRPC methods to be run on _hot side_

* PrepareOneSidedTransactionForSigning
* BroadcastSignedOneSidedTransaction

Motivation and Context
---

Exchanges are requesting a way to have offline signing.
Basically, they want two wallets:
- a hot wallet, which uses view key and public spend key
- cold wallet with private spend key, not connected to internet

The signing process would look like follows.
1. Hot wallet is requested to create an unsigned transaction (from
recipient address and amount). There will be an option to use CLI to
create a file, which contains unsigned transaction
2. Unisigned transaction will be airgap transferred to cold wallet,
where it is signed via CLI. The output will be another file containing a
signed transaction
3. Signed transaction file is transferred to hot walle... (continued)

0 of 851 new or added lines in 9 files covered. (0.0%)

301 existing lines in 23 files now uncovered.

82846 of 115572 relevant lines covered (71.68%)

239176.69 hits per line

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

0.0
/base_layer/core/src/base_node/sync/block_sync/error.rs
1
//  Copyright 2020, 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::time::Duration;
24

25
use tari_common_types::types::FixedHashSizeError;
26
use tari_comms::{
27
    connectivity::ConnectivityError,
28
    peer_manager::NodeId,
29
    protocol::rpc::{RpcError, RpcStatus, RpcStatusCode},
30
};
31

32
use crate::{
33
    chain_storage::ChainStorageError,
34
    common::{BanPeriod, BanReason},
35
    validation::ValidationError,
36
};
37

38
#[derive(Debug, thiserror::Error)]
39
pub enum BlockSyncError {
40
    #[error("Async validation task failed: {0}")]
41
    AsyncTaskFailed(#[from] tokio::task::JoinError),
42
    #[error("RPC error: {0}")]
43
    RpcError(#[from] RpcError),
44
    #[error("RPC request failed: {0}")]
45
    RpcRequestError(#[from] RpcStatus),
46
    #[error("Chain storage error: {0}")]
47
    ChainStorageError(#[from] ChainStorageError),
48
    #[error("Peer sent a block that did not form a chain. Expected hash = {expected}, got = {got}")]
49
    BlockWithoutParent { expected: String, got: String },
50
    #[error("Connectivity Error: {0}")]
51
    ConnectivityError(#[from] ConnectivityError),
52
    #[error("No more sync peers available: {0}")]
53
    NoMoreSyncPeers(String),
54
    #[error("Block validation failed: {0}")]
55
    ValidationError(#[from] ValidationError),
56
    #[error("Failed to construct valid chain block")]
57
    FailedToConstructChainBlock,
58
    #[error("Peer sent unknown hash")]
59
    UnknownHeaderHash(String),
60
    #[error("Peer sent block with invalid block body")]
61
    InvalidBlockBody(String),
62
    #[error("Peer {peer} exceeded maximum permitted sync latency. latency: {latency:.2?}, max: {max_latency:.2?}")]
63
    MaxLatencyExceeded {
64
        peer: NodeId,
65
        latency: Duration,
66
        max_latency: Duration,
67
    },
68
    #[error("All sync peers exceeded max allowed latency")]
69
    AllSyncPeersExceedLatency,
70
    #[error("FixedHash size error: {0}")]
71
    FixedHashSizeError(#[from] FixedHashSizeError),
72
    #[error("This sync round failed")]
73
    SyncRoundFailed,
74
    #[error("Could not find peer info")]
75
    PeerNotFound,
76
    #[error("Peer did not supply all the blocks they claimed they had: {0}")]
77
    PeerDidNotSupplyAllClaimedBlocks(String),
78
}
79

80
impl BlockSyncError {
UNCOV
81
    pub fn to_short_str(&self) -> &'static str {
×
82
        match self {
×
83
            BlockSyncError::RpcError(_) => "RpcError",
×
84
            BlockSyncError::RpcRequestError(status) if status.as_status_code() == RpcStatusCode::Timeout => {
×
85
                "RpcTimeout"
×
86
            },
87
            BlockSyncError::RpcRequestError(_) => "RpcRequestError",
×
88
            BlockSyncError::AsyncTaskFailed(_) => "AsyncTaskFailed",
×
89
            BlockSyncError::ChainStorageError(_) => "ChainStorageError",
×
90
            BlockSyncError::BlockWithoutParent { .. } => "PeerSentBlockThatDidNotFormAChain",
×
91
            BlockSyncError::ConnectivityError(_) => "ConnectivityError",
×
UNCOV
92
            BlockSyncError::NoMoreSyncPeers(_) => "NoMoreSyncPeers",
×
93
            BlockSyncError::ValidationError(_) => "ValidationError",
×
94
            BlockSyncError::FailedToConstructChainBlock => "FailedToConstructChainBlock",
×
95
            BlockSyncError::UnknownHeaderHash(_) => "UnknownHeaderHash",
×
96
            BlockSyncError::InvalidBlockBody(_) => "InvalidBlockBody",
×
97
            BlockSyncError::MaxLatencyExceeded { .. } => "MaxLatencyExceeded",
×
98
            BlockSyncError::AllSyncPeersExceedLatency => "AllSyncPeersExceedLatency",
×
99
            BlockSyncError::FixedHashSizeError(_) => "FixedHashSizeError",
×
100
            BlockSyncError::SyncRoundFailed => "SyncRoundFailed",
×
101
            BlockSyncError::PeerNotFound => "PeerNotFound",
×
102
            BlockSyncError::PeerDidNotSupplyAllClaimedBlocks(_) => "PeerDidNotSupplyAllClaimedBlocks",
×
103
        }
UNCOV
104
    }
×
105
}
106

107
impl BlockSyncError {
UNCOV
108
    pub fn get_ban_reason(&self) -> Option<BanReason> {
×
UNCOV
109
        match self {
×
110
            // no ban
111
            BlockSyncError::AsyncTaskFailed(_) |
112
            BlockSyncError::ConnectivityError(_) |
113
            BlockSyncError::NoMoreSyncPeers(_) |
114
            BlockSyncError::AllSyncPeersExceedLatency |
115
            BlockSyncError::FailedToConstructChainBlock |
116
            BlockSyncError::PeerNotFound |
117
            BlockSyncError::SyncRoundFailed => None,
×
118
            BlockSyncError::ChainStorageError(e) => e.get_ban_reason(),
×
119
            // short ban
120
            err @ BlockSyncError::MaxLatencyExceeded { .. } |
×
121
            err @ BlockSyncError::PeerDidNotSupplyAllClaimedBlocks(_) |
×
122
            err @ BlockSyncError::RpcError(_) |
×
UNCOV
123
            err @ BlockSyncError::RpcRequestError(_) => Some(BanReason {
×
UNCOV
124
                reason: format!("{}", err),
×
UNCOV
125
                ban_duration: BanPeriod::Short,
×
UNCOV
126
            }),
×
127

128
            // long ban
129
            err @ BlockSyncError::BlockWithoutParent { .. } |
×
130
            err @ BlockSyncError::UnknownHeaderHash(_) |
×
131
            err @ BlockSyncError::InvalidBlockBody(_) |
×
132
            err @ BlockSyncError::FixedHashSizeError(_) => Some(BanReason {
×
133
                reason: format!("{}", err),
×
134
                ban_duration: BanPeriod::Long,
×
135
            }),
×
136

137
            BlockSyncError::ValidationError(err) => ValidationError::get_ban_reason(err),
×
138
        }
UNCOV
139
    }
×
140
}
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