Skip to content

Commit

Permalink
Minor fix for missing fee types
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Apr 25, 2022
1 parent 14420c8 commit b9009c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion policy_quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions policy_quote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b9009c7

Please sign in to comment.