It is adultery that manifests itself in masterbation. That is the result of lustfull desires. It could not be more clear. Matt 18 is the same.1st, The context of Matt 5:30 begins in verse 27. It's adultery not masturbation!
2ndly, Unless you're masturbating to an audience. The following scripture say's: NO prosecutable sin has been committed.
Deuteronomy 19:15 One witness shall not rise up against a man for any iniquity, or for any sin, in any sin that he sinneth: at the mouth of two witnesses, or at the mouth of three witnesses, shall the matter be established.
Other supporting verses:
Matthew 18:16, 2 Corinthians 13:1, John 8:17, 1 Timothy 5:19, Hebrews 10:28, Numbers 35:30
Jesus has a message he is trying to say here. We are all dead in oor sins. If lust does not get you anger will or greed. None of us can escape. Finally Jesus says to be justified you must be perfect as God is perfect. Who can do that?
We can’t, only with Jesus’ righteousness can we be saved.