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

tari-project / tari / 17542535568

08 Sep 2025 07:01AM UTC coverage: 61.111% (-0.08%) from 61.19%
17542535568

push

github

web-flow
chore: improvements needed in new wallet  (#7471)

Description
---
Moved historical blocks out of tari core so that wallet can access them
without needing tari core
Created legacy transaction status for current wallet to use, with new
simplified transaction status for new wallet
Changed `try_output_key_recovery` top use private key and not key id
Add new wallet output constructor


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- New Features
- Dual support for legacy and new transaction statuses across gRPC,
wallet, and FFI.
  - Wallet seed birthday accessor added.
- Wallet can import existing outputs via a new imported-output
constructor.
- Exposed MAX_ENCRYPTED_DATA_SIZE and added Borsh serialization for
MemoField.

- Refactor
- Block-related types moved to a shared component and a builder-based
API introduced for accumulated header data.
  - Broad import-path and module surface cleanups.

- Breaking Changes
- Wallet and related APIs now use
LegacyTransactionStatus/LegacyImportStatus.
- Key-recovery APIs now accept an owned PrivateKey instead of a key ID.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

125 of 424 new or added lines in 22 files covered. (29.48%)

28 existing lines in 8 files now uncovered.

72887 of 119270 relevant lines covered (61.11%)

300900.42 hits per line

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

37.21
/base_layer/node_components/src/blocks/block_header_accumulated_data.rs
1
//  Copyright 2025, 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
use std::{fmt, fmt::Display};
23

24
use primitive_types::U512;
25
use tari_common_types::types::{HashOutput, PrivateKey};
26
use tari_transaction_components::tari_proof_of_work::{AccumulatedDifficulty, Difficulty};
27

28
/// Accumulated and other pertinent data in the block header acting as a "condensed blockchain snapshot" for the block
29
#[derive(Debug, Clone, PartialEq, Eq)]
30
pub struct BlockHeaderAccumulatedData {
31
    /// The block hash.
32
    pub hash: HashOutput,
33
    /// The total accumulated offset for all kernels in the block.
34
    pub total_kernel_offset: PrivateKey,
35
    /// The achieved difficulty for solving the current block using the specified proof of work algorithm.
36
    pub achieved_difficulty: Difficulty,
37
    /// The total accumulated difficulty for all blocks since Genesis, but not including this block, tracked
38
    /// separately.
39
    pub total_accumulated_difficulty: U512,
40
    /// The total accumulated difficulty for Merged mined monero RandomX proof of work for all blocks since Genesis,
41
    /// but not including this block, tracked separately.
42
    pub accumulated_monero_randomx_difficulty: AccumulatedDifficulty,
43
    /// The total accumulated difficulty for Tari RandomX proof of work for all blocks since Genesis,
44
    /// but not including this block, tracked separately.
45
    pub accumulated_tari_randomx_difficulty: AccumulatedDifficulty,
46
    /// The total accumulated difficulty for SHA3 proof of work for all blocks since Genesis,
47
    /// but not including this block, tracked separately.
48
    pub accumulated_sha3x_difficulty: AccumulatedDifficulty,
49
    /// The total accumulated difficulty for Cuckaroo proof of work for all blocks since Genesis,
50
    pub accumulated_cuckaroo_difficulty: AccumulatedDifficulty,
51
    /// The target difficulty for solving the current block using the specified proof of work algorithm.
52
    pub target_difficulty: Difficulty,
53
}
54

55
impl BlockHeaderAccumulatedData {
56
    pub fn genesis(hash: HashOutput, total_kernel_offset: PrivateKey) -> Self {
323✔
57
        Self {
323✔
58
            hash,
323✔
59
            total_kernel_offset,
323✔
60
            achieved_difficulty: Difficulty::min(),
323✔
61
            total_accumulated_difficulty: 1.into(),
323✔
62
            accumulated_monero_randomx_difficulty: AccumulatedDifficulty::min(),
323✔
63
            accumulated_tari_randomx_difficulty: AccumulatedDifficulty::min(),
323✔
64
            accumulated_sha3x_difficulty: AccumulatedDifficulty::min(),
323✔
65
            accumulated_cuckaroo_difficulty: AccumulatedDifficulty::min(),
323✔
66
            target_difficulty: Difficulty::min(),
323✔
67
        }
323✔
68
    }
323✔
69

NEW
70
    pub fn accumulated_monero_randomx_difficulty(&self) -> AccumulatedDifficulty {
×
NEW
71
        self.accumulated_monero_randomx_difficulty
×
NEW
72
    }
×
73

NEW
74
    pub fn accumulated_tari_randomx_difficulty(&self) -> AccumulatedDifficulty {
×
NEW
75
        self.accumulated_tari_randomx_difficulty
×
NEW
76
    }
×
77

78
    pub fn accumulated_sha3x_difficulty(&self) -> AccumulatedDifficulty {
28✔
79
        self.accumulated_sha3x_difficulty
28✔
80
    }
28✔
81

NEW
82
    pub fn accumulated_cuckaroo_difficulty(&self) -> AccumulatedDifficulty {
×
NEW
83
        self.accumulated_cuckaroo_difficulty
×
NEW
84
    }
×
85
}
86

87
impl Display for BlockHeaderAccumulatedData {
NEW
88
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
NEW
89
        writeln!(f, "Hash: {}", self.hash)?;
×
NEW
90
        writeln!(f, "Achieved difficulty: {}", self.achieved_difficulty)?;
×
NEW
91
        writeln!(f, "Total accumulated difficulty: {}", self.total_accumulated_difficulty)?;
×
NEW
92
        writeln!(
×
NEW
93
            f,
×
NEW
94
            "Accumulated Monero RandomX difficulty: {}",
×
NEW
95
            self.accumulated_monero_randomx_difficulty
×
NEW
96
        )?;
×
NEW
97
        writeln!(
×
NEW
98
            f,
×
NEW
99
            "Accumulated Tari RandomX difficulty: {}",
×
NEW
100
            self.accumulated_tari_randomx_difficulty
×
NEW
101
        )?;
×
NEW
102
        writeln!(f, "Accumulated sha3 difficulty: {}", self.accumulated_sha3x_difficulty)?;
×
NEW
103
        writeln!(f, "Target difficulty: {}", self.target_difficulty)?;
×
NEW
104
        Ok(())
×
NEW
105
    }
×
106
}
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