@aibtc/mcp-server 1.72.1 → 1.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +4 -3
  2. package/dist/services/bitflow.service.d.ts +1 -1
  3. package/dist/services/bitflow.service.js +5 -17
  4. package/dist/services/btc-spend.d.ts +39 -0
  5. package/dist/services/btc-spend.js +99 -0
  6. package/dist/services/sbtc-deposit.service.d.ts +4 -1
  7. package/dist/services/sbtc-deposit.service.js +7 -4
  8. package/dist/services/sbtc.service.d.ts +2 -1
  9. package/dist/services/sbtc.service.js +7 -2
  10. package/dist/services/spend-limiter.d.ts +35 -3
  11. package/dist/services/spend-limiter.js +70 -9
  12. package/dist/services/tokens.service.js +9 -2
  13. package/dist/services/x402.service.js +5 -5
  14. package/dist/tools/bitcoin.tools.js +2 -6
  15. package/dist/tools/child-inscription.tools.js +3 -2
  16. package/dist/tools/contract.tools.js +18 -3
  17. package/dist/tools/dual-stacking.tools.js +3 -0
  18. package/dist/tools/inbox-x402.tools.js +1 -1
  19. package/dist/tools/jingswap.tools.js +10 -0
  20. package/dist/tools/legion.tools.js +4 -3
  21. package/dist/tools/lightning.tools.js +2 -1
  22. package/dist/tools/ordinals.tools.js +3 -2
  23. package/dist/tools/profiles.d.ts +5 -1
  24. package/dist/tools/profiles.js +5 -2
  25. package/dist/tools/psbt.tools.js +7 -0
  26. package/dist/tools/runes.tools.js +2 -1
  27. package/dist/tools/sbtc.tools.js +1 -1
  28. package/dist/tools/signing.tools.js +10 -0
  29. package/dist/tools/souldinals.tools.js +3 -2
  30. package/dist/tools/stacking-lottery.tools.js +8 -0
  31. package/dist/tools/stacks-market.tools.js +10 -0
  32. package/dist/tools/styx.tools.js +2 -1
  33. package/dist/transactions/builder.d.ts +17 -0
  34. package/dist/transactions/builder.js +26 -13
  35. package/dist/transactions/sponsor-builder.js +25 -4
  36. package/dist/utils/fee.d.ts +41 -2
  37. package/dist/utils/fee.js +15 -1
  38. package/package.json +1 -1
  39. package/skill/SKILL.md +2 -2
@@ -6,6 +6,44 @@
6
6
  * fee estimates from the Stacks mempool.
7
7
  */
8
8
  import type { Network } from "../config/networks.js";
9
+ /**
10
+ * Fee floor and ceiling clamps by transaction type (in micro-STX).
11
+ * Prevents absurd fees during mempool spikes while allowing reasonable variation.
12
+ *
13
+ * Ceilings are set conservatively:
14
+ * token_transfer: 3,000 uSTX (0.003 STX) — simple transfer
15
+ * contract_call: 50,000 uSTX (0.05 STX) — complex contract call
16
+ * smart_contract: 50,000 uSTX (0.05 STX) — deployment
17
+ * These match the x402-sponsor-relay reference implementation.
18
+ *
19
+ * sbtc_transfer is a plain sBTC `transfer` call. It is priced from Hiro's
20
+ * contract_call tier, whose medium estimate is skewed by heavy calls and sat
21
+ * at 2.5 STX, so every x402 sBTC payment paid the 0.05 STX ceiling. Mainnet
22
+ * sBTC transfers confirm at 500-3,000 uSTX.
23
+ */
24
+ declare const FEE_CLAMPS: {
25
+ readonly token_transfer: {
26
+ readonly floor: 180n;
27
+ readonly ceiling: 3000n;
28
+ };
29
+ readonly contract_call: {
30
+ readonly floor: 3000n;
31
+ readonly ceiling: 50000n;
32
+ };
33
+ readonly sbtc_transfer: {
34
+ readonly floor: 500n;
35
+ readonly ceiling: 3000n;
36
+ };
37
+ readonly smart_contract: {
38
+ readonly floor: 10000n;
39
+ readonly ceiling: 50000n;
40
+ };
41
+ readonly all: {
42
+ readonly floor: 180n;
43
+ readonly ceiling: 50000n;
44
+ };
45
+ };
46
+ type FeeTxType = keyof typeof FEE_CLAMPS;
9
47
  /**
10
48
  * Valid fee preset strings.
11
49
  * These map to the mempool fee priorities:
@@ -37,7 +75,7 @@ export declare function isFeePreset(value: string): value is FeePreset;
37
75
  * // Undefined - returns undefined (auto-estimate)
38
76
  * await resolveFee(undefined, "mainnet") // -> undefined
39
77
  */
40
- export declare function resolveFee(fee: string | undefined, network: Network, txType?: "all" | "token_transfer" | "contract_call" | "smart_contract"): Promise<bigint | undefined>;
78
+ export declare function resolveFee(fee: string | undefined, network: Network, txType?: FeeTxType): Promise<bigint | undefined>;
41
79
  /**
42
80
  * Resolve a default medium-priority fee for a given transaction type.
43
81
  *
@@ -52,5 +90,6 @@ export declare function resolveFee(fee: string | undefined, network: Network, tx
52
90
  * @param txType - The transaction type for ceiling/floor selection
53
91
  * @returns Fee in micro-STX as bigint
54
92
  */
