From 581ebedfb7896d69ad65813ef0fa0176031d5b31 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 18 Oct 2023 15:16:44 +0200 Subject: [PATCH] cli: fix force accept of invalid consignments Closes #24 --- src/bin/rgb/command.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bin/rgb/command.rs b/src/bin/rgb/command.rs index 84c8f4c..5abdd27 100644 --- a/src/bin/rgb/command.rs +++ b/src/bin/rgb/command.rs @@ -697,7 +697,16 @@ impl Command { } Command::Accept { force, file } => { let bindle = Bindle::::load(file)?; - let transfer = bindle.unbindle().validate(resolver).unwrap_or_else(|c| c); + let transfer = bindle.unbindle().validate(resolver).or_else(|c| { + if force { + Ok(c) + } else { + Err(RuntimeError::InvalidConsignment( + c.into_validation_status() + .expect("consignment must have status after the validation"), + )) + } + })?; eprintln!("{}", transfer.validation_status().expect("just validated")); runtime.accept_transfer(transfer, resolver, force)?; eprintln!("Transfer accepted into the stash");