feat(asset): add ARC-compatible /v1/policy endpoint#456
Open
freemans13 wants to merge 1 commit intobsv-blockchain:mainfrom
Open
feat(asset): add ARC-compatible /v1/policy endpoint#456freemans13 wants to merge 1 commit intobsv-blockchain:mainfrom
freemans13 wants to merge 1 commit intobsv-blockchain:mainfrom
Conversation
Contributor
|
🤖 Claude Code Review Status: Complete Issues Found1. Missing Unit TestsFile: The new handler lacks unit tests. All similar handlers in this codebase have corresponding test files (e.g., Required test coverage:
2. Potential Float-to-Uint Conversion IssueFile: satoshisPerKB := uint64(policy.MinMiningTxFee * 100_000_000)Problem: Direct conversion from
Suggested fix: Add validation before conversion: feeFloat := policy.MinMiningTxFee * 100_000_000
if feeFloat < 0 || feeFloat > float64(math.MaxUint64) {
return echo.NewHTTPError(http.StatusInternalServerError, "invalid fee configuration")
}
satoshisPerKB := uint64(feeFloat)Risk: Low (defaults are safe), but defensive coding is best practice. Positive Aspects
|
|
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
Adds an ARC-compatible
GET /v1/policyendpoint that returns the node's policy settings in the format specified by the ARC API.This enables clients using ARC-compatible APIs to query Teranode for its transaction acceptance policies.
Changes
services/asset/httpimpl/get_policy.go- Handler returning policy settingsservices/asset/httpimpl/http.go- Route registration for/v1/policyResponse Format
{ "timestamp": "2026-01-29T18:30:00.123456789Z", "policy": { "maxscriptsizepolicy": 500000, "maxtxsigopscountspolicy": 0, "maxtxsizepolicy": 10485760, "miningFee": { "satoshis": 500, "bytes": 1000 }, "standardFormatSupported": true } }Field Mapping
maxscriptsizepolicyPolicy.MaxScriptSizePolicymaxtxsigopscountspolicyPolicy.MaxTxSigopsCountsPolicymaxtxsizepolicyPolicy.MaxTxSizePolicyminingFee.satoshisPolicy.MinMiningTxFee * 1e8miningFee.bytesstandardFormatSupportedtrueTest Plan
make build-teranodecurl http://localhost:8090/v1/policymake test🤖 Generated with Claude Code