Skip to content
28 changes: 10 additions & 18 deletions node/src/actors/chain_manager/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,25 +1306,17 @@ impl Handler<BuildScriptTransaction> for ChainManager {
Box::pin(actix::fut::err(e.into()))
}
Ok(vtt) => {
let fut = signature_mngr::sign_transaction(&vtt, vtt.inputs.len())
.into_actor(self)
.then(|s, _act, _ctx| match s {
Ok(_signatures) => {
let multi_sig_witness = witnet_stack::encode(vec![]);
let num_inputs = vtt.inputs.len();
let transaction = Transaction::ValueTransfer(VTTransaction {
body: vtt,
witness: vec![multi_sig_witness; num_inputs],
});
actix::fut::result(Ok(transaction))
}
Err(e) => {
log::error!("Failed to sign value transfer transaction: {}", e);
actix::fut::result(Err(e))
}
});
// Script transactions are not signed by this method because the witness may need
// something more aside from a single signature, so script transactions need to be
// manually signed using other methods.
let empty_witness = witnet_stack::encode(vec![]).unwrap();
let num_inputs = vtt.inputs.len();
let transaction = Transaction::ValueTransfer(VTTransaction {
body: vtt,
witness: vec![empty_witness; num_inputs],
});

Box::pin(fut)
Box::pin(actix::fut::result(Ok(transaction)))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/cli/node/json_rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ pub fn create_multisig_address(
]);

let locking_script_hash =
PublicKeyHash::from_script_bytes(&witnet_stack::encode(redeem_script));
PublicKeyHash::from_script_bytes(&witnet_stack::encode(redeem_script)?);

println!(
"Sending to {}-of-{} multisig address {} composed of {:?}",
Expand Down Expand Up @@ -778,7 +778,7 @@ pub fn create_opened_multisig(
Item::Value(MyValue::Integer(i128::from(n))),
Item::Operator(MyOperator::CheckMultiSig),
]);
let redeem_script_bytes = witnet_stack::encode(redeem_script);
let redeem_script_bytes = witnet_stack::encode(redeem_script)?;
let vt_outputs = vec![ValueTransferOutput {
pkh: address,
value,
Expand Down Expand Up @@ -854,13 +854,13 @@ pub fn sign_tx(addr: SocketAddr, hex: String, dry_run: bool) -> Result<(), failu
match tx {
Transaction::ValueTransfer(ref mut vtt) => {
let signature_bytes = signature.to_pb_bytes()?;
let mut script = witnet_stack::decode(&vtt.witness[0]);
let mut script = witnet_stack::decode(&vtt.witness[0])?;

println!("Previous script:\n{:?}", script);
script.push(Item::Value(MyValue::Signature(signature_bytes)));

println!("Post script:\n{:?}", script);
let encoded_script = witnet_stack::encode(script);
let encoded_script = witnet_stack::encode(script)?;

vtt.witness[0] = encoded_script;

Expand Down
Loading