diff --git a/applications/tari_explorer/app.js b/applications/tari_explorer/app.js
index 8c75f973ea..724c30e994 100644
--- a/applications/tari_explorer/app.js
+++ b/applications/tari_explorer/app.js
@@ -70,6 +70,8 @@ hbs.registerHelper("json", function (obj) {
return JSON.stringify(obj);
});
+hbs.registerPartials(path.join(__dirname, "partials"));
+
var app = express();
// view engine setup
diff --git a/applications/tari_explorer/partials/CheckpointParameters.hbs b/applications/tari_explorer/partials/CheckpointParameters.hbs
new file mode 100644
index 0000000000..5db2cc1e1f
--- /dev/null
+++ b/applications/tari_explorer/partials/CheckpointParameters.hbs
@@ -0,0 +1,4 @@
+
+ - Abandoned interval
- {{abandoned_interval}}
+ - Minimum quorum required
- {{minimum_quorum_required}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ComSignature.hbs b/applications/tari_explorer/partials/ComSignature.hbs
new file mode 100644
index 0000000000..11bc902c7a
--- /dev/null
+++ b/applications/tari_explorer/partials/ComSignature.hbs
@@ -0,0 +1,5 @@
+
+ - Public nonce commitment
- {{hex public_nonce_commitment}}
+ - Signature u
- {{hex signature_u}}
+ - Signature v
- {{hex signature_v}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/CommitteeMembers.hbs b/applications/tari_explorer/partials/CommitteeMembers.hbs
new file mode 100644
index 0000000000..43c11e3ec7
--- /dev/null
+++ b/applications/tari_explorer/partials/CommitteeMembers.hbs
@@ -0,0 +1,6 @@
+
+ - Members
+ {{#each this.members as |member|}}
+ - {{hex member}}
+ {{/each}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/CommitteeSignatures.hbs b/applications/tari_explorer/partials/CommitteeSignatures.hbs
new file mode 100644
index 0000000000..80c3c74fff
--- /dev/null
+++ b/applications/tari_explorer/partials/CommitteeSignatures.hbs
@@ -0,0 +1,6 @@
+
+ - Signatures
+ {{#each signatures as |signature|}}
+ - {{>Signature signature}}
+ {{/each}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ConstitutionChangeRules.hbs b/applications/tari_explorer/partials/ConstitutionChangeRules.hbs
new file mode 100644
index 0000000000..09d56df4e6
--- /dev/null
+++ b/applications/tari_explorer/partials/ConstitutionChangeRules.hbs
@@ -0,0 +1,7 @@
+
+ - Change flags
- {{change_flags}}
+ {{#if requirements_for_constitution_change}}
+ - Requirements for constitution change
+ - {{>RequirementsForConstitutionChange requirements_for_constitution_change}}
+ {{/if}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractAcceptance.hbs b/applications/tari_explorer/partials/ContractAcceptance.hbs
new file mode 100644
index 0000000000..c6d2492bbe
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractAcceptance.hbs
@@ -0,0 +1,7 @@
+
+ - Validator node public key
- {{hex validator_node_public_key}}
+ {{#if signature}}
+ - Signature
+ - {{>Signature signature}}
+ {{/if}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractAcceptanceRequirements.hbs b/applications/tari_explorer/partials/ContractAcceptanceRequirements.hbs
new file mode 100644
index 0000000000..b0e1b3515c
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractAcceptanceRequirements.hbs
@@ -0,0 +1,4 @@
+
+ - Acceptance period expiry
- {{acceptance_period_expiry}}
+ - Minimum quorum required
- {{minimum_quorum_required}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractAmendment.hbs b/applications/tari_explorer/partials/ContractAmendment.hbs
new file mode 100644
index 0000000000..e6cc920b32
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractAmendment.hbs
@@ -0,0 +1,16 @@
+
+ - Proposal id
- {{proposal_id}}
+ {{#if validator_committee}}
+ - Validator committee
+ {{>CommitteeMembers validator_committee}}
+ {{/if}}
+ {{#if validator_signatures}}
+ - Validator signatures
+ {{>CommitteeSignatures validator_signatures}}
+ {{/if}}
+ {{#if updated_constitution}}
+ - Updated constitution
+ - {{>ContractConstitution updated_constitution}}
+ {{/if}}
+ - Activation window
- {{activation_window}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractCheckpoint.hbs b/applications/tari_explorer/partials/ContractCheckpoint.hbs
new file mode 100644
index 0000000000..cc0dade72d
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractCheckpoint.hbs
@@ -0,0 +1,4 @@
+
+ - Merkle root
- {{hex merkle_root}}
+ - Signatures
- {{>CommitteeSignatures signatures}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractConstitution.hbs b/applications/tari_explorer/partials/ContractConstitution.hbs
new file mode 100644
index 0000000000..73c933626f
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractConstitution.hbs
@@ -0,0 +1,18 @@
+
+ - Validator committee
+ - {{>CommitteeMembers validator_committee}}
+ {{#if acceptance_requirements}}
+ - Acceptance requirements
+ - {{>ContractAcceptanceRequirements acceptance_requirements}}
+ {{/if}}
+ - Consensus
- {{consensus}}
+ {{#if checkpoint_params}}
+ - Checkpoint params
+ - {{>CheckpointParameters checkpoint_params}}
+ {{/if}}
+ {{#if constitution_change_rules}}
+ - Constitution change rules
+ - {{>ConstitutionChangeRules constitution_change_rules}}
+ {{/if}}
+ - Initial reward
- {{initial_reward}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractDefinition.hbs b/applications/tari_explorer/partials/ContractDefinition.hbs
new file mode 100644
index 0000000000..5352e3a2f6
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractDefinition.hbs
@@ -0,0 +1,5 @@
+
+ - Contract name
- {{contract_name}}
+ - Contract issuer
- {{hex contract_issuer}}
+ - Contract spec
- {{>ContractSpecification contract_spec}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractSpecification.hbs b/applications/tari_explorer/partials/ContractSpecification.hbs
new file mode 100644
index 0000000000..98a4a36d66
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractSpecification.hbs
@@ -0,0 +1,9 @@
+
+ - runtime
- {{runtime}}
+ {{#if public_functions.length}}
+ - Public functions
+ {{#each public_functions as |public_function|}}
+ - {{>PublicFunction public_function}}
+ {{/each}}
+ {{/if}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractUpdateProposal.hbs b/applications/tari_explorer/partials/ContractUpdateProposal.hbs
new file mode 100644
index 0000000000..1b10eb5d83
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractUpdateProposal.hbs
@@ -0,0 +1,11 @@
+
+ - Proposal id
- {{proposal_id}}
+ {{#if signature}}
+ - Signature
+ - {{>Signature signature}}
+ {{/if}}
+ {{#if updated_constitution}}
+ - Updated constitution
+ - {{>ContractConstitution updated_constitution}}
+ {{/if}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/ContractUpdateProposalAcceptance.hbs b/applications/tari_explorer/partials/ContractUpdateProposalAcceptance.hbs
new file mode 100644
index 0000000000..a3607e3c7b
--- /dev/null
+++ b/applications/tari_explorer/partials/ContractUpdateProposalAcceptance.hbs
@@ -0,0 +1,8 @@
+
+ - Proposal id
- {{proposal_id}}
+ - Validator node public key
- {{hex validator_node_public_key}}
+ {{#if signature}}
+ - Signature
+ - {{>Signature signature}}
+ {{/if}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/FunctionRef.hbs b/applications/tari_explorer/partials/FunctionRef.hbs
new file mode 100644
index 0000000000..28ff79a48c
--- /dev/null
+++ b/applications/tari_explorer/partials/FunctionRef.hbs
@@ -0,0 +1,4 @@
+
+ - Template id
- {{hex template_id}}
+ - Function id
- {{function_id}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/OutputFeatures.hbs b/applications/tari_explorer/partials/OutputFeatures.hbs
new file mode 100644
index 0000000000..821f17e2b5
--- /dev/null
+++ b/applications/tari_explorer/partials/OutputFeatures.hbs
@@ -0,0 +1,39 @@
+{{#*inline 1}}
+Coinbase
+{{/inline}}
+{{#*inline 2}}
+Contract definition
+{{/inline}}
+{{#*inline 3}}
+Contract constitution
+{{/inline}}
+{{#*inline 4}}
+Contract validator acceptance
+{{/inline}}
+{{#*inline 5}}
+Contract checkpoint
+{{/inline}}
+{{#*inline 6}}
+Contract constitution proposal
+{{/inline}}
+{{#*inline 7}}
+Contract constitution change acceptance
+{{/inline}}
+
+ - Version
- {{version}}
+ - Output Type
+ -
+ {{#> (lookup . 'output_type')}}
+ {{!-- Lookup to output_type 0 will evaluate as undefined, so there can't be inline partial for 0 as is for the rest above--}}
+ Standard
+ {{/undefined}}
+
+ - Maturity
- {{maturity}}
+ {{#if metadata.length}}- Metadata
- {{json metadata}}
{{/if}}
+ - Recovery byte
- {{recovery_byte}}
+ {{#if sidechain_features}}
+ - Sidechain Features
+ {{>SideChainFeatures sidechain_features}}
+ {{/if}}
+ {{#if unique_id.length}}- Unique id
- {{hex unique_id}}
{{/if}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/PublicFunction.hbs b/applications/tari_explorer/partials/PublicFunction.hbs
new file mode 100644
index 0000000000..668970bcf5
--- /dev/null
+++ b/applications/tari_explorer/partials/PublicFunction.hbs
@@ -0,0 +1,4 @@
+
+ - Name
- {{name}}
+ - Function
- {{>FunctionRef function}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/RequirementsForConstitutionChange.hbs b/applications/tari_explorer/partials/RequirementsForConstitutionChange.hbs
new file mode 100644
index 0000000000..ec09258531
--- /dev/null
+++ b/applications/tari_explorer/partials/RequirementsForConstitutionChange.hbs
@@ -0,0 +1,6 @@
+
+ - Minimum constitution committee signatures
+ - {{minimum_constitution_committee_signatures}}
+ - Constitution committee
+ - {{>CommitteeMembers constitution_committee}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/SideChainFeatures.hbs b/applications/tari_explorer/partials/SideChainFeatures.hbs
new file mode 100644
index 0000000000..5bafbb1bd8
--- /dev/null
+++ b/applications/tari_explorer/partials/SideChainFeatures.hbs
@@ -0,0 +1,33 @@
+
+
+ - Contract id
- {{hex contract_id}}
+ {{#if definition}}
+ - Definition
+ - {{>ContractDefinition definition}}
+ {{/if}}
+ {{#if constitution}}
+ - Constitution
+ - {{>ContractConstitution constitution}}
+ {{/if}}
+ {{#if acceptance}}
+ - Acceptance
+ - {{>ContractAcceptance acceptance}}
+ {{/if}}
+ {{#if update_proposal}}
+ - Update proposal
+ - {{>ContractUpdateProposal update_proposal}}
+ {{/if}}
+ {{#if update_proposal_acceptance}}
+ - Update proposal acceptance
+ - {{>ContractUpdateProposalAcceptance update_proposal_acceptance}}
+ {{/if}}
+ {{#if amendment}}
+ - amendment
+ - {{>ContractAmendment amendment}}
+ {{/if}}
+ {{#if checkpoint}}
+ - Checkpoint
+ - {{>ContractCheckpoint checkpoint}}
+ {{/if}}
+
+
diff --git a/applications/tari_explorer/partials/Signature.hbs b/applications/tari_explorer/partials/Signature.hbs
new file mode 100644
index 0000000000..b8e00e985c
--- /dev/null
+++ b/applications/tari_explorer/partials/Signature.hbs
@@ -0,0 +1,4 @@
+
+ - Public nonce
- {{hex public_nonce}}
+ - Signature
- {{hex signature}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/TransactionInput.hbs b/applications/tari_explorer/partials/TransactionInput.hbs
new file mode 100644
index 0000000000..d6fa54cd7b
--- /dev/null
+++ b/applications/tari_explorer/partials/TransactionInput.hbs
@@ -0,0 +1,13 @@
+
+ - Features
- {{>OutputFeatures features}}
+ - Commitment
- {{hex commitment}}
+ - Hash
- {{hex hash}}
+ - Script
- {{hex script}}
+ - Input data
- {{hex input_data}}
+ - Script signature
- {{>ComSignature script_signature}}
+ - Sender offset public key
- {{hex sender_offset_public_key}}
+ - Output hash
- {{hex output_hash}}
+ - Covenant
- {{hex covenant}}
+ - Version
- {{version}}
+ - Encrypted value
- {{hex encrypted_value}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/TransactionKernel.hbs b/applications/tari_explorer/partials/TransactionKernel.hbs
new file mode 100644
index 0000000000..f77de05361
--- /dev/null
+++ b/applications/tari_explorer/partials/TransactionKernel.hbs
@@ -0,0 +1,9 @@
+
+ - Features
- {{features}}
+ - Fee
- {{fee}}
+ - Lock height
- {{lock_height}}
+ - Excess
- {{hex excess}}
+ - Excess sig
- {{>Signature excess_sig}}
+ - Hash
- {{hex hash}}
+ - Version
- {{version}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/partials/TransactionOutput.hbs b/applications/tari_explorer/partials/TransactionOutput.hbs
new file mode 100644
index 0000000000..2221487c0a
--- /dev/null
+++ b/applications/tari_explorer/partials/TransactionOutput.hbs
@@ -0,0 +1,15 @@
+
+ - Features
+ -
+ {{>OutputFeatures features}}
+
+ - Commitment
- {{hex commitment}}
+ - Hash
- {{hex hash}}
+ - Script
- {{hex script}}
+ - Sender offset public key
- {{hex sender_offset_public_key}}
+ - Metadata signature
+ - {{>ComSignature metadata_signature}}
+ {{#if covenant.length}}- Covenant
- {{covenant}}
{{/if}}
+ - Version
- {{version}}
+ {{#if encrypted_value.length}}- Encrypted value
- {{hex encrypted_value}}
{{/if}}
+
\ No newline at end of file
diff --git a/applications/tari_explorer/views/blocks.hbs b/applications/tari_explorer/views/blocks.hbs
index f1fe50a674..03ba99f780 100644
--- a/applications/tari_explorer/views/blocks.hbs
+++ b/applications/tari_explorer/views/blocks.hbs
@@ -73,86 +73,64 @@
-
-Kernels
-
-
-
- Hash |
- Excess |
- Excess Signature |
- Fee |
- Lock Height |
- Features |
-
-
-
- {{#each this.block.body.kernels}}
+{{#with this.block.body}}
+
+
- {{hex hash}} |
- {{hex excess}} |
- Nonce:{{hex excess_sig.public_nonce}}
- Sig:{{hex excess_sig.signature}} |
- {{fee}} |
- {{lock_height}} |
- {{features}} |
+
+ Kernels({{kernels.length}})
+ |
- {{/each}}
-
-
+
+
+ {{#each kernels as |kernel|}}
+
+
+ Kernel {{@index}}
+ {{>TransactionKernel kernel}}
+ |
+
+ {{/each}}
+
+
-
-Outputs
-
-
-
- Hash |
- Commitment |
- Flags |
- Maturity |
- Parent PK |
- Unique Id |
- Other Features |
- Script |
-
-
-
- {{#each this.block.body.outputs}}
+
+
- {{hex hash}} |
- {{hex commitment}} |
- {{features.flags}} |
- {{features.maturity}} |
- {{hex
- features.parent_public_key
- }} |
- {{hex features.unique_id}} |
- {{json features}} |
- {{hex script}} |
+
+ Outputs({{outputs.length}})
+ |
- {{/each}}
-
-
+
+
+ {{#each outputs as |output|}}
+
+
+ Output {{@index}}
+ {{>TransactionOutput output}}
+ |
+
+ {{/each}}
+
+
-
-Spent Inputs
-
-
-
- Hash |
- Commitment |
- Flags |
- Maturity |
-
-
-
- {{#each this.block.body.inputs}}
+
+
- {{hex hash}} |
- {{hex commitment}} |
- {{features.flags}} |
- {{features.maturity}} |
+
+ Inputs({{inputs.length}})
+ |
- {{/each}}
-
-
\ No newline at end of file
+
+
+ {{#each inputs as |input|}}
+
+
+ Input {{@index}}
+ {{>TransactionInput input}}
+ |
+
+ {{/each}}
+
+
+{{/with}}
\ No newline at end of file
diff --git a/applications/tari_explorer/views/layout.hbs b/applications/tari_explorer/views/layout.hbs
index 9afc72630d..e06afaf2bb 100644
--- a/applications/tari_explorer/views/layout.hbs
+++ b/applications/tari_explorer/views/layout.hbs
@@ -5,11 +5,11 @@
body { font-family: "Courier New"; font-size: small; margin: 20px; width:
1100px; } h1, h2, h3, h4, h5, h6 { font-family: Arial, Helvetica,
sans-serif; } a { color: #932fff; } table { border-collapse: collapse;
- border: 1px solid #efefef; width: 100%; } th, td { padding: 5px; border:
- 1px solid #efefef; } .noborder, .noborder td, .noborder th { border: none;
- } @media (prefers-color-scheme: dark) { body { background: #111; color:
- #eee; } table { border-color: #333; } th, td { border-color: #333; } }
-
+ border: 1px solid #efefef; width: 100%; margin:1em; } th, td { padding:
+ 5px; border: 1px solid #efefef; } .noborder, .noborder td, .noborder th {
+ border: none; } @media (prefers-color-scheme: dark) { body { background:
+ #111; color: #eee; } } dl {margin:0; font-size:medium} dd {font-style:
+ italic;} dt{font-style: normal;} h2 {margin:0;}
diff --git a/base_layer/wallet/Cargo.toml b/base_layer/wallet/Cargo.toml
index 5e47070a72..a11428d36e 100644
--- a/base_layer/wallet/Cargo.toml
+++ b/base_layer/wallet/Cargo.toml
@@ -37,7 +37,7 @@ chrono = { version = "0.4.19", default-features = false, features = ["serde"] }
clear_on_drop = "=0.2.4"
crossbeam-channel = "0.5.4"
derivative = "2.2.0"
-diesel = { version = "1.4.8", features = ["sqlite", "serde_json", "chrono"] }
+diesel = { version = "1.4.8", features = ["sqlite", "serde_json", "chrono", "64-column-tables"] }
diesel_migrations = "1.4.0"
digest = "0.9.0"
fs2 = "0.3.0"
diff --git a/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/down.sql b/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/down.sql
new file mode 100644
index 0000000000..83e26d0a29
--- /dev/null
+++ b/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/down.sql
@@ -0,0 +1,2 @@
+DROP INDEX outputs_contract_id_index;
+ALTER TABLE outputs DROP COLUMN contract_id;
diff --git a/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/up.sql b/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/up.sql
new file mode 100644
index 0000000000..1dea687f5b
--- /dev/null
+++ b/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/up.sql
@@ -0,0 +1,4 @@
+ALTER TABLE outputs
+ ADD contract_id blob NULL;
+
+CREATE INDEX outputs_contract_id_index ON outputs (contract_id);
\ No newline at end of file
diff --git a/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/down.sql b/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/down.sql
new file mode 100644
index 0000000000..7d6184acc0
--- /dev/null
+++ b/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/down.sql
@@ -0,0 +1,2 @@
+ALTER TABLE outputs
+ RENAME COLUMN output_type TO flags;
diff --git a/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/up.sql b/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/up.sql
new file mode 100644
index 0000000000..7dd8171c09
--- /dev/null
+++ b/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/up.sql
@@ -0,0 +1,2 @@
+ALTER TABLE outputs
+ RENAME COLUMN flags TO output_type;
\ No newline at end of file
diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs
index 2c6a94a40c..ab6eb5d2c7 100644
--- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs
+++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs
@@ -296,9 +296,12 @@ impl OutputManagerBackend for OutputManagerSqliteDatabase {
Ok(result)
}
- fn fetch_with_features(&self, flags: OutputType) -> Result, OutputManagerStorageError> {
+ fn fetch_with_features(
+ &self,
+ output_type: OutputType,
+ ) -> Result, OutputManagerStorageError> {
let conn = self.database_connection.get_pooled_connection()?;
- let mut outputs = OutputSql::index_by_feature_flags(flags, &conn)?;
+ let mut outputs = OutputSql::index_by_output_type(output_type, &conn)?;
for o in &mut outputs {
self.decrypt_if_necessary(o)?;
}
diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs
index 6b4024ffc1..884d1a5367 100644
--- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs
+++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs
@@ -44,7 +44,7 @@ pub struct NewOutputSql {
#[derivative(Debug = "ignore")]
pub spending_key: Vec,
pub value: i64,
- pub flags: i32,
+ pub output_type: i32,
pub maturity: i64,
pub recovery_byte: i32,
pub status: i32,
@@ -65,6 +65,7 @@ pub struct NewOutputSql {
pub features_json: String,
pub covenant: Vec,
pub encrypted_value: Vec,
+ pub contract_id: Option>,
}
impl NewOutputSql {
@@ -79,7 +80,7 @@ impl NewOutputSql {
commitment: Some(output.commitment.to_vec()),
spending_key: output.unblinded_output.spending_key.to_vec(),
value: output.unblinded_output.value.as_u64() as i64,
- flags: i32::from(output.unblinded_output.features.output_type.as_byte()),
+ output_type: i32::from(output.unblinded_output.features.output_type.as_byte()),
maturity: output.unblinded_output.features.maturity as i64,
recovery_byte: i32::from(output.unblinded_output.features.recovery_byte),
status: status as i32,
@@ -108,6 +109,7 @@ impl NewOutputSql {
})?,
covenant: output.unblinded_output.covenant.to_bytes(),
encrypted_value: output.unblinded_output.encrypted_value.to_vec(),
+ contract_id: output.unblinded_output.features.contract_id().map(|h| h.to_vec()),
})
}
@@ -138,7 +140,7 @@ impl From for NewOutputSql {
commitment: o.commitment,
spending_key: o.spending_key,
value: o.value,
- flags: o.flags,
+ output_type: o.output_type,
maturity: o.maturity,
recovery_byte: o.recovery_byte,
status: o.status,
@@ -158,6 +160,7 @@ impl From for NewOutputSql {
features_json: o.features_json,
covenant: o.covenant,
encrypted_value: o.encrypted_value,
+ contract_id: o.contract_id,
}
}
}
diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs
index fc16e08555..2161db7e07 100644
--- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs
+++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs
@@ -71,8 +71,7 @@ pub struct OutputSql {
#[derivative(Debug = "ignore")]
pub spending_key: Vec,
pub value: i64,
- // TODO: Rename this to output_type
- pub flags: i32,
+ pub output_type: i32,
pub maturity: i64,
pub recovery_byte: i32,
pub status: i32,
@@ -101,6 +100,7 @@ pub struct OutputSql {
pub spending_priority: i32,
pub covenant: Vec,
pub encrypted_value: Vec,
+ pub contract_id: Option>,
}
impl OutputSql {
@@ -196,7 +196,11 @@ impl OutputSql {
.filter(outputs::maturity.le(tip_height))
.filter(outputs::features_unique_id.is_null())
.filter(outputs::features_parent_public_key.is_null())
- .filter(outputs::flags.eq(no_flags).or(outputs::flags.eq(coinbase_flag)))
+ .filter(
+ outputs::output_type
+ .eq(no_flags)
+ .or(outputs::output_type.eq(coinbase_flag)),
+ )
.order(outputs::value.desc())
.select(outputs::value)
.limit(1)
@@ -217,7 +221,11 @@ impl OutputSql {
.filter(outputs::maturity.le(tip_height))
.filter(outputs::features_unique_id.is_null())
.filter(outputs::features_parent_public_key.is_null())
- .filter(outputs::flags.eq(no_flags).or(outputs::flags.eq(coinbase_flag)))
+ .filter(
+ outputs::output_type
+ .eq(no_flags)
+ .or(outputs::output_type.eq(coinbase_flag)),
+ )
.order_by(outputs::spending_priority.desc());
match strategy {
UTXOSelectionStrategy::Smallest => {
@@ -256,12 +264,12 @@ impl OutputSql {
.load(conn)?)
}
- pub fn index_by_feature_flags(
- flags: OutputType,
+ pub fn index_by_output_type(
+ output_type: OutputType,
conn: &SqliteConnection,
) -> Result, OutputManagerStorageError> {
- let res = diesel::sql_query("SELECT * FROM outputs where flags & $1 = $1 ORDER BY id;")
- .bind::(i32::from(flags.as_byte()))
+ let res = diesel::sql_query("SELECT * FROM outputs where output_type & $1 = $1 ORDER BY id;")
+ .bind::(i32::from(output_type.as_byte()))
.load(conn)?;
Ok(res)
}
@@ -569,15 +577,16 @@ impl TryFrom for DbUnblindedOutput {
reason: format!("Could not convert json into OutputFeatures:{}", s),
})?;
- let flags = o
- .flags
+ let output_type = o
+ .output_type
.try_into()
.map_err(|_| OutputManagerStorageError::ConversionError {
- reason: format!("Unable to convert flag bits with value {} to OutputType", o.flags),
+ reason: format!("Unable to convert flag bits with value {} to OutputType", o.output_type),
+ })?;
+ features.output_type =
+ OutputType::from_byte(output_type).ok_or(OutputManagerStorageError::ConversionError {
+ reason: "Flags could not be converted from bits".to_string(),
})?;
- features.output_type = OutputType::from_byte(flags).ok_or(OutputManagerStorageError::ConversionError {
- reason: "Flags could not be converted from bits".to_string(),
- })?;
features.maturity = o.maturity as u64;
features.metadata = o.metadata.unwrap_or_default();
features.sidechain_features = o
diff --git a/base_layer/wallet/src/schema.rs b/base_layer/wallet/src/schema.rs
index b746e3d5b6..7027274c95 100644
--- a/base_layer/wallet/src/schema.rs
+++ b/base_layer/wallet/src/schema.rs
@@ -1,5 +1,24 @@
-// Copyright 2022 The Tari Project
-// SPDX-License-Identifier: BSD-3-Clause
+// Copyright 2020. The Tari Project
+//
+// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+// following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
+// disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
+// following disclaimer in the documentation and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
+// products derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
table! {
client_key_values (key) {
@@ -108,7 +127,7 @@ table! {
commitment -> Nullable,
spending_key -> Binary,
value -> BigInt,
- flags -> Integer,
+ output_type -> Integer,
maturity -> BigInt,
recovery_byte -> Integer,
status -> Integer,
@@ -136,6 +155,7 @@ table! {
spending_priority -> Integer,
covenant -> Binary,
encrypted_value -> Binary,
+ contract_id -> Nullable,
}
}