@arkade-os/swap 0.0.12 → 0.1.0-rc.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.
@@ -1,4 +1,4 @@
1
- import { VHTLC, IWallet, ProvisionedKey, ProvisionedClaimSecret, asset } from '@arkade-os/sdk';
1
+ import { VHTLC, IWallet, ProvisionedClaimSecret, ProvisionedKey, asset } from '@arkade-os/sdk';
2
2
 
3
3
  /** L1 confirmation-depth and reorg margin between dependent timelocks. */
4
4
  declare const ONCHAIN_ORDER_MARGIN_SECONDS: number;
@@ -259,6 +259,10 @@ type RfqRefusalReason = "unsupported_pair" | "unsupported_payload" | "amount_out
259
259
  declare const RFQ_TERMINAL_STATES: readonly ["settled", "refused", "expired", "refunded", "stuck"];
260
260
  /** A refusal from the solver, carrying its closed-set reason. */
261
261
  declare class SwapRefusal extends Error {
262
+ /** Literal-typed so the v2 error taxonomy's union discriminates on `name`
263
+ * — a `string` here collapses the discriminant for every member. Same value
264
+ * the constructor has always set, moved to a field initializer. */
265
+ readonly name = "SwapRefusal";
262
266
  readonly reason: string;
263
267
  readonly rfqId: string | undefined;
264
268
  constructor(reason: string, rfqId?: string);
@@ -305,7 +309,7 @@ interface RfqStatus {
305
309
  /** The rfq_request for the lightning send profile. A BOLT11 profile is always
306
310
  * exact-out: the invoice fixes the amount, so none is restated here.
307
311
  * `senderPubkey` is the trader's own key for the VHTLC's sender-side leaves
308
- * (see {@link lightningSendVtxoScript}) — required, never sent anywhere else,
312
+ * (see {@link lightningSendContract}) — required, never sent anywhere else,
309
313
  * never trusted by the solver as anything but a pubkey to bind into the
310
314
  * script. On the wire it's `client_refund_pubkey` (the payload schemas are
311
315
  * public at https://docs.arkadeos.com/intents/reference/rfq — the solver's schema
@@ -443,7 +447,7 @@ declare const SOLO_REFUND_HEADROOM_SECONDS: number;
443
447
  * exit delay exactly as the reference solver derives it — both sides read the
444
448
  * SAME server, so the derivation (not a quote field) is what keeps the two
445
449
  * scripts identical. */
446
- declare const unilateralClaimDelay: (serverExitDelaySeconds: number) => number;
450
+ declare const unilateralClaimDelay: (operatorExitDelaySeconds: number) => number;
447
451
  /** VHTLC's `unilateralRefund` tier: sender + receiver, no server — LEVEL with
448
452
  * `claimDelay`, not above it. Neither party can spend a two-signature leaf
449
453
  * alone, so separating it buys no safety, and every second spent separating it
@@ -471,13 +475,13 @@ declare const unilateralRefundWithoutReceiverDelay: (claimDelay: number) => numb
471
475
  * needing no participant at all). Nine leaves in all, unless `legacy` says
472
476
  * otherwise.
473
477
  */
474
- declare function lightningSendVtxoScript(params: {
478
+ declare function lightningSendContract(params: {
475
479
  /** Binding field #1: the solver's x-only key, from the quote. */
476
480
  solverPubkey: Uint8Array;
477
481
  /** Binding field #2: when the trader's refund path opens, from the quote. */
478
482
  refundLocktime: number;
479
483
  /** The Ark server's x-only key — the trader's OWN connection. */
480
- serverPubkey: Uint8Array;
484
+ operatorPubkey: Uint8Array;
481
485
  /** BOLT11 payment hash, hex — from the trader's OWN invoice decode. */
482
486
  paymentHash: string;
483
487
  /** From {@link unilateralClaimDelay} over the trader's OWN server info.
@@ -504,9 +508,9 @@ declare function lightningSendVtxoScript(params: {
504
508
  * the quote's own address says the solver quoted that shape. */
505
509
  legacy?: "preTimelockedRefund";
506
510
  }): InstanceType<typeof VHTLC.ScriptV2>;
507
- /** Every input {@link lightningSendVtxoScript} builds from. Derived from the
511
+ /** Every input {@link lightningSendContract} builds from. Derived from the
508
512
  * builder rather than restated, so the two cannot drift. */
509
- type LightningSendTreeParams = Parameters<typeof lightningSendVtxoScript>[0];
513
+ type LightningSendContractParams = Parameters<typeof lightningSendContract>[0];
510
514
  /** The BOLT11 facts the trader read from its OWN decode — this module takes
511
515
  * the facts, not the decoder, so any wallet's existing decoder serves. */
512
516
  interface InvoiceFacts {
@@ -540,14 +544,15 @@ interface InvoiceFacts {
540
544
  * throws while nothing is funded. `RfqSwapManager` re-registers as a backstop
541
545
  * for older records; a repeat write is a no-op.
542
546
  *
543
- * The `sender` key is the wallet's identity key, reused by {@link
544
- * provisionRefundKey} — returned as `senderPubkey` plus `secrets`. `secrets`
545
- * holds only a public descriptor; the signer re-derives from the wallet, so
546
- * nothing secret is at rest. Persist `secrets` with the record anyway: it is
547
- * how the refund signer is found again. `nonInteractiveRefund` recovers the funds even without it — but it needs the SOLVER's active
548
- * cooperation, not just infrastructure uptime.
547
+ * The `sender` key is the wallet's identity key, as {@link provisionRefundKey}
548
+ * pins it — returned as `senderPubkey` plus `secrets`. `secrets` holds only a
549
+ * public descriptor; the signer re-derives from the wallet, so nothing secret
550
+ * is at rest. Persist `secrets` with the record anyway: it is how the refund
551
+ * signer is found again. `nonInteractiveRefund` recovers the funds even
552
+ * without it — but it needs the SOLVER's active cooperation, not just
553
+ * infrastructure uptime.
549
554
  */
550
- declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
555
+ declare function requestLightningSend(wallet: IWallet, transport: RfqTransport, params: {
551
556
  invoice: InvoiceFacts;
552
557
  rfqId?: string;
553
558
  /** Co-signer key override (33-byte compressed hex); see
@@ -580,7 +585,7 @@ declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, tra
580
585
  *
581
586
  * Returned so a consumer can persist the swap without re-deriving any of
582
587
  * it. Half of these are not on the quote: `serverPubkey` and `claimDelay`
583
- * come from this wallet's own `getInfo()`, `emulatorPubkey` from a
588
+ * come from this wallet's own `getArkadeInfo()`, `emulatorPubkey` from a
584
589
  * per-network pin, `refundPkScript` from `secrets` — decoded from the
585
590
  * refund address at provisioning time, the same address this call returns
586
591
  * as `refundAddress`.
@@ -592,7 +597,7 @@ declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, tra
592
597
  * `VHTLCV2ContractHandler.serializeParams(script.options)`, the shape the
593
598
  * rebuild accepts.
594
599
  */
595
- treeParams: LightningSendTreeParams;
600
+ contractParams: LightningSendContractParams;
596
601
  }>;
597
602
  /**
598
603
  * Map an arkade↔arkade quote onto `createOffer` terms. The trader takes the
@@ -675,7 +680,7 @@ declare function deriveOnchainSend(input: {
675
680
  quote: RfqQuote;
676
681
  paymentHash: string;
677
682
  payoutPubkey: Uint8Array;
678
- serverPubkey: Uint8Array;
683
+ operatorPubkey: Uint8Array;
679
684
  emulatorPubkey: Uint8Array;
680
685
  claimDelay: number;
681
686
  hrp: string;
@@ -726,7 +731,7 @@ declare function deriveOnchainSend(input: {
726
731
  * `claimOnchainFill`) before `htlc.refundLocktime`. Missing that window
727
732
  * forfeits the fill and falls back to the Arkade covenant refund.
728
733
  */
729
- declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
734
+ declare function requestOnchainSend(wallet: IWallet, transport: RfqTransport, params: {
730
735
  amount: number;
731
736
  amountSide: "from" | "to";
732
737
  /** User's x-only L1 key that will claim the HTLC. */
@@ -774,6 +779,11 @@ declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, trans
774
779
  /** `profile.min_confirmations`; gates when the L1 fill becomes claimable,
775
780
  * and part of what a restored swap needs to drive its own claim. */
776
781
  minConfirmations: number;
782
+ /** The arkade lockup's refund deadline, as the covenant was built with it.
783
+ * Read this rather than `quote.refund_locktime`: that field is optional on
784
+ * the wire, a solver may carry the value in `profile` instead, and
785
+ * `deriveOnchainSend` is what settles which one this contract used. */
786
+ refundLocktime: number;
777
787
  /** The VHTLC `sender` x-only key, bound into the covenant. Public. */
778
788
  senderPubkey: Uint8Array;
779
789
  /** How the preimage and the `sender` key are recovered later — map it
@@ -840,12 +850,12 @@ declare const assertReceivable: (input: {
840
850
  maxPayAmount?: number;
841
851
  }) => void;
842
852
  /** Compile the RECEIVE-direction VHTLC: the same suite-carrying tree as {@link
843
- * lightningSendVtxoScript} with the roles inverted — the trader is the
853
+ * lightningSendContract} with the roles inverted — the trader is the
844
854
  * `receiver` (it generated `P` and claims the lockup with it), the solver is
845
855
  * the `sender` (it funds the lockup and holds the refund recourse). One
846
856
  * function shared by both receive corridors, mirroring the send legs' sharing
847
- * of `lightningSendVtxoScript`. */
848
- declare function receiveVtxoScript(params: {
857
+ * of `lightningSendContract`. */
858
+ declare function lightningReceiveContract(params: {
849
859
  /** Binding field #1: the solver's x-only key, from the quote — VHTLC's
850
860
  * `sender` role on the receive corridors. */
851
861
  solverPubkey: Uint8Array;
@@ -853,7 +863,7 @@ declare function receiveVtxoScript(params: {
853
863
  * the quote — after it the solver may reclaim an unclaimed lockup. */
854
864
  refundLocktime: number;
855
865
  /** The Ark server's x-only key — the trader's OWN connection. */
856
- serverPubkey: Uint8Array;
866
+ operatorPubkey: Uint8Array;
857
867
  /** `sha256(P)`, hex — the trader's OWN preimage hash. */
858
868
  paymentHash: string;
859
869
  /** From {@link unilateralClaimDelay} over the trader's OWN server info. */
@@ -873,9 +883,9 @@ declare function receiveVtxoScript(params: {
873
883
  /** LEGACY REBUILD ONLY — see {@link lightningSendVtxoScript}'s `legacy`. */
874
884
  legacy?: "preTimelockedRefund";
875
885
  }): InstanceType<typeof VHTLC.ScriptV2>;
876
- /** Every input {@link receiveVtxoScript} builds from; see
877
- * {@link LightningSendTreeParams}. */
878
- type LightningReceiveTreeParams = Parameters<typeof receiveVtxoScript>[0];
886
+ /** Every input {@link lightningReceiveContract} builds from; see
887
+ * {@link LightningSendContractParams}. */
888
+ type LightningReceiveContractParams = Parameters<typeof lightningReceiveContract>[0];
879
889
  /**
880
890
  * The pure core of {@link requestLightningReceive}: derive the solver-funded
881
891
  * covenant locally from the quote's binding fields plus the trader's own data
@@ -889,7 +899,7 @@ declare function deriveLightningReceive(input: {
889
899
  paymentHash: string;
890
900
  payoutPubkey: Uint8Array;
891
901
  payoutAddress: string;
892
- serverPubkey: Uint8Array;
902
+ operatorPubkey: Uint8Array;
893
903
  emulatorPubkey: Uint8Array;
894
904
  claimDelay: number;
895
905
  hrp: string;
@@ -902,7 +912,7 @@ declare function deriveLightningReceive(input: {
902
912
  refundLocktime: number;
903
913
  /** Every input the covenant was built from — see the same field on
904
914
  * `requestLightningSend`'s result for why a consumer needs them. */
905
- treeParams: LightningReceiveTreeParams;
915
+ contractParams: LightningReceiveContractParams;
906
916
  };
907
917
  /**
908
918
  * The `lightning:BTC->arkade:BTC` user flow: quote → derive the covenant
@@ -935,7 +945,7 @@ declare function deriveLightningReceive(input: {
935
945
  * Pay before `invoiceExpiresAt`: the hold-invoice window is minutes, not the
936
946
  * quote's `valid_until`.
937
947
  */
938
- declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
948
+ declare function requestLightningReceive(wallet: IWallet, transport: RfqTransport, params: {
939
949
  amount: number;
940
950
  amountSide: "from" | "to";
941
951
  /** Co-signer key override (33-byte compressed hex); see
@@ -980,7 +990,7 @@ declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string,
980
990
  secrets: ProvisionedClaimSecret;
981
991
  /** Every input the covenant was built from; see the same field on
982
992
  * `requestLightningSend`'s result. */
983
- treeParams: LightningReceiveTreeParams;
993
+ contractParams: LightningReceiveContractParams;
984
994
  }>;
985
995
  /**
986
996
  * The pure core of {@link requestOnchainReceive}: derive BOTH contracts
@@ -996,7 +1006,7 @@ declare function deriveOnchainReceive(input: {
996
1006
  payoutAddress: string;
997
1007
  /** The trader's own x-only L1 key — the HTLC's refund role. */
998
1008
  refundPubkey: Uint8Array;
999
- serverPubkey: Uint8Array;
1009
+ operatorPubkey: Uint8Array;
1000
1010
  emulatorPubkey: Uint8Array;
1001
1011
  claimDelay: number;
1002
1012
  hrp: string;
@@ -1024,7 +1034,7 @@ declare function deriveOnchainReceive(input: {
1024
1034
  * `refundPubkey`) opens at `htlc.refundLocktime` — `buildHtlcRefund` takes it
1025
1035
  * back from there.
1026
1036
  */
1027
- declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
1037
+ declare function requestOnchainReceive(wallet: IWallet, transport: RfqTransport, params: {
1028
1038
  amount: number;
1029
1039
  amountSide: "from" | "to";
1030
1040
  /** Co-signer key override (33-byte compressed hex); see
@@ -1057,4 +1067,4 @@ declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, tr
1057
1067
  secrets: ProvisionedClaimSecret;
1058
1068
  }>;
1059
1069
 
1060
- export { lightningSendRequest as $, ARKADE_ASSET as A, type RfqStatus as B, type ChainSource as C, SwapRefusal as D, arkadeAssetLeg as E, arkadeSwapRequest as F, assertFundable as G, type HtlcUtxo as H, type InvoiceFacts as I, assertReceivable as J, awaitOnchainFill as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, buildHtlcClaim as N, type OnchainNetwork as O, buildHtlcRefund as P, claimOnchainFill as Q, type RfqTransport as R, SOLO_REFUND_HEADROOM_SECONDS as S, classifyOnchainHtlc as T, deriveLightningReceive as U, deriveOnchainReceive as V, deriveOnchainSend as W, extractPreimage as X, httpTransport as Y, l1ScriptForAddress as Z, lightningReceiveRequest as _, type OnchainHtlc as a, lightningSendVtxoScript as a0, newPreimage as a1, newRfqId as a2, offerTermsFromQuote as a3, onchainHtlcScript as a4, onchainReceiveRequest as a5, onchainSendRequest as a6, paymentHashOf as a7, receiveVtxoScript as a8, relayTransport as a9, requestLightningReceive as aa, requestOnchainReceive as ab, rfqPair as ac, unilateralClaimDelay as ad, unilateralRefundDelay as ae, unilateralRefundWithoutReceiverDelay as af, verifyLockupAddress as ag, verifyReceiveInvoice as ah, type OnchainHtlcParams as b, requestLightningSend as c, ARKADE_BTC as d, AddressMismatch as e, type ChainUtxo as f, LIGHTNING_RECEIVE_PAIR as g, LIGHTNING_SEND_PAIR as h, LOCKTIME_THRESHOLD as i, type LightningReceiveTreeParams as j, type LightningSendTreeParams as k, MIN_CLAIM_WINDOW_SECONDS as l, MIN_HEADROOM_SECONDS as m, ONCHAIN_BTC as n, ONCHAIN_CLAIM_MARGIN_SECONDS as o, ONCHAIN_DUST_SATS as p, ONCHAIN_ORDER_MARGIN_SECONDS as q, requestOnchainSend as r, ONCHAIN_RECEIVE_PAIR as s, ONCHAIN_SECONDS_PER_BLOCK as t, ONCHAIN_SEND_PAIR as u, type OnchainHtlcPhase as v, RFQ_TERMINAL_STATES as w, type RelaySocket as x, type RfqQuote as y, type RfqRefusalReason as z };
1070
+ export { lightningReceiveContract as $, ARKADE_ASSET as A, type RfqRefusalReason as B, type ChainSource as C, type RfqStatus as D, SwapRefusal as E, arkadeAssetLeg as F, arkadeSwapRequest as G, type HtlcUtxo as H, type InvoiceFacts as I, assertFundable as J, assertReceivable as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, awaitOnchainFill as N, type OnchainNetwork as O, buildHtlcClaim as P, buildHtlcRefund as Q, type RfqTransport as R, SOLO_REFUND_HEADROOM_SECONDS as S, claimOnchainFill as T, classifyOnchainHtlc as U, deriveLightningReceive as V, deriveOnchainReceive as W, deriveOnchainSend as X, extractPreimage as Y, httpTransport as Z, l1ScriptForAddress as _, type OnchainHtlc as a, lightningReceiveRequest as a0, lightningSendContract as a1, lightningSendRequest as a2, newPreimage as a3, newRfqId as a4, offerTermsFromQuote as a5, onchainHtlcScript as a6, onchainReceiveRequest as a7, onchainSendRequest as a8, paymentHashOf as a9, relayTransport as aa, requestOnchainReceive as ab, rfqPair as ac, unilateralClaimDelay as ad, unilateralRefundDelay as ae, unilateralRefundWithoutReceiverDelay as af, verifyLockupAddress as ag, verifyReceiveInvoice as ah, type OnchainHtlcParams as b, requestLightningSend as c, requestLightningReceive as d, ARKADE_BTC as e, AddressMismatch as f, type ChainUtxo as g, LIGHTNING_RECEIVE_PAIR as h, LIGHTNING_SEND_PAIR as i, LOCKTIME_THRESHOLD as j, type LightningReceiveContractParams as k, type LightningSendContractParams as l, MIN_CLAIM_WINDOW_SECONDS as m, MIN_HEADROOM_SECONDS as n, ONCHAIN_BTC as o, ONCHAIN_CLAIM_MARGIN_SECONDS as p, ONCHAIN_DUST_SATS as q, requestOnchainSend as r, ONCHAIN_ORDER_MARGIN_SECONDS as s, ONCHAIN_RECEIVE_PAIR as t, ONCHAIN_SECONDS_PER_BLOCK as u, ONCHAIN_SEND_PAIR as v, type OnchainHtlcPhase as w, RFQ_TERMINAL_STATES as x, type RelaySocket as y, type RfqQuote as z };
@@ -1,4 +1,4 @@
1
- import { VHTLC, IWallet, ProvisionedKey, ProvisionedClaimSecret, asset } from '@arkade-os/sdk';
1
+ import { VHTLC, IWallet, ProvisionedClaimSecret, ProvisionedKey, asset } from '@arkade-os/sdk';
2
2
 
3
3
  /** L1 confirmation-depth and reorg margin between dependent timelocks. */
4
4
  declare const ONCHAIN_ORDER_MARGIN_SECONDS: number;
@@ -259,6 +259,10 @@ type RfqRefusalReason = "unsupported_pair" | "unsupported_payload" | "amount_out
259
259
  declare const RFQ_TERMINAL_STATES: readonly ["settled", "refused", "expired", "refunded", "stuck"];
260
260
  /** A refusal from the solver, carrying its closed-set reason. */
261
261
  declare class SwapRefusal extends Error {
262
+ /** Literal-typed so the v2 error taxonomy's union discriminates on `name`
263
+ * — a `string` here collapses the discriminant for every member. Same value
264
+ * the constructor has always set, moved to a field initializer. */
265
+ readonly name = "SwapRefusal";
262
266
  readonly reason: string;
263
267
  readonly rfqId: string | undefined;
264
268
  constructor(reason: string, rfqId?: string);
@@ -305,7 +309,7 @@ interface RfqStatus {
305
309
  /** The rfq_request for the lightning send profile. A BOLT11 profile is always
306
310
  * exact-out: the invoice fixes the amount, so none is restated here.
307
311
  * `senderPubkey` is the trader's own key for the VHTLC's sender-side leaves
308
- * (see {@link lightningSendVtxoScript}) — required, never sent anywhere else,
312
+ * (see {@link lightningSendContract}) — required, never sent anywhere else,
309
313
  * never trusted by the solver as anything but a pubkey to bind into the
310
314
  * script. On the wire it's `client_refund_pubkey` (the payload schemas are
311
315
  * public at https://docs.arkadeos.com/intents/reference/rfq — the solver's schema
@@ -443,7 +447,7 @@ declare const SOLO_REFUND_HEADROOM_SECONDS: number;
443
447
  * exit delay exactly as the reference solver derives it — both sides read the
444
448
  * SAME server, so the derivation (not a quote field) is what keeps the two
445
449
  * scripts identical. */
446
- declare const unilateralClaimDelay: (serverExitDelaySeconds: number) => number;
450
+ declare const unilateralClaimDelay: (operatorExitDelaySeconds: number) => number;
447
451
  /** VHTLC's `unilateralRefund` tier: sender + receiver, no server — LEVEL with
448
452
  * `claimDelay`, not above it. Neither party can spend a two-signature leaf
449
453
  * alone, so separating it buys no safety, and every second spent separating it
@@ -471,13 +475,13 @@ declare const unilateralRefundWithoutReceiverDelay: (claimDelay: number) => numb
471
475
  * needing no participant at all). Nine leaves in all, unless `legacy` says
472
476
  * otherwise.
473
477
  */
474
- declare function lightningSendVtxoScript(params: {
478
+ declare function lightningSendContract(params: {
475
479
  /** Binding field #1: the solver's x-only key, from the quote. */
476
480
  solverPubkey: Uint8Array;
477
481
  /** Binding field #2: when the trader's refund path opens, from the quote. */
478
482
  refundLocktime: number;
479
483
  /** The Ark server's x-only key — the trader's OWN connection. */
480
- serverPubkey: Uint8Array;
484
+ operatorPubkey: Uint8Array;
481
485
  /** BOLT11 payment hash, hex — from the trader's OWN invoice decode. */
482
486
  paymentHash: string;
483
487
  /** From {@link unilateralClaimDelay} over the trader's OWN server info.
@@ -504,9 +508,9 @@ declare function lightningSendVtxoScript(params: {
504
508
  * the quote's own address says the solver quoted that shape. */
505
509
  legacy?: "preTimelockedRefund";
506
510
  }): InstanceType<typeof VHTLC.ScriptV2>;
507
- /** Every input {@link lightningSendVtxoScript} builds from. Derived from the
511
+ /** Every input {@link lightningSendContract} builds from. Derived from the
508
512
  * builder rather than restated, so the two cannot drift. */
509
- type LightningSendTreeParams = Parameters<typeof lightningSendVtxoScript>[0];
513
+ type LightningSendContractParams = Parameters<typeof lightningSendContract>[0];
510
514
  /** The BOLT11 facts the trader read from its OWN decode — this module takes
511
515
  * the facts, not the decoder, so any wallet's existing decoder serves. */
512
516
  interface InvoiceFacts {
@@ -540,14 +544,15 @@ interface InvoiceFacts {
540
544
  * throws while nothing is funded. `RfqSwapManager` re-registers as a backstop
541
545
  * for older records; a repeat write is a no-op.
542
546
  *
543
- * The `sender` key is the wallet's identity key, reused by {@link
544
- * provisionRefundKey} — returned as `senderPubkey` plus `secrets`. `secrets`
545
- * holds only a public descriptor; the signer re-derives from the wallet, so
546
- * nothing secret is at rest. Persist `secrets` with the record anyway: it is
547
- * how the refund signer is found again. `nonInteractiveRefund` recovers the funds even without it — but it needs the SOLVER's active
548
- * cooperation, not just infrastructure uptime.
547
+ * The `sender` key is the wallet's identity key, as {@link provisionRefundKey}
548
+ * pins it — returned as `senderPubkey` plus `secrets`. `secrets` holds only a
549
+ * public descriptor; the signer re-derives from the wallet, so nothing secret
550
+ * is at rest. Persist `secrets` with the record anyway: it is how the refund
551
+ * signer is found again. `nonInteractiveRefund` recovers the funds even
552
+ * without it — but it needs the SOLVER's active cooperation, not just
553
+ * infrastructure uptime.
549
554
  */
550
- declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
555
+ declare function requestLightningSend(wallet: IWallet, transport: RfqTransport, params: {
551
556
  invoice: InvoiceFacts;
552
557
  rfqId?: string;
553
558
  /** Co-signer key override (33-byte compressed hex); see
@@ -580,7 +585,7 @@ declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, tra
580
585
  *
581
586
  * Returned so a consumer can persist the swap without re-deriving any of
582
587
  * it. Half of these are not on the quote: `serverPubkey` and `claimDelay`
583
- * come from this wallet's own `getInfo()`, `emulatorPubkey` from a
588
+ * come from this wallet's own `getArkadeInfo()`, `emulatorPubkey` from a
584
589
  * per-network pin, `refundPkScript` from `secrets` — decoded from the
585
590
  * refund address at provisioning time, the same address this call returns
586
591
  * as `refundAddress`.
@@ -592,7 +597,7 @@ declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, tra
592
597
  * `VHTLCV2ContractHandler.serializeParams(script.options)`, the shape the
593
598
  * rebuild accepts.
594
599
  */
595
- treeParams: LightningSendTreeParams;
600
+ contractParams: LightningSendContractParams;
596
601
  }>;
597
602
  /**
598
603
  * Map an arkade↔arkade quote onto `createOffer` terms. The trader takes the
@@ -675,7 +680,7 @@ declare function deriveOnchainSend(input: {
675
680
  quote: RfqQuote;
676
681
  paymentHash: string;
677
682
  payoutPubkey: Uint8Array;
678
- serverPubkey: Uint8Array;
683
+ operatorPubkey: Uint8Array;
679
684
  emulatorPubkey: Uint8Array;
680
685
  claimDelay: number;
681
686
  hrp: string;
@@ -726,7 +731,7 @@ declare function deriveOnchainSend(input: {
726
731
  * `claimOnchainFill`) before `htlc.refundLocktime`. Missing that window
727
732
  * forfeits the fill and falls back to the Arkade covenant refund.
728
733
  */
729
- declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
734
+ declare function requestOnchainSend(wallet: IWallet, transport: RfqTransport, params: {
730
735
  amount: number;
731
736
  amountSide: "from" | "to";
732
737
  /** User's x-only L1 key that will claim the HTLC. */
@@ -774,6 +779,11 @@ declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, trans
774
779
  /** `profile.min_confirmations`; gates when the L1 fill becomes claimable,
775
780
  * and part of what a restored swap needs to drive its own claim. */
776
781
  minConfirmations: number;
782
+ /** The arkade lockup's refund deadline, as the covenant was built with it.
783
+ * Read this rather than `quote.refund_locktime`: that field is optional on
784
+ * the wire, a solver may carry the value in `profile` instead, and
785
+ * `deriveOnchainSend` is what settles which one this contract used. */
786
+ refundLocktime: number;
777
787
  /** The VHTLC `sender` x-only key, bound into the covenant. Public. */
778
788
  senderPubkey: Uint8Array;
779
789
  /** How the preimage and the `sender` key are recovered later — map it
@@ -840,12 +850,12 @@ declare const assertReceivable: (input: {
840
850
  maxPayAmount?: number;
841
851
  }) => void;
842
852
  /** Compile the RECEIVE-direction VHTLC: the same suite-carrying tree as {@link
843
- * lightningSendVtxoScript} with the roles inverted — the trader is the
853
+ * lightningSendContract} with the roles inverted — the trader is the
844
854
  * `receiver` (it generated `P` and claims the lockup with it), the solver is
845
855
  * the `sender` (it funds the lockup and holds the refund recourse). One
846
856
  * function shared by both receive corridors, mirroring the send legs' sharing
847
- * of `lightningSendVtxoScript`. */
848
- declare function receiveVtxoScript(params: {
857
+ * of `lightningSendContract`. */
858
+ declare function lightningReceiveContract(params: {
849
859
  /** Binding field #1: the solver's x-only key, from the quote — VHTLC's
850
860
  * `sender` role on the receive corridors. */
851
861
  solverPubkey: Uint8Array;
@@ -853,7 +863,7 @@ declare function receiveVtxoScript(params: {
853
863
  * the quote — after it the solver may reclaim an unclaimed lockup. */
854
864
  refundLocktime: number;
855
865
  /** The Ark server's x-only key — the trader's OWN connection. */
856
- serverPubkey: Uint8Array;
866
+ operatorPubkey: Uint8Array;
857
867
  /** `sha256(P)`, hex — the trader's OWN preimage hash. */
858
868
  paymentHash: string;
859
869
  /** From {@link unilateralClaimDelay} over the trader's OWN server info. */
@@ -873,9 +883,9 @@ declare function receiveVtxoScript(params: {
873
883
  /** LEGACY REBUILD ONLY — see {@link lightningSendVtxoScript}'s `legacy`. */
874
884
  legacy?: "preTimelockedRefund";
875
885
  }): InstanceType<typeof VHTLC.ScriptV2>;
876
- /** Every input {@link receiveVtxoScript} builds from; see
877
- * {@link LightningSendTreeParams}. */
878
- type LightningReceiveTreeParams = Parameters<typeof receiveVtxoScript>[0];
886
+ /** Every input {@link lightningReceiveContract} builds from; see
887
+ * {@link LightningSendContractParams}. */
888
+ type LightningReceiveContractParams = Parameters<typeof lightningReceiveContract>[0];
879
889
  /**
880
890
  * The pure core of {@link requestLightningReceive}: derive the solver-funded
881
891
  * covenant locally from the quote's binding fields plus the trader's own data
@@ -889,7 +899,7 @@ declare function deriveLightningReceive(input: {
889
899
  paymentHash: string;
890
900
  payoutPubkey: Uint8Array;
891
901
  payoutAddress: string;
892
- serverPubkey: Uint8Array;
902
+ operatorPubkey: Uint8Array;
893
903
  emulatorPubkey: Uint8Array;
894
904
  claimDelay: number;
895
905
  hrp: string;
@@ -902,7 +912,7 @@ declare function deriveLightningReceive(input: {
902
912
  refundLocktime: number;
903
913
  /** Every input the covenant was built from — see the same field on
904
914
  * `requestLightningSend`'s result for why a consumer needs them. */
905
- treeParams: LightningReceiveTreeParams;
915
+ contractParams: LightningReceiveContractParams;
906
916
  };
907
917
  /**
908
918
  * The `lightning:BTC->arkade:BTC` user flow: quote → derive the covenant
@@ -935,7 +945,7 @@ declare function deriveLightningReceive(input: {
935
945
  * Pay before `invoiceExpiresAt`: the hold-invoice window is minutes, not the
936
946
  * quote's `valid_until`.
937
947
  */
938
- declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
948
+ declare function requestLightningReceive(wallet: IWallet, transport: RfqTransport, params: {
939
949
  amount: number;
940
950
  amountSide: "from" | "to";
941
951
  /** Co-signer key override (33-byte compressed hex); see
@@ -980,7 +990,7 @@ declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string,
980
990
  secrets: ProvisionedClaimSecret;
981
991
  /** Every input the covenant was built from; see the same field on
982
992
  * `requestLightningSend`'s result. */
983
- treeParams: LightningReceiveTreeParams;
993
+ contractParams: LightningReceiveContractParams;
984
994
  }>;
985
995
  /**
986
996
  * The pure core of {@link requestOnchainReceive}: derive BOTH contracts
@@ -996,7 +1006,7 @@ declare function deriveOnchainReceive(input: {
996
1006
  payoutAddress: string;
997
1007
  /** The trader's own x-only L1 key — the HTLC's refund role. */
998
1008
  refundPubkey: Uint8Array;
999
- serverPubkey: Uint8Array;
1009
+ operatorPubkey: Uint8Array;
1000
1010
  emulatorPubkey: Uint8Array;
1001
1011
  claimDelay: number;
1002
1012
  hrp: string;
@@ -1024,7 +1034,7 @@ declare function deriveOnchainReceive(input: {
1024
1034
  * `refundPubkey`) opens at `htlc.refundLocktime` — `buildHtlcRefund` takes it
1025
1035
  * back from there.
1026
1036
  */
1027
- declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
1037
+ declare function requestOnchainReceive(wallet: IWallet, transport: RfqTransport, params: {
1028
1038
  amount: number;
1029
1039
  amountSide: "from" | "to";
1030
1040
  /** Co-signer key override (33-byte compressed hex); see
@@ -1057,4 +1067,4 @@ declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, tr
1057
1067
  secrets: ProvisionedClaimSecret;
1058
1068
  }>;
1059
1069
 
1060
- export { lightningSendRequest as $, ARKADE_ASSET as A, type RfqStatus as B, type ChainSource as C, SwapRefusal as D, arkadeAssetLeg as E, arkadeSwapRequest as F, assertFundable as G, type HtlcUtxo as H, type InvoiceFacts as I, assertReceivable as J, awaitOnchainFill as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, buildHtlcClaim as N, type OnchainNetwork as O, buildHtlcRefund as P, claimOnchainFill as Q, type RfqTransport as R, SOLO_REFUND_HEADROOM_SECONDS as S, classifyOnchainHtlc as T, deriveLightningReceive as U, deriveOnchainReceive as V, deriveOnchainSend as W, extractPreimage as X, httpTransport as Y, l1ScriptForAddress as Z, lightningReceiveRequest as _, type OnchainHtlc as a, lightningSendVtxoScript as a0, newPreimage as a1, newRfqId as a2, offerTermsFromQuote as a3, onchainHtlcScript as a4, onchainReceiveRequest as a5, onchainSendRequest as a6, paymentHashOf as a7, receiveVtxoScript as a8, relayTransport as a9, requestLightningReceive as aa, requestOnchainReceive as ab, rfqPair as ac, unilateralClaimDelay as ad, unilateralRefundDelay as ae, unilateralRefundWithoutReceiverDelay as af, verifyLockupAddress as ag, verifyReceiveInvoice as ah, type OnchainHtlcParams as b, requestLightningSend as c, ARKADE_BTC as d, AddressMismatch as e, type ChainUtxo as f, LIGHTNING_RECEIVE_PAIR as g, LIGHTNING_SEND_PAIR as h, LOCKTIME_THRESHOLD as i, type LightningReceiveTreeParams as j, type LightningSendTreeParams as k, MIN_CLAIM_WINDOW_SECONDS as l, MIN_HEADROOM_SECONDS as m, ONCHAIN_BTC as n, ONCHAIN_CLAIM_MARGIN_SECONDS as o, ONCHAIN_DUST_SATS as p, ONCHAIN_ORDER_MARGIN_SECONDS as q, requestOnchainSend as r, ONCHAIN_RECEIVE_PAIR as s, ONCHAIN_SECONDS_PER_BLOCK as t, ONCHAIN_SEND_PAIR as u, type OnchainHtlcPhase as v, RFQ_TERMINAL_STATES as w, type RelaySocket as x, type RfqQuote as y, type RfqRefusalReason as z };
1070
+ export { lightningReceiveContract as $, ARKADE_ASSET as A, type RfqRefusalReason as B, type ChainSource as C, type RfqStatus as D, SwapRefusal as E, arkadeAssetLeg as F, arkadeSwapRequest as G, type HtlcUtxo as H, type InvoiceFacts as I, assertFundable as J, assertReceivable as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, awaitOnchainFill as N, type OnchainNetwork as O, buildHtlcClaim as P, buildHtlcRefund as Q, type RfqTransport as R, SOLO_REFUND_HEADROOM_SECONDS as S, claimOnchainFill as T, classifyOnchainHtlc as U, deriveLightningReceive as V, deriveOnchainReceive as W, deriveOnchainSend as X, extractPreimage as Y, httpTransport as Z, l1ScriptForAddress as _, type OnchainHtlc as a, lightningReceiveRequest as a0, lightningSendContract as a1, lightningSendRequest as a2, newPreimage as a3, newRfqId as a4, offerTermsFromQuote as a5, onchainHtlcScript as a6, onchainReceiveRequest as a7, onchainSendRequest as a8, paymentHashOf as a9, relayTransport as aa, requestOnchainReceive as ab, rfqPair as ac, unilateralClaimDelay as ad, unilateralRefundDelay as ae, unilateralRefundWithoutReceiverDelay as af, verifyLockupAddress as ag, verifyReceiveInvoice as ah, type OnchainHtlcParams as b, requestLightningSend as c, requestLightningReceive as d, ARKADE_BTC as e, AddressMismatch as f, type ChainUtxo as g, LIGHTNING_RECEIVE_PAIR as h, LIGHTNING_SEND_PAIR as i, LOCKTIME_THRESHOLD as j, type LightningReceiveContractParams as k, type LightningSendContractParams as l, MIN_CLAIM_WINDOW_SECONDS as m, MIN_HEADROOM_SECONDS as n, ONCHAIN_BTC as o, ONCHAIN_CLAIM_MARGIN_SECONDS as p, ONCHAIN_DUST_SATS as q, requestOnchainSend as r, ONCHAIN_ORDER_MARGIN_SECONDS as s, ONCHAIN_RECEIVE_PAIR as t, ONCHAIN_SECONDS_PER_BLOCK as u, ONCHAIN_SEND_PAIR as v, type OnchainHtlcPhase as w, RFQ_TERMINAL_STATES as x, type RelaySocket as y, type RfqQuote as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/swap",
3
- "version": "0.0.12",
3
+ "version": "0.1.0-rc.1",
4
4
  "type": "module",
5
5
  "description": "Client-side Arkade Intents asset swaps: discover markets, quote, create/track/cancel offers, restore from chain.",
6
6
  "repository": {
@@ -31,6 +31,16 @@
31
31
  "default": "./dist/nostr.cjs"
32
32
  }
33
33
  },
34
+ "./node": {
35
+ "import": {
36
+ "types": "./dist/node/index.d.ts",
37
+ "default": "./dist/node/index.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/node/index.d.ts",
41
+ "default": "./dist/node/index.cjs"
42
+ }
43
+ },
34
44
  "./repositories/sqlite": {
35
45
  "import": {
36
46
  "types": "./dist/repositories/sqlite/index.d.ts",
@@ -55,6 +65,9 @@
55
65
  "files": [
56
66
  "dist"
57
67
  ],
68
+ "engines": {
69
+ "node": ">=22.12.0"
70
+ },
58
71
  "keywords": [
59
72
  "arkade",
60
73
  "swap",
@@ -70,7 +83,8 @@
70
83
  "@noble/hashes": "2.0.1",
71
84
  "@scure/base": "2.0.0",
72
85
  "@scure/btc-signer": "2.0.1",
73
- "@arkade-os/sdk": "0.4.69"
86
+ "light-bolt11-decoder": "3.2.0",
87
+ "@arkade-os/sdk": "0.5.0-rc.1"
74
88
  },
75
89
  "peerDependencies": {
76
90
  "nostr-tools": "^2.12.0"
@@ -89,14 +103,16 @@
89
103
  "nostr-tools": "^2.12.0"
90
104
  },
91
105
  "scripts": {
92
- "build": "tsup src/index.ts src/nostr.ts src/repositories/sqlite/index.ts src/repositories/realm/index.ts --format esm,cjs --dts --clean",
93
- "typecheck": "tsc --noEmit",
106
+ "build": "pnpm run build:web && pnpm run build:node",
107
+ "build:web": "tsup src/index.ts src/nostr.ts src/repositories/sqlite/index.ts src/repositories/realm/index.ts --format esm,cjs --dts --clean",
108
+ "build:node": "tsup --config tsup.node.config.ts",
109
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
94
110
  "format": "biome format --write src test",
95
111
  "lint": "biome format src test",
96
112
  "test": "vitest run --exclude test/e2e",
97
113
  "test:unit": "vitest run --exclude test/e2e",
98
- "test:integration": "vitest run test/e2e/** --exclude test/e2e/rfq*.test.ts",
99
- "test:integration:rfq": "vitest run test/e2e/rfq*.test.ts",
114
+ "test:integration": "vitest run test/e2e --exclude 'test/e2e/rfq*.test.ts'",
115
+ "test:integration:rfq": "vitest run test/e2e/rfq",
100
116
  "smoke:dist": "node scripts/smoke-dist.mjs"
101
117
  }
102
118
  }