Skip to content

Commit

Permalink
Transfer transaction fails if masp transparent inputs are not debited
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Jul 19, 2024
1 parent dab10a6 commit fc63450
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions wasm/tx_transfer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ fn apply_tx(ctx: &mut Ctx, tx_data: BatchedTx) -> TxResult {
ctx.push_action(Action::Masp(MaspAction::MaspSectionRef(
masp_section_ref,
)))?;
let vins_addresses = shielded.transparent_bundle().map_or_else(
// Extract the debited accounts for the masp part of the transfer and
// push the relative actions
let vin_addresses = shielded.transparent_bundle().map_or_else(
Default::default,
|bndl| {
bndl.vin
Expand All @@ -67,9 +69,18 @@ fn apply_tx(ctx: &mut Ctx, tx_data: BatchedTx) -> TxResult {
.collect::<BTreeSet<_>>()
},
);
let masp_authorizers = debited_accounts.into_iter().filter(|account| {
vins_addresses.contains(&addr_taddr(account.clone()))
});
let masp_authorizers: Vec<_> = debited_accounts
.into_iter()
.filter(|account| {
vin_addresses.contains(&addr_taddr(account.clone()))
})
.collect();
if masp_authorizers.len() != vin_addresses.len() {
return Err(Error::SimpleMessage(
"Transfer transaction does not debit all the expected accounts",
));
}

for authorizer in masp_authorizers {
ctx.push_action(Action::Masp(MaspAction::MaspAuthorizer(
authorizer,
Expand Down

0 comments on commit fc63450

Please sign in to comment.