From b9009c7521939c0e4b26ba782e8318c0b7c48938 Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Mon, 25 Apr 2022 15:57:08 -0400 Subject: [PATCH] Minor fix for missing fee types --- policy_quote.go | 10 +++++++++- policy_quote_test.go | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/policy_quote.go b/policy_quote.go index 2b9a426..91433ce 100644 --- a/policy_quote.go +++ b/policy_quote.go @@ -173,7 +173,15 @@ func (i *internalResult) parsePolicyQuote() (response PolicyQuoteResponse, err e // If we have a valid payload if len(response.Payload) > 0 { - err = json.Unmarshal([]byte(response.Payload), &response.Quote) + if err = json.Unmarshal([]byte(response.Payload), &response.Quote); err != nil { + return + } + if response.Quote != nil && + len(response.Quote.Fees) > 0 && + len(response.Quote.Fees[0].FeeType) == 0 { // This is an issue because go-bt json field is stripping the types + response.Quote.Fees[0].FeeType = FeeTypeStandard + response.Quote.Fees[1].FeeType = FeeTypeData + } } return } diff --git a/policy_quote_test.go b/policy_quote_test.go index 0240d32..3072f29 100644 --- a/policy_quote_test.go +++ b/policy_quote_test.go @@ -79,6 +79,9 @@ func TestClient_PolicyQuote(t *testing.T) { assert.Equal(t, uint32(99999), response.Quote.Policies.MaxTxSizePolicy) assert.Equal(t, uint64(10000000), response.Quote.Policies.MaxStackMemoryUsagePolicy) assert.Equal(t, flags, response.Quote.Policies.SkipScriptFlags) + + assert.Equal(t, 500, response.Quote.FeePayload.GetFee(FeeTypeStandard).MiningFee.Satoshis) + assert.Equal(t, 1000, response.Quote.FeePayload.GetFee(FeeTypeStandard).MiningFee.Bytes) }) t.Run("invalid miner", func(t *testing.T) {