Block times (minutes)
@@ -83,7 +83,7 @@
{{title}}
-
+
Height |
@@ -123,7 +123,7 @@
Mempool
-
+
Excess |
diff --git a/applications/tari_explorer/views/layout.hbs b/applications/tari_explorer/views/layout.hbs
index 3c0ee74010..9afc72630d 100644
--- a/applications/tari_explorer/views/layout.hbs
+++ b/applications/tari_explorer/views/layout.hbs
@@ -4,11 +4,17 @@
A simple, no Javascript, (almost) no CSS block explorer for Tari
+
{{{body}}}
diff --git a/applications/test_faucet/src/main.rs b/applications/test_faucet/src/main.rs
index 05eb4061a4..5667055f3f 100644
--- a/applications/test_faucet/src/main.rs
+++ b/applications/test_faucet/src/main.rs
@@ -6,17 +6,30 @@
#![deny(unreachable_patterns)]
#![deny(unknown_lints)]
-use std::{fs::File, io::Write};
+use std::{
+ fs::File,
+ io::{stdout, Write},
+};
use serde::Serialize;
use tari_common_types::types::{Commitment, PrivateKey};
-use tari_core::transactions::{
- tari_amount::{MicroTari, T},
- test_helpers,
- transaction::{KernelFeatures, OutputFeatures, TransactionKernel, TransactionOutput},
- CryptoFactories,
+use tari_core::{
+ covenants::Covenant,
+ transactions::{
+ tari_amount::{MicroTari, T},
+ test_helpers,
+ test_helpers::generate_keys,
+ transaction::{KernelFeatures, OutputFeatures, TransactionKernel, TransactionOutput},
+ CryptoFactories,
+ },
+};
+use tari_crypto::{
+ commitment::HomomorphicCommitmentFactory,
+ range_proof::RangeProofService,
+ script,
+ script::TariScript,
+ tari_utilities::hex::Hex,
};
-use tari_crypto::{script, tari_utilities::hex::Hex};
use tokio::{sync::mpsc, task};
const NUM_KEYS: usize = 4000;
@@ -63,8 +76,9 @@ async fn main() -> Result<(), Box> {
task::spawn(async move {
let result = task::spawn_blocking(move || {
let script = script!(Nop);
- let (utxo, key, _) = test_helpers::create_utxo(value, &fc, feature, &script, &Default::default());
+ let (utxo, key, _) = create_utxo(value, &fc, feature, script, Covenant::default());
print!(".");
+ let _ = stdout().flush();
(utxo, key, value)
})
.await
@@ -137,3 +151,37 @@ impl Iterator for UTXOFeatures {
Some(f)
}
}
+
+/// Create a new UTXO for the specified value and return the output and spending key
+fn create_utxo(
+ value: MicroTari,
+ factories: &CryptoFactories,
+ features: OutputFeatures,
+ script: TariScript,
+ covenant: Covenant,
+) -> (TransactionOutput, PrivateKey, PrivateKey) {
+ let keys = generate_keys();
+ let offset_keys = generate_keys();
+ let commitment = factories.commitment.commit_value(&keys.k, value.into());
+ let proof = factories.range_proof.construct_proof(&keys.k, value.into()).unwrap();
+ let metadata_sig = TransactionOutput::create_final_metadata_signature(
+ &value,
+ &keys.k,
+ &script,
+ &features,
+ &offset_keys.k,
+ &covenant,
+ )
+ .unwrap();
+
+ let utxo = TransactionOutput::new_current_version(
+ features,
+ commitment,
+ proof.into(),
+ script,
+ offset_keys.pk,
+ metadata_sig,
+ covenant,
+ );
+ (utxo, keys.k, offset_keys.k)
+}
diff --git a/base_layer/core/src/base_node/state_machine_service/states/horizon_state_sync/horizon_state_synchronization.rs b/base_layer/core/src/base_node/state_machine_service/states/horizon_state_sync/horizon_state_synchronization.rs
index 9c5924a04f..80937f4d9b 100644
--- a/base_layer/core/src/base_node/state_machine_service/states/horizon_state_sync/horizon_state_synchronization.rs
+++ b/base_layer/core/src/base_node/state_machine_service/states/horizon_state_sync/horizon_state_synchronization.rs
@@ -199,10 +199,7 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {
latency.unwrap_or_default().as_millis()
);
- let mut current_header = self
- .db()
- .fetch_header_containing_kernel_mmr(local_num_kernels + 1)
- .await?;
+ let mut current_header = self.db().fetch_header_containing_kernel_mmr(local_num_kernels).await?;
let req = SyncKernelsRequest {
start: local_num_kernels,
end_header_hash: to_header.hash(),
@@ -362,7 +359,7 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {
include_pruned_utxos: true,
};
- let mut current_header = self.db().fetch_header_containing_utxo_mmr(start + 1).await?;
+ let mut current_header = self.db().fetch_header_containing_utxo_mmr(start).await?;
let mut output_stream = client.sync_utxos(req).await?;
debug!(
diff --git a/base_layer/core/src/base_node/sync/rpc/service.rs b/base_layer/core/src/base_node/sync/rpc/service.rs
index adedcb23ef..891775ebc2 100644
--- a/base_layer/core/src/base_node/sync/rpc/service.rs
+++ b/base_layer/core/src/base_node/sync/rpc/service.rs
@@ -435,7 +435,7 @@ impl BaseNodeSyncService for BaseNodeSyncRpcServ
let db = self.db();
let start_header = db
- .fetch_header_containing_kernel_mmr(req.start + 1)
+ .fetch_header_containing_kernel_mmr(req.start)
.await
.map_err(RpcStatus::log_internal_error(LOG_TARGET))?
.into_header();
diff --git a/base_layer/core/src/base_node/sync/rpc/sync_utxos_task.rs b/base_layer/core/src/base_node/sync/rpc/sync_utxos_task.rs
index bf6c81c5d8..db1e46f94b 100644
--- a/base_layer/core/src/base_node/sync/rpc/sync_utxos_task.rs
+++ b/base_layer/core/src/base_node/sync/rpc/sync_utxos_task.rs
@@ -54,7 +54,7 @@ where B: BlockchainBackend + 'static
) -> Result<(), RpcStatus> {
let start_header = self
.db
- .fetch_header_containing_utxo_mmr(request.start + 1)
+ .fetch_header_containing_utxo_mmr(request.start)
.await
.map_err(|err| {
error!(target: LOG_TARGET, "{}", err);
diff --git a/base_layer/core/src/chain_storage/blockchain_database.rs b/base_layer/core/src/chain_storage/blockchain_database.rs
index 29b62b8a96..d5f68a7df5 100644
--- a/base_layer/core/src/chain_storage/blockchain_database.rs
+++ b/base_layer/core/src/chain_storage/blockchain_database.rs
@@ -214,9 +214,9 @@ where B: BlockchainBackend
difficulty_calculator: Arc::new(difficulty_calculator),
disable_add_block_flag: Arc::new(AtomicBool::new(false)),
};
+ let genesis_block = Arc::new(blockchain_db.consensus_manager.get_genesis_block());
if is_empty {
info!(target: LOG_TARGET, "Blockchain db is empty. Adding genesis block.");
- let genesis_block = Arc::new(blockchain_db.consensus_manager.get_genesis_block());
blockchain_db.insert_block(genesis_block.clone())?;
let mut txn = DbTransaction::new();
let body = &genesis_block.block().body;
@@ -230,6 +230,20 @@ where B: BlockchainBackend
txn.set_horizon_data(kernel_sum, utxo_sum);
blockchain_db.write(txn)?;
blockchain_db.store_pruning_horizon(config.pruning_horizon)?;
+ } else if !blockchain_db.block_exists(genesis_block.accumulated_data().hash.clone())? {
+ // Check the genesis block in the DB.
+ error!(
+ target: LOG_TARGET,
+ "Genesis block in database does not match the supplied genesis block in the code! Hash in the code \
+ {:?}, hash in the database {:?}",
+ blockchain_db.fetch_chain_header(0)?.hash(),
+ genesis_block.accumulated_data().hash
+ );
+ return Err(ChainStorageError::CorruptedDatabase(
+ "Genesis block in database does not match the supplied genesis block in the code! Please delete and \
+ resync your blockchain database."
+ .into(),
+ ));
}
if cleanup_orphans_at_startup {
match blockchain_db.cleanup_all_orphans() {
@@ -449,11 +463,6 @@ where B: BlockchainBackend
Ok(chain_header)
}
- // TODO: this method is actually off by one. It returns the highest header where the kernel_mmr_count is <=
- // mmr_position, but should probably only be <.
- // E.g. if mmr_position == 2, it will return a header where kernel_mmr_count == 2, but this is
- // confusing because mmr_position ==2 actually would be in the next header
- // Either the caller needs to be updated or this method needs to be renamed
pub fn fetch_header_containing_kernel_mmr(&self, mmr_position: u64) -> Result {
let db = self.db_read_access()?;
db.fetch_header_containing_kernel_mmr(mmr_position)
diff --git a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
index 14229c5cb3..7bbb2f67e9 100644
--- a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
+++ b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
@@ -1738,6 +1738,9 @@ impl BlockchainBackend for LMDBDatabase {
fn fetch_header_containing_kernel_mmr(&self, mmr_position: u64) -> Result {
let txn = self.read_transaction()?;
+ // LMDB returns the height at the position, so we have to offset the position by 1 so that the mmr_position arg
+ // is an index starting from 0
+ let mmr_position = mmr_position + 1;
let height = lmdb_first_after::<_, u64>(&txn, &self.kernel_mmr_size_index, &mmr_position.to_be_bytes())?
.ok_or_else(|| ChainStorageError::ValueNotFound {
@@ -1773,6 +1776,9 @@ impl BlockchainBackend for LMDBDatabase {
// TODO: Can be merged with the method above
fn fetch_header_containing_utxo_mmr(&self, mmr_position: u64) -> Result {
let txn = self.read_transaction()?;
+ // LMDB returns the height at the position, so we have to offset the position by 1 so that the mmr_position arg
+ // is an index starting from 0
+ let mmr_position = mmr_position + 1;
let (height, _hash) =
lmdb_first_after::<_, (u64, Vec)>(&txn, &self.output_mmr_size_index, &mmr_position.to_be_bytes())?
diff --git a/base_layer/core/src/chain_storage/tests/blockchain_database.rs b/base_layer/core/src/chain_storage/tests/blockchain_database.rs
index d6a8a10818..5bb31b4d19 100644
--- a/base_layer/core/src/chain_storage/tests/blockchain_database.rs
+++ b/base_layer/core/src/chain_storage/tests/blockchain_database.rs
@@ -575,7 +575,7 @@ mod fetch_header_containing_utxo_mmr {
assert_eq!(header.height(), 0);
mmr_position += 1;
});
- let err = db.fetch_header_containing_utxo_mmr(4002).unwrap_err();
+ let err = db.fetch_header_containing_utxo_mmr(mmr_position).unwrap_err();
matches!(err, ChainStorageError::ValueNotFound { .. });
}
@@ -586,12 +586,16 @@ mod fetch_header_containing_utxo_mmr {
let _ = add_many_chained_blocks(5, &db);
let num_genesis_outputs = genesis.block().body.outputs().len() as u64;
+ let header = db.fetch_header_containing_utxo_mmr(num_genesis_outputs - 1).unwrap();
+ assert_eq!(header.height(), 0);
+
for i in 1..=5 {
- let header = db.fetch_header_containing_utxo_mmr(num_genesis_outputs + i).unwrap();
- assert_eq!(header.height(), i);
+ let index = num_genesis_outputs + i - 1;
+ let header = db.fetch_header_containing_utxo_mmr(index).unwrap();
+ assert_eq!(header.height(), i, "Incorrect header for MMR index = {}", index);
}
let err = db
- .fetch_header_containing_utxo_mmr(num_genesis_outputs + 5 + 1)
+ .fetch_header_containing_utxo_mmr(num_genesis_outputs + 5)
.unwrap_err();
matches!(err, ChainStorageError::ValueNotFound { .. });
}
@@ -605,13 +609,13 @@ mod fetch_header_containing_kernel_mmr {
let db = setup();
let genesis = db.fetch_block(0).unwrap();
assert_eq!(genesis.block().body.kernels().len(), 2);
- // let mut mmr_position = 0;
- // genesis.block().body.kernels().iter().for_each(|_| {
- // let header = db.fetch_header_containing_kernel_mmr(mmr_position).unwrap();
- // assert_eq!(header.height(), 0);
- // mmr_position += 1;
- // });
- let err = db.fetch_header_containing_kernel_mmr(3).unwrap_err();
+ let mut mmr_position = 0;
+ genesis.block().body.kernels().iter().for_each(|_| {
+ let header = db.fetch_header_containing_kernel_mmr(mmr_position).unwrap();
+ assert_eq!(header.height(), 0);
+ mmr_position += 1;
+ });
+ let err = db.fetch_header_containing_kernel_mmr(mmr_position).unwrap_err();
matches!(err, ChainStorageError::ValueNotFound { .. });
}
@@ -627,22 +631,22 @@ mod fetch_header_containing_kernel_mmr {
db.add_block(block).unwrap();
let _ = add_many_chained_blocks(3, &db);
- let header = db.fetch_header_containing_kernel_mmr(num_genesis_kernels).unwrap();
+ let header = db.fetch_header_containing_kernel_mmr(num_genesis_kernels - 1).unwrap();
assert_eq!(header.height(), 0);
- let header = db.fetch_header_containing_kernel_mmr(num_genesis_kernels + 1).unwrap();
+ let header = db.fetch_header_containing_kernel_mmr(num_genesis_kernels).unwrap();
assert_eq!(header.height(), 1);
- for i in 2..=3 {
+ for i in 1..=2 {
let header = db.fetch_header_containing_kernel_mmr(num_genesis_kernels + i).unwrap();
assert_eq!(header.height(), 2);
}
- for i in 4..=6 {
+ for i in 3..=5 {
let header = db.fetch_header_containing_kernel_mmr(num_genesis_kernels + i).unwrap();
- assert_eq!(header.height(), i - 1);
+ assert_eq!(header.height(), i);
}
let err = db
- .fetch_header_containing_kernel_mmr(num_genesis_kernels + 6 + 1)
+ .fetch_header_containing_kernel_mmr(num_genesis_kernels + 6)
.unwrap_err();
matches!(err, ChainStorageError::ValueNotFound { .. });
}
diff --git a/base_layer/core/src/transactions/transaction_protocol/recipient.rs b/base_layer/core/src/transactions/transaction_protocol/recipient.rs
index 1aca21dc84..7aae24f19d 100644
--- a/base_layer/core/src/transactions/transaction_protocol/recipient.rs
+++ b/base_layer/core/src/transactions/transaction_protocol/recipient.rs
@@ -30,7 +30,7 @@ use tari_common_types::{
use crate::transactions::{
crypto_factories::CryptoFactories,
- transaction::{OutputFeatures, TransactionOutput},
+ transaction::TransactionOutput,
transaction_protocol::{
sender::{SingleRoundSenderData as SD, TransactionSenderMessage},
single_receiver::SingleReceiverTransactionProtocol,
@@ -110,13 +110,12 @@ impl ReceiverTransactionProtocol {
info: TransactionSenderMessage,
nonce: PrivateKey,
spending_key: PrivateKey,
- features: OutputFeatures,
factories: &CryptoFactories,
) -> ReceiverTransactionProtocol {
let state = match info {
TransactionSenderMessage::None => RecipientState::Failed(TransactionProtocolError::InvalidStateError),
TransactionSenderMessage::Single(v) => {
- ReceiverTransactionProtocol::single_round(nonce, spending_key, features, &v, factories, None)
+ ReceiverTransactionProtocol::single_round(nonce, spending_key, &v, factories, None)
},
TransactionSenderMessage::Multiple => Self::multi_round(),
};
@@ -129,20 +128,14 @@ impl ReceiverTransactionProtocol {
info: TransactionSenderMessage,
nonce: PrivateKey,
spending_key: PrivateKey,
- features: OutputFeatures,
factories: &CryptoFactories,
rewind_data: &RewindData,
) -> ReceiverTransactionProtocol {
let state = match info {
TransactionSenderMessage::None => RecipientState::Failed(TransactionProtocolError::InvalidStateError),
- TransactionSenderMessage::Single(v) => ReceiverTransactionProtocol::single_round(
- nonce,
- spending_key,
- features,
- &v,
- factories,
- Some(rewind_data),
- ),
+ TransactionSenderMessage::Single(v) => {
+ ReceiverTransactionProtocol::single_round(nonce, spending_key, &v, factories, Some(rewind_data))
+ },
TransactionSenderMessage::Multiple => Self::multi_round(),
};
ReceiverTransactionProtocol { state }
@@ -178,12 +171,11 @@ impl ReceiverTransactionProtocol {
fn single_round(
nonce: PrivateKey,
key: PrivateKey,
- features: OutputFeatures,
data: &SD,
factories: &CryptoFactories,
rewind_data: Option<&RewindData>,
) -> RecipientState {
- let signer = SingleReceiverTransactionProtocol::create(data, nonce, key, features, factories, rewind_data);
+ let signer = SingleReceiverTransactionProtocol::create(data, nonce, key, factories, rewind_data);
match signer {
Ok(signed_data) => RecipientState::Finalized(Box::new(signed_data)),
Err(e) => RecipientState::Failed(e),
@@ -252,7 +244,7 @@ mod test {
public_nonce: PublicKey::from_secret_key(&p.change_spend_key), // any random key will do
metadata: m.clone(),
message: "".to_string(),
- features: features.clone(),
+ features,
script,
sender_offset_public_key: p.sender_offset_public_key,
public_commitment_nonce: p.sender_public_commitment_nonce,
@@ -260,8 +252,7 @@ mod test {
};
let sender_info = TransactionSenderMessage::Single(Box::new(msg.clone()));
let pubkey = PublicKey::from_secret_key(&p.spend_key);
- let receiver =
- ReceiverTransactionProtocol::new(sender_info, p.nonce.clone(), p.spend_key.clone(), features, &factories);
+ let receiver = ReceiverTransactionProtocol::new(sender_info, p.nonce.clone(), p.spend_key.clone(), &factories);
assert!(receiver.is_finalized());
let data = receiver.get_signed_data().unwrap();
assert_eq!(data.tx_id.as_u64(), 15);
@@ -300,7 +291,7 @@ mod test {
public_nonce: PublicKey::from_secret_key(&p.change_spend_key), // any random key will do
metadata: m,
message: "".to_string(),
- features: features.clone(),
+ features,
script,
sender_offset_public_key: p.sender_offset_public_key,
public_commitment_nonce: p.sender_public_commitment_nonce,
@@ -316,7 +307,6 @@ mod test {
sender_info,
p.nonce.clone(),
p.spend_key.clone(),
- features,
&factories,
&rewind_data,
);
diff --git a/base_layer/core/src/transactions/transaction_protocol/sender.rs b/base_layer/core/src/transactions/transaction_protocol/sender.rs
index d6cd156159..8c231d5b79 100644
--- a/base_layer/core/src/transactions/transaction_protocol/sender.rs
+++ b/base_layer/core/src/transactions/transaction_protocol/sender.rs
@@ -902,7 +902,7 @@ mod test {
.with_offset(a.offset.clone())
.with_private_nonce(a.nonce.clone())
.with_input(utxo.clone(), input)
- .with_recipient_data(0, script.clone(), PrivateKey::random(&mut OsRng), features.clone(), PrivateKey::random(&mut OsRng), Covenant::default())
+ .with_recipient_data(0, script.clone(), PrivateKey::random(&mut OsRng), features, PrivateKey::random(&mut OsRng), Covenant::default())
.with_change_script(script, ExecutionStack::default(), PrivateKey::default())
// A little twist: Check the case where the change is less than the cost of another output
.with_amount(0, MicroTari(1200) - fee - MicroTari(10));
@@ -918,7 +918,7 @@ mod test {
// Receiver gets message, deserializes it etc, and creates his response
let mut bob_info =
- SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, features, &factories, None).unwrap(); // Alice gets message back, deserializes it, etc
+ SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, &factories, None).unwrap(); // Alice gets message back, deserializes it, etc
alice
.add_single_recipient_info(bob_info.clone(), &factories.range_proof)
.unwrap();
@@ -968,7 +968,7 @@ mod test {
0,
script.clone(),
PrivateKey::random(&mut OsRng),
- features.clone(),
+ features,
PrivateKey::random(&mut OsRng),
Covenant::default(),
)
@@ -993,8 +993,7 @@ mod test {
let mut alice = SenderTransactionProtocol::load_pending_transaction_to_be_sent(ser).unwrap();
// Receiver gets message, deserializes it etc, and creates his response
- let bob_info =
- SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, features, &factories, None).unwrap();
+ let bob_info = SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, &factories, None).unwrap();
println!(
"Bob's key: {}, Nonce: {}, Signature: {}, Commitment: {}",
bob_info.public_spend_key.to_hex(),
@@ -1049,7 +1048,7 @@ mod test {
0,
script.clone(),
PrivateKey::random(&mut OsRng),
- features.clone(),
+ features,
PrivateKey::random(&mut OsRng),
Covenant::default(),
)
@@ -1061,8 +1060,7 @@ mod test {
// Send message down the wire....and wait for response
assert!(alice.is_collecting_single_signature());
// Receiver gets message, deserializes it etc, and creates his response
- let bob_info =
- SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, features, &factories, None).unwrap(); // Alice gets message back, deserializes it, etc
+ let bob_info = SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, &factories, None).unwrap(); // Alice gets message back, deserializes it, etc
match alice.add_single_recipient_info(bob_info, &factories.range_proof) {
Ok(_) => panic!("Range proof should have failed to verify"),
Err(e) => assert_eq!(
@@ -1181,7 +1179,7 @@ mod test {
0,
script.clone(),
PrivateKey::random(&mut OsRng),
- features.clone(),
+ features,
PrivateKey::random(&mut OsRng),
Covenant::default(),
)
@@ -1205,8 +1203,7 @@ mod test {
assert!(alice.is_collecting_single_signature());
// Receiver gets message, deserializes it etc, and creates his response
- let bob_info =
- SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, features, &factories, None).unwrap();
+ let bob_info = SingleReceiverTransactionProtocol::create(&msg, b.nonce, b.spend_key, &factories, None).unwrap();
// Alice gets message back, deserializes it, etc
alice
diff --git a/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs b/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs
index d51daa4242..19ffc76800 100644
--- a/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs
+++ b/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs
@@ -30,7 +30,7 @@ use tari_crypto::{
use crate::transactions::{
crypto_factories::CryptoFactories,
- transaction::{OutputFeatures, TransactionOutput},
+ transaction::TransactionOutput,
transaction_protocol::{
build_challenge,
recipient::RecipientSignedMessage as RD,
@@ -53,18 +53,12 @@ impl SingleReceiverTransactionProtocol {
sender_info: &SD,
nonce: SK,
spending_key: SK,
- features: OutputFeatures,
factories: &CryptoFactories,
rewind_data: Option<&RewindData>,
) -> Result {
SingleReceiverTransactionProtocol::validate_sender_data(sender_info)?;
- let output = SingleReceiverTransactionProtocol::build_output(
- sender_info,
- &spending_key,
- features,
- factories,
- rewind_data,
- )?;
+ let output =
+ SingleReceiverTransactionProtocol::build_output(sender_info, &spending_key, factories, rewind_data)?;
let public_nonce = PublicKey::from_secret_key(&nonce);
let public_spending_key = PublicKey::from_secret_key(&spending_key);
let e = build_challenge(&(&sender_info.public_nonce + &public_nonce), &sender_info.metadata);
@@ -89,7 +83,6 @@ impl SingleReceiverTransactionProtocol {
fn build_output(
sender_info: &SD,
spending_key: &SK,
- features: OutputFeatures,
factories: &CryptoFactories,
rewind_data: Option<&RewindData>,
) -> Result {
@@ -111,18 +104,20 @@ impl SingleReceiverTransactionProtocol {
.construct_proof(spending_key, sender_info.amount.into())?
};
+ let sender_features = sender_info.features.clone();
+
let partial_metadata_signature = TransactionOutput::create_partial_metadata_signature(
&sender_info.amount,
&spending_key.clone(),
&sender_info.script,
- &sender_info.features,
+ &sender_features,
&sender_info.sender_offset_public_key,
&sender_info.public_commitment_nonce,
&sender_info.covenant,
)?;
let output = TransactionOutput::new_current_version(
- features,
+ sender_features,
commitment,
RangeProof::from_bytes(&proof)
.map_err(|_| TPE::RangeProofError(RangeProofError::ProofConstructionError))?,
@@ -169,8 +164,8 @@ mod test {
fn zero_amount_fails() {
let factories = CryptoFactories::default();
let info = SingleRoundSenderData::default();
- let (r, k, of) = generate_output_parms();
- match SingleReceiverTransactionProtocol::create(&info, r, k, of, &factories, None) {
+ let (r, k, _) = generate_output_parms();
+ match SingleReceiverTransactionProtocol::create(&info, r, k, &factories, None) {
Ok(_) => panic!("Zero amounts should fail"),
Err(TransactionProtocolError::ValidationError(s)) => assert_eq!(s, "Cannot send zero microTari"),
Err(_) => panic!("Protocol fails for the wrong reason"),
@@ -201,13 +196,13 @@ mod test {
public_nonce: pub_rs.clone(),
metadata: m.clone(),
message: "".to_string(),
- features: of.clone(),
+ features: of,
script,
sender_offset_public_key,
public_commitment_nonce,
covenant: Default::default(),
};
- let prot = SingleReceiverTransactionProtocol::create(&info, r, k.clone(), of, &factories, None).unwrap();
+ let prot = SingleReceiverTransactionProtocol::create(&info, r, k.clone(), &factories, None).unwrap();
assert_eq!(prot.tx_id.as_u64(), 500, "tx_id is incorrect");
// Check the signature
assert_eq!(prot.public_spend_key, pubkey, "Public key is incorrect");
diff --git a/base_layer/wallet/src/output_manager_service/service.rs b/base_layer/wallet/src/output_manager_service/service.rs
index 2a8aedd8ac..3f51a32f8f 100644
--- a/base_layer/wallet/src/output_manager_service/service.rs
+++ b/base_layer/wallet/src/output_manager_service/service.rs
@@ -648,7 +648,6 @@ where
sender_message.clone(),
nonce,
spending_key,
- single_round_sender_data.features.clone(),
&self.resources.factories,
self.resources.master_key_manager.rewind_data(),
);
diff --git a/base_layer/wallet/src/transaction_service/service.rs b/base_layer/wallet/src/transaction_service/service.rs
index 73252d36e5..e83538c4f6 100644
--- a/base_layer/wallet/src/transaction_service/service.rs
+++ b/base_layer/wallet/src/transaction_service/service.rs
@@ -939,7 +939,6 @@ where
sender_message,
PrivateKey::random(&mut OsRng),
spend_key.clone(),
- OutputFeatures::default(),
&self.resources.factories,
&rewind_data,
);
@@ -1099,7 +1098,6 @@ where
sender_message,
PrivateKey::random(&mut OsRng),
spend_key,
- OutputFeatures::default(),
&self.resources.factories,
&rewind_data,
);
diff --git a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs
index 02798d3f3c..8dc318d5e8 100644
--- a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs
+++ b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs
@@ -2168,7 +2168,6 @@ mod test {
TransactionSenderMessage::Single(Box::new(stp.build_single_round_message().unwrap())),
PrivateKey::random(&mut OsRng),
PrivateKey::random(&mut OsRng),
- OutputFeatures::default(),
&factories,
);
diff --git a/base_layer/wallet/tests/transaction_service_tests/service.rs b/base_layer/wallet/tests/transaction_service_tests/service.rs
index a1103ef294..b145f8ef8c 100644
--- a/base_layer/wallet/tests/transaction_service_tests/service.rs
+++ b/base_layer/wallet/tests/transaction_service_tests/service.rs
@@ -1430,7 +1430,6 @@ fn test_accepting_unknown_tx_id_and_malformed_reply() {
sender_message.try_into().unwrap(),
params.nonce,
params.spend_key,
- OutputFeatures::default(),
&factories,
);
@@ -2997,13 +2996,8 @@ fn test_restarting_transaction_protocols() {
let tx_id = msg.tx_id;
let sender_info = TransactionSenderMessage::Single(Box::new(msg.clone()));
- let receiver_protocol = ReceiverTransactionProtocol::new(
- sender_info,
- alice.nonce.clone(),
- alice.spend_key,
- OutputFeatures::default(),
- &factories,
- );
+ let receiver_protocol =
+ ReceiverTransactionProtocol::new(sender_info, alice.nonce.clone(), alice.spend_key, &factories);
let alice_reply = receiver_protocol.get_signed_data().unwrap().clone();
@@ -4415,7 +4409,6 @@ fn test_resend_on_startup() {
tx_sender_msg,
PrivateKey::random(&mut OsRng),
PrivateKey::random(&mut OsRng),
- OutputFeatures::default(),
&factories,
);
diff --git a/base_layer/wallet/tests/transaction_service_tests/storage.rs b/base_layer/wallet/tests/transaction_service_tests/storage.rs
index d9e616dac0..72b2cf2052 100644
--- a/base_layer/wallet/tests/transaction_service_tests/storage.rs
+++ b/base_layer/wallet/tests/transaction_service_tests/storage.rs
@@ -169,7 +169,6 @@ pub fn test_db_backend(backend: T) {
TransactionSenderMessage::Single(Box::new(stp.clone().build_single_round_message().unwrap())),
PrivateKey::random(&mut OsRng),
PrivateKey::random(&mut OsRng),
- OutputFeatures::default(),
&factories,
);
|