Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Jan 15, 2025
1 parent c283cef commit 20c0088
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions internal/services/watch_btc_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,11 @@ func (s *Service) validateUnbondingTxOutput(
stakingValue := btcutil.Amount(stakingTx.TxOut[delegation.StakingOutputIdx].Value)

// Validate transaction sequence and locktime
if tx.TxIn[0].Sequence != wire.MaxTxInSequenceNum {
return false, nil
}
if tx.LockTime != 0 {
if tx.TxIn[0].Sequence != wire.MaxTxInSequenceNum || tx.LockTime != 0 {
log.Debug().
Str("staking_tx", delegation.StakingTxHashHex).
Str("spending_tx", tx.TxHash().String()).
Msg("unbonding tx has invalid sequence or locktime")
return false, nil
}

Expand Down Expand Up @@ -623,9 +624,17 @@ func (s *Service) validateUnbondingTxOutput(

// Validate output script and value
if !bytes.Equal(tx.TxOut[0].PkScript, unbondingInfo.UnbondingOutput.PkScript) {
log.Debug().
Str("staking_tx", delegation.StakingTxHashHex).
Str("spending_tx", tx.TxHash().String()).
Msg("unbonding tx output pk script does not match")
return false, nil
}
if tx.TxOut[0].Value != unbondingInfo.UnbondingOutput.Value {
log.Debug().
Str("staking_tx", delegation.StakingTxHashHex).
Str("spending_tx", tx.TxHash().String()).
Msg("unbonding tx output value does not match")
return false, nil
}

Expand All @@ -640,6 +649,10 @@ func (s *Service) validateUnbondingTxOutput(
}

if registeredUnbondingTx.TxHash().String() != tx.TxHash().String() {
log.Debug().
Str("staking_tx", delegation.StakingTxHashHex).
Str("spending_tx", tx.TxHash().String()).
Msg("unbonding tx hash does not match")
return false, nil
}

Expand Down

0 comments on commit 20c0088

Please sign in to comment.