55
- export declare function resolveDefaultFee(network: Network, txType?: "token_transfer" | "contract_call" | "smart_contract"): Promise<bigint>;
93
+ export declare function resolveDefaultFee(network: Network, txType?: Exclude<FeeTxType, "all">): Promise<bigint>;
94
+ export {};
56
95
  //# sourceMappingURL=fee.d.ts.map
package/dist/utils/fee.js CHANGED
@@ -15,13 +15,27 @@ import { getHiroApi } from "../services/hiro-api.js";
15
15
  * contract_call: 50,000 uSTX (0.05 STX) — complex contract call
16
16
  * smart_contract: 50,000 uSTX (0.05 STX) — deployment
17
17
  * These match the x402-sponsor-relay reference implementation.
18
+ *
19
+ * sbtc_transfer is a plain sBTC `transfer` call. It is priced from Hiro's
20
+ * contract_call tier, whose medium estimate is skewed by heavy calls and sat
21
+ * at 2.5 STX, so every x402 sBTC payment paid the 0.05 STX ceiling. Mainnet
22
+ * sBTC transfers confirm at 500-3,000 uSTX.
18
23
  */
19
24
  const FEE_CLAMPS = {
20
25
  token_transfer: { floor: 180n, ceiling: 3000n },
21
26
  contract_call: { floor: 3000n, ceiling: 50000n },
27
+ sbtc_transfer: { floor: 500n, ceiling: 3000n },
22
28
  smart_contract: { floor: 10000n, ceiling: 50000n },
23
29
  all: { floor: 180n, ceiling: 50000n }, // Widest range for aggregate fees
24
30
  };
31
+ /** Hiro mempool fee tier each clamp type is estimated from. */
32
+ const FEE_TIER = {
33
+ token_transfer: "token_transfer",
34
+ contract_call: "contract_call",
35
+ sbtc_transfer: "contract_call",
36
+ smart_contract: "smart_contract",
37
+ all: "all",
38
+ };
25
39
  /**
26
40
  * Check if a string is a valid fee preset.
27
41
  */
@@ -77,7 +91,7 @@ export async function resolveFee(fee, network, txType = "all") {
77
91
  const hiroApi = getHiroApi(network);
78
92
  try {
79
93
  const mempoolFees = await hiroApi.getMempoolFees();
80
- const feeTier = mempoolFees[txType];
94
+ const feeTier = mempoolFees[FEE_TIER[txType]];
81
95
  const priorityKey = presetToPriorityKey(fee);
82
96
  const rawFee = BigInt(Math.ceil(feeTier[priorityKey]));
83
97
  const clamps = FEE_CLAMPS[txType];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibtc/mcp-server",
3
- "version": "1.72.1",
3
+ "version": "1.73.1",
4
4
  "description": "Bitcoin-native MCP server for AI agents: BTC/STX wallets, DeFi yield, sBTC peg, NFTs, and x402 payments.",
5
5
  "mcpName": "io.github.aibtcdev/mcp-server",
6
6
  "type": "module",
package/skill/SKILL.md CHANGED
@@ -4,7 +4,7 @@ description: Bitcoin L1 wallet for agents - check balances, send BTC, manage UTX
4
4
  license: MIT
5
5
  metadata:
6
6
  author: aibtcdev
7
- version: 1.72.1 # x-release-please-version
7
+ version: 1.73.1 # x-release-please-version
8
8
  npm: "@aibtc/mcp-server"
9
9
  github: https://github.com/aibtcdev/aibtc-mcp-server
10
10
  ---
@@ -121,7 +121,7 @@ Wallets are stored encrypted at `~/.aibtc/`.
121
121
  | `btc_sign_message` | Sign plain text with Bitcoin key (BIP-137/BIP-322) | `message`, `addressType` (optional) |
122
122
  | `btc_verify_message` | Verify Bitcoin message signature (auto-detects BIP-137/BIP-322) | `message`, `signature`, `address` (optional) |
123
123
  | `nostr_sign_event` | Sign a Nostr event (NIP-01) with BIP-340 Schnorr using NIP-06 derived key by default (m/44'/1237'/0'/0/0) | `kind`, `content`, `tags` (optional), `created_at` (optional), `keySource` (`"nostr"` default via NIP-06 path, `"taproot"` for P2TR key, `"segwit"` for P2WPKH key) |
124
- | `schnorr_sign_digest` | Sign a raw 32-byte digest with Schnorr/BIP-340 | `digest`, `confirmBlindSign`, `auxRand` (optional) |
124
+ | `schnorr_sign_digest` | Sign a raw 32-byte digest with Schnorr/BIP-340 (off unless the user sets `AIBTC_ALLOW_BLIND_SIGN=true`) | `digest`, `confirmBlindSign`, `auxRand` (optional) |
125
125
  | `schnorr_verify_digest` | Verify a BIP-340 Schnorr signature over a digest | `digest`, `signature`, `publicKey` |
126
126
 
127
127
  ## Units and Addresses