Skip to content

rfq: misc. fixedpoint unmarshalling hardening - #2398

Open
jtobin wants to merge 2 commits into
lightninglabs:mainfrom
jtobin:unmarshal-fixedpoint-harden
Open

jtobin wants to merge 2 commits into
lightninglabs:mainfrom
jtobin:unmarshal-fixedpoint-harden

Conversation

@jtobin

@jtobin jtobin commented Nov 25, 2026

Copy link
Copy Markdown
Member

Simply improves the UnmarshalFixedPoint handling, returning proper errors in bogus cases.

This matches the behaviour of UnmarshalPortfolioFixedPoint, and covers a
price oracle reply whose asset rates omit the subject asset rate.
UnmarshalFixedPoint now returns an error when the coefficient is not a
base-10 integer. This matches UnmarshalPortfolioFixedPoint.

cBigInt := new(big.Int)
cBigInt.SetString(fp.Coefficient, 10)
if _, ok := cBigInt.SetString(fp.Coefficient, 10); !ok {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both oracle quote handlers reject zero but accept negative rates. Require a positive rate in both handlers.

func TestUnmarshalFixedPointNil(t *testing.T) {
t.Parallel()

rate, err := UnmarshalFixedPoint(nil)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a mock oracle reply with SubjectAssetRate omitted. Assert that both buy and sell quote calls return an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

2 participants