fix(publish): enforce the AllowMainnet gate in BuildPSBT (#109)#110
Merged
Conversation
Finding #23. Submit refuses mainnet without AllowMainnet, but BuildPSBT — the external/hardware-signer flow — had no such gate, so on mainnet it pinned DID files to public IPFS and funded a real-BTC spend with no check firing (the out-of-band signer then completes it). Add the same Params.Name==MainNetParams.Name && !AllowMainnet gate to BuildPSBT, checked BEFORE the IPFS pin. Test: TestBuildPSBTMainnetGuard (refused without AllowMainnet; builds with it). Mutation-verified. go test -race ./... green. Co-authored-by: Liran Cohen <liranlasvegas@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes audit finding #23.
Writer.Submitrefuses mainnet withoutAllowMainnet(writer.go:81), butBuildPSBT— the external/hardware-signer flow, the PSBT feature's whole reason to exist — had no such gate. So on mainnet it pinned DID files to public IPFS and funded a real-BTC-spending tx with no ion-node mainnet check firing; the out-of-band signer then completes the spend.Fix
Add the same
Params.Name == MainNetParams.Name && !AllowMainnetgate toBuildPSBT, checked before the IPFS pin.TestBuildPSBTMainnetGuard— refused withoutAllowMainnet, builds with it; mutation-verified.go test -race ./...green (26 packages).Post-Deploy Monitoring & Validation
No additional operational monitoring required: tightens a money-path guard to matchSubmit. Operators using the PSBT flow on mainnet must now pass--allow-mainnet(same asSubmit).Closes #109
🤖 Generated with Claude Code