Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ await wallet.listenForLivePayments()

## Fees

The wallet bills at **100 sat/KB** by default. wallet-toolbox's own default is `1 sat/KB`, which is below the policy ARC endpoints (TAAL, GorillaPool) currently enforce — transactions at that rate may never confirm. Set `feeModel: 'live'` to fetch the broadcaster's current policy from ARC `GET /v1/policy` at init instead of hardcoding (falls back to 100 if the fetch fails); a fixed `{ model: 'sat/kb', value }` is also accepted. The resolved rate is asserted on init, so a silently-skipped override throws rather than mis-pricing every transaction.
The wallet bills at **100 sat/KB** by default. wallet-toolbox's own default is `1 sat/KB`, which is below the policy ARC endpoints currently enforce — transactions at that rate may never confirm. Set `feeModel: 'live'` to fetch the broadcaster's current policy from ARC `GET /v1/policy` (default: GorillaPool ARC, `https://arc.gorillapool.io`, keyless; testnet falls back to TAAL's keyless testnet endpoint since GorillaPool has no testnet ARC) at init instead of hardcoding (falls back to 100 if the fetch fails); a fixed `{ model: 'sat/kb', value }` is also accepted. The resolved rate is asserted on init, so a silently-skipped override throws rather than mis-pricing every transaction.

## Broadcast routing

Expand Down
13 changes: 9 additions & 4 deletions src/BitcoinAgentWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export class BitcoinAgentWallet {
identityKey: this.identityKey,
identityKey2: this.identityKey,
filePath: dbFilePath,
taalApiKey: process.env.TAAL_API_KEY || '',
// Feltnavnet er wallet-toolbox sitt (SetupEnv krever det). Default er
// nøkkelfri — GorillaPool ARC trenger ingen API-nøkkel. Sett ARC_API_KEY
// kun hvis du peker mot et ARC-endepunkt som krever auth.
taalApiKey: process.env.ARC_API_KEY || '',
devKeys: { [this.identityKey]: this.config.privateKeyHex },
mySQLConnection: '',
}
Expand All @@ -95,13 +98,15 @@ export class BitcoinAgentWallet {
// subsequent createAction calls bill at peck-policy.
// Resolve the fee model. 'live' asks the broadcaster for its current policy
// (ARC /v1/policy) instead of guessing — correct against whatever the miner
// enforces now. Falls back to 100 sat/KB (today's TAAL/GorillaPool policy)
// enforces now. Falls back to 100 sat/KB (today's GorillaPool ARC policy)
// if the fetch fails, so init never blocks on a flaky policy call.
// Mainnet-default = GorillaPool ARC (nøkkelfri). GorillaPool har ingen
// testnet-ARC, så testnet beholder TAALs endepunkt som nøkkelløs fallback.
let desiredFeeModel: { model: 'sat/kb'; value: number }
if (this.config.feeModel === 'live') {
const arcUrl = this.config.services?.arcUrl
?? (this.network === 'main' ? 'https://arc.taal.com' : 'https://arc-test.taal.com')
const live = await fetchLivePolicyFee(arcUrl, process.env.TAAL_API_KEY)
?? (this.network === 'main' ? 'https://arc.gorillapool.io' : 'https://arc-test.taal.com')
const live = await fetchLivePolicyFee(arcUrl, process.env.ARC_API_KEY)
if (live) {
desiredFeeModel = live
console.error(`[agent-wallet] live fee policy ${live.value} sat/kb (from ${arcUrl}/v1/policy)`)
Expand Down
8 changes: 5 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface BitcoinAgentWalletConfig {
/** peck.to service-URL-er. Default peker på prod. */
services?: ServicesConfig
/** Fee-modellen wallet-toolbox bruker. Default { sat/kb, value: 100 } som
* matcher dagens TAAL/GorillaPool-policy (wallet-toolbox sin egen default er
* matcher dagens GorillaPool ARC-policy (wallet-toolbox sin egen default er
* value: 1 — for lavt for de fleste miner-policies). Sett til 'live' for å
* hente broadcasterens faktiske policy fra ARC `/v1/policy` ved init
* (faller tilbake til 100 hvis henting feiler). */
Expand All @@ -38,8 +38,10 @@ export interface ServicesConfig {
overlayUrl?: string // default: https://overlay.peck.to
headersUrl?: string // default: https://headers.peck.to
identityUrl?: string // default: https://identity.peck.to
/** ARC-URL brukt som broadcaster av wallet-toolbox. */
arcUrl?: string // default: https://arc.taal.com (main)
/** ARC-URL brukt som broadcaster av wallet-toolbox. Default (main):
* https://arc.gorillapool.io (nøkkelfri). Testnet: https://arc-test.taal.com
* som nøkkelløs fallback — GorillaPool har ingen testnet-ARC. */
arcUrl?: string
/** Redis broadcast-queue. Hvis satt, submitter async via broadcaster-worker i stedet for direkte til overlay. */
redisHost?: string
redisPort?: number
Expand Down
2 changes: 1 addition & 1 deletion test/feePolicy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parsePolicyFee } from '../src/feePolicy.js'

describe('parsePolicyFee', () => {
it('reads policy.miningFee into a sat/kb model (real ARC shape)', () => {
// arc.taal.com / arc.gorillapool.io /v1/policy, 2026-06-04
// arc.gorillapool.io /v1/policy, 2026-06-04 (samme respons-shape som TAALs ARC)
const data = { policy: { miningFee: { satoshis: 100, bytes: 1000 } } }
expect(parsePolicyFee(data)).toEqual({ model: 'sat/kb', value: 100 })
})
Expand Down
Loading