Based on what I've read, he knew part of the law. That was the same part many gun owners know: minimum length for a shotgun barrel under federal law is 18 inches. So, when the government informant showed Weaver where he wanted the shotgun barrel cut, Weaver measured how much barrel would be left (more than 18 inches), figured it was OK, and made the cut.
What Weaver apparently didn't know (and many gun owners do not know) is that there is also a minimum overall length for shotguns, of 26 inches (again, federal law). When Weaver shortened the barrel to the requested length, he unintentionally violated the law related to overall length, not the barrel length requirement...
That's my understanding of the events, FWIW, "I'm not a lawyer", CYA, YMMV, etc...
I had heard that also but cannot find any reference to it now.
Bottom line is Randy was acquitted on that charge.