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

tari-project / tari / 19227006544

10 Nov 2025 09:31AM UTC coverage: 51.608% (-7.9%) from 59.471%
19227006544

push

github

web-flow
feat: add deterministic transaction id (#7541)

Description
---
Added deterministic transaction IDs, which are an 8-byte (u64) hash
based on the transaction output hash in question and the wallet view
key.
- Any scanned or recovered wallet output will have the same transaction
ID across view or spend wallets.
- Sender wallets will be able to calculate the transaction ID for
receiver wallets if they need to, for that specific output.
- Sender wallets will use their change output as the determining output
hash for the transaction; this will result in the same transaction ID
being allocated upon wallet recovery. In the case of no change output,
the hash of the first ordered output will be used for the transaction
ID.
- For coin split transactions, the hash of the first ordered output will
be used for the transaction ID.

Fixed the issue with the Windows test build target link:
```
: error LNK2019: unresolved external symbol __imp_InitializeSecurityDescriptor referenced in function mdb_env_setup_locks
: error LNK2019: unresolved external symbol __imp_SetSecurityDescriptorDacl referenced in function mdb_env_setup_lock
```

Fixes #7485.

Motivation and Context
---
See #7485.

How Has This Been Tested?
---
Added unit tests.
Performed system-level testing.

What process can a PR reviewer use to test or verify this change?
---
Code review.
System-level testing.

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->


<!-- This is an auto-generated comm... (continued)

52 of 1260 new or added lines in 14 files covered. (4.13%)

9213 existing lines in 93 files now uncovered.

59188 of 114687 relevant lines covered (51.61%)

8172.79 hits per line

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

0.0
/base_layer/transaction_components/src/multisig/script.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 tari_common_types::types::{CompressedPublicKey, PrivateKey, UncompressedPublicKey};
23
use tari_crypto::keys::{PublicKey, SecretKey};
24
use tari_script::{Opcode, TariScript};
25

26
use crate::{
27
    key_manager::{TariKeyId, TransactionKeyManagerInterface},
28
    transaction_components::{one_sided::diffie_hellman_stealth_domain_hasher, TransactionError},
29
};
30

31
pub fn is_multisig_utxo(tari_script: &TariScript) -> bool {
×
32
    tari_script
×
33
        .as_slice()
×
34
        .iter()
×
35
        .any(|op| matches!(op, Opcode::CheckMultiSigVerify(..)))
×
36
}
×
37

38
pub fn get_multi_sig_script_components(script: &TariScript) -> Option<(Vec<CompressedPublicKey>, u8)> {
×
39
    for op in script.as_slice() {
×
40
        if let Opcode::CheckMultiSigVerify(m, _n, keys, _msg) = op {
×
41
            return Some((keys.clone(), *m));
×
42
        }
×
43
    }
44

45
    None
×
46
}
×
47

UNCOV
48
pub async fn derive_multisig_ephemeral_pubkey<KM: TransactionKeyManagerInterface>(
×
UNCOV
49
    key_manager: &KM,
×
UNCOV
50
    public_key: &CompressedPublicKey,
×
UNCOV
51
    sender_offset_key: &TariKeyId,
×
UNCOV
52
) -> Result<CompressedPublicKey, TransactionError> {
×
UNCOV
53
    let dh_shared_secret = key_manager
×
UNCOV
54
        .get_diffie_hellman_shared_secret(sender_offset_key, public_key)
×
UNCOV
55
        .await?;
×
56

UNCOV
57
    let stealth_hash = diffie_hellman_stealth_domain_hasher(dh_shared_secret);
×
UNCOV
58
    let private_key = PrivateKey::from_uniform_bytes(stealth_hash.as_ref())?;
×
59

UNCOV
60
    let shared_secret = UncompressedPublicKey::from_secret_key(&private_key);
×
UNCOV
61
    Ok(CompressedPublicKey::new_from_pk(
×
UNCOV
62
        public_key.to_public_key()? + shared_secret,
×
63
    ))
UNCOV
64
}
×
65

UNCOV
66
pub async fn derive_multisig_ephemeral_pubkeys<KM: TransactionKeyManagerInterface>(
×
UNCOV
67
    key_manager: &KM,
×
UNCOV
68
    public_keys: &[CompressedPublicKey],
×
UNCOV
69
    sender_offset_key: &TariKeyId,
×
UNCOV
70
) -> Result<Vec<CompressedPublicKey>, TransactionError> {
×
UNCOV
71
    let mut ephemeral_pubkeys = Vec::new();
×
UNCOV
72
    for pub_key in public_keys {
×
UNCOV
73
        ephemeral_pubkeys.push(derive_multisig_ephemeral_pubkey(key_manager, pub_key, sender_offset_key).await?);
×
74
    }
UNCOV
75
    Ok(ephemeral_pubkeys)
×
UNCOV
76
}
×
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