They used the Barb's scuttling charge. It's a bomb kept on-board with the power of 55 pounds of TNT in case the ship needed to be sunk deliberately to prevent it from falling into enemy hands.
The crew of the USS Barb watching an entire freight train get yeeted 200 feet in the air after sneaking a bomb powerful enough to sink a battleship under a Japanese railway: