Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug method for constructing valid consignments #221

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/containers/consignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use amplify::{ByteArray, Bytes32};
use armor::{ArmorHeader, AsciiArmor, StrictArmor};
use baid64::{Baid64ParseError, DisplayBaid64, FromBaid64Str};
use commit_verify::{CommitEncode, CommitEngine, CommitId, CommitmentId, DigestExt, Sha256};
use rgb::validation::{ResolveWitness, Validator, Validity, Warning, CONSIGNMENT_MAX_LIBS};
use rgb::validation::{ResolveWitness, Status, Validator, Validity, Warning, CONSIGNMENT_MAX_LIBS};
use rgb::{
impl_serde_baid64, validation, AttachId, BundleId, ContractHistory, ContractId, Extension,
Genesis, GraphSeal, Operation, Schema, SchemaId, XChain,
Expand Down Expand Up @@ -388,6 +388,24 @@ impl<const TRANSFER: bool> Consignment<TRANSFER> {
})
}
}

/// Method to forcefully construct a valid consignment, which can be consumed by a stash.
///
Copy link
Member Author

@dr-orlovsky dr-orlovsky Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I strictly disagree with this. It has no - and must not has (!) any other use than the debug purposes, since any other use is literally a security leak. My opinion is so strong, that until the public audit conclusion on this issue I will just fork this repository and will contribute to the fork not having this security issue.

/// # Safety
///
/// Warning: this runs no actual validation, but still constructs a [`ValidConsignment`]. If
/// used improperly this could lead to loss of funds. The method must be used only for special
/// purposes where it's necessary to consume a consignment even though standard rules prevent
Comment on lines +397 to +398
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no other "special purposes" than debugging!

/// it. Use with extreme care and only if you know what you're doing.
pub fn assume_valid_unsafe(self) -> ValidConsignment<TRANSFER> {
let validation_status = Status::with_failure(validation::Failure::Custom(s!(
"consignment was assumed valid with no actual validation"
)));
ValidConsignment {
validation_status,
consignment: self,
}
}
}

impl<const TRANSFER: bool> StrictArmor for Consignment<TRANSFER> {
Expand Down
Loading