# Class BSV::Transaction::FeeModels::LivePolicy <a id="class-BSV-Transaction-FeeModels-LivePolicy"></a>

**Inherits:** `BSV::Transaction::FeeModel`

Dynamic fee model that fetches the live mining fee rate from an ARC policy
endpoint.

The fetched rate is cached for a configurable TTL (default 5 minutes) so
repeated calls to {#compute_fee} do not repeatedly query the API. If a fetch
fails, the model falls back to a configurable default rate.

**@example**
```ruby
model = BSV::Transaction::FeeModels::LivePolicy.new(
  arc_url: 'https://arc.taal.com',
  fallback_rate: 50
)
fee = model.compute_fee(transaction)
```

## Constants
### `DEFAULT_CACHE_TTL` <a id="constant-DEFAULT_CACHE_TTL"></a> <a id="DEFAULT_CACHE_TTL-constant"></a>
5 minutes in seconds

### `DEFAULT_FALLBACK_RATE` <a id="constant-DEFAULT_FALLBACK_RATE"></a> <a id="DEFAULT_FALLBACK_RATE-constant"></a>
Not documented.

### `TAAL_ARC_URL` <a id="constant-TAAL_ARC_URL"></a> <a id="TAAL_ARC_URL-constant"></a>
TAAL still runs a public ARC instance that serves /v1/policy. Full policy
access may require a TAAL API key.

## Attributes
### `arc_url` [R] <a id="attribute-i-arc_url"></a> <a id="arc_url-instance_method"></a>
- **@return** [String] the ARC base URL

### `cache_ttl` [R] <a id="attribute-i-cache_ttl"></a> <a id="cache_ttl-instance_method"></a>
- **@return** [Integer] cache TTL in seconds

### `fallback_rate` [R] <a id="attribute-i-fallback_rate"></a> <a id="fallback_rate-instance_method"></a>
- **@return** [Integer] fallback sat/kB when fetch fails

## Public Class Methods
### `default(api_key: = nil)` <a id="method-c-default"></a> <a id="default-class_method"></a>
Returns a LivePolicy using TAAL ARC for fee policy, 100 sat/kB fallback, and a
5-minute cache.
- **@param** `api_key` [String, nil] optional TAAL API key for authenticated policy access
- **@return** [LivePolicy]

## Public Instance Methods
### `compute_fee(transaction)` <a id="method-i-compute_fee"></a> <a id="compute_fee-instance_method"></a>
Compute the fee for a transaction using the latest ARC rate.
- **@param** `transaction` [Transaction::Tx] the transaction to compute the fee for
- **@return** [Integer] the fee in satoshis

### `current_rate()` <a id="method-i-current_rate"></a> <a id="current_rate-instance_method"></a>
Return the current sat/kB rate, fetching from ARC if the cache has expired.
- **@return** [Integer] satoshis per kilobyte

### `initialize(arc_url:, fallback_rate: = DEFAULT_FALLBACK_RATE, cache_ttl: = DEFAULT_CACHE_TTL, api_key: = nil, http_client: = nil)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
- **@param** `arc_url` [String] ARC base URL (e.g. 'https://arc.taal.com')
- **@param** `fallback_rate` [Integer] sat/kB to use when fetch fails (default: 100)
- **@param** `cache_ttl` [Integer] seconds to cache a fetched rate (default: 300)
- **@param** `api_key` [String, nil] optional Bearer token for ARC authentication
- **@param** `http_client` [#request, nil] injectable HTTP client for testing
- **@return** [LivePolicy] a new instance of LivePolicy
