From 98eec3243f827e08b1fc274bc6037ceb5e7f006b Mon Sep 17 00:00:00 2001 From: Thorianite <100335276+Thorian1te@users.noreply.github.com> Date: Fri, 20 Dec 2024 19:44:05 +0930 Subject: [PATCH] added fee bound check to ledger (#1323) --- .changeset/grumpy-dots-cheer.md | 5 +++++ packages/xchain-bitcoin/src/clientLedger.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/grumpy-dots-cheer.md diff --git a/.changeset/grumpy-dots-cheer.md b/.changeset/grumpy-dots-cheer.md new file mode 100644 index 000000000..0ca148247 --- /dev/null +++ b/.changeset/grumpy-dots-cheer.md @@ -0,0 +1,5 @@ +--- +'@xchainjs/xchain-bitcoin': minor +--- + +add feebound check to btc ledger client diff --git a/packages/xchain-bitcoin/src/clientLedger.ts b/packages/xchain-bitcoin/src/clientLedger.ts index 467cc4ce7..be2922153 100644 --- a/packages/xchain-bitcoin/src/clientLedger.ts +++ b/packages/xchain-bitcoin/src/clientLedger.ts @@ -1,6 +1,6 @@ import AppBtc from '@ledgerhq/hw-app-btc' import { Transaction } from '@ledgerhq/hw-app-btc/lib/types' -import { FeeOption, FeeRate, TxHash } from '@xchainjs/xchain-client' +import { FeeOption, FeeRate, TxHash, checkFeeBounds } from '@xchainjs/xchain-client' import { Address } from '@xchainjs/xchain-util' import { TxParams, UTXO, UtxoClientParams } from '@xchainjs/xchain-utxo' import * as Bitcoin from 'bitcoinjs-lib' @@ -54,6 +54,8 @@ class ClientLedger extends Client { const fromAddressIndex = params?.walletIndex || 0 // Get fee rate const feeRate = params.feeRate || (await this.getFeeRates())[FeeOption.Fast] + // Check if the fee rate is within the fee bounds + checkFeeBounds(this.feeBounds, feeRate) // Get sender address const sender = await this.getAddressAsync(fromAddressIndex) // Prepare transaction