@inversealtruism/cairnx-core 0.1.37 → 0.1.38

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.
package/dist/index.cjs CHANGED
@@ -108,6 +108,8 @@ __export(index_exports, {
108
108
  V28_HEIGHT: () => V28_HEIGHT,
109
109
  ZERO_ADDR: () => ZERO_ADDR,
110
110
  bid: () => bid,
111
+ bindOfferTerms: () => bindOfferTerms,
112
+ bindProvenOffer: () => bindProvenOffer,
111
113
  blockReward: () => import_csd_codec5.blockReward,
112
114
  buildFeeHeight: () => buildFeeHeight,
113
115
  buildRecord: () => buildRecord,
@@ -122,6 +124,7 @@ __export(index_exports, {
122
124
  fclaim: () => fclaim,
123
125
  fclaimEpochFor: () => fclaimEpochFor,
124
126
  fclaimHoldEnd: () => fclaimHoldEnd,
127
+ feeBpsAt: () => feeBpsAt,
125
128
  fillIsSafe: () => fillIsSafe,
126
129
  fillTargetId: () => fillTargetId,
127
130
  finalizeWinnerCheck: () => finalizeWinnerCheck,
@@ -151,6 +154,7 @@ __export(index_exports, {
151
154
  pickPrimaryName: () => pickPrimaryName,
152
155
  previewFill: () => previewFill,
153
156
  primaryRankBefore: () => primaryRankBefore,
157
+ provenOfferTerms: () => provenOfferTerms,
154
158
  replayLiveHold: () => replayLiveHold,
155
159
  requiredClaimDepth: () => requiredClaimDepth,
156
160
  requiredFillOutputs: () => requiredFillOutputs,
@@ -195,7 +199,7 @@ var CLAIM_FILL_GRACE_BLOCKS = 5;
195
199
  var MAX_ACTIVE_CLAIMS = 3;
196
200
  var CLAIM_COOLDOWN_BLOCKS = 15;
197
201
  var FCLAIM_MAX_EPOCH_AHEAD = 2;
198
- var FILL_TIP_MARGIN = 2;
202
+ var FILL_TIP_MARGIN = 4;
199
203
  var CONF_TOKEN_FILL = 1e6;
200
204
  var TREASURY_ADDR = "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016";
201
205
  var FEE_BPS = 100;
@@ -1735,6 +1739,39 @@ async function verifyFillSpv(offerId, fclaimTxid, me, io, opts) {
1735
1739
  if (holdEnd < tip + FILL_TIP_MARGIN) return no(`too close to the hold deadline (holdEnd ${holdEnd}, tip ${tip}) - would strand`);
1736
1740
  return { safe: true, reason: "ok" };
1737
1741
  }
1742
+ var feeBpsAt = (height) => height >= V11_HEIGHT ? height >= V16_HEIGHT ? FEE_BPS_V16 : FEE_BPS : 0;
1743
+ function provenOfferTerms(offerRec, provenHeight) {
1744
+ const w = offerRec.want;
1745
+ return {
1746
+ height: Number(provenHeight),
1747
+ feeBps: feeBpsAt(Number(provenHeight)),
1748
+ value: w.value !== void 0 ? String(w.value) : void 0,
1749
+ taker: offerRec.taker !== void 0 ? String(offerRec.taker).toLowerCase() : void 0,
1750
+ bid: offerRec.bid !== void 0 ? String(offerRec.bid).toLowerCase() : void 0,
1751
+ min: offerRec.min !== void 0 ? String(offerRec.min) : void 0
1752
+ };
1753
+ }
1754
+ function bindOfferTerms(servedOffer, t) {
1755
+ const o = servedOffer;
1756
+ const s = (v) => v === void 0 || v === null ? "" : String(v).toLowerCase();
1757
+ if (Number(o?.height) !== t.height) return true;
1758
+ if (Number(o?.feeBps) !== t.feeBps) return true;
1759
+ if (t.value !== void 0 && String(o?.want?.value) !== t.value) return true;
1760
+ if (s(o?.taker) !== s(t.taker)) return true;
1761
+ if (s(o?.bid) !== s(t.bid)) return true;
1762
+ const om = o?.min;
1763
+ if ((om !== void 0 && om !== null) !== (t.min !== void 0)) return true;
1764
+ if (t.min !== void 0 && String(om) !== t.min) return true;
1765
+ return false;
1766
+ }
1767
+ function bindProvenOffer(offerEv) {
1768
+ const rec = bindRecord(offerEv);
1769
+ if (!rec || rec.t !== "offer") return null;
1770
+ const seller = String(offerEv.proposer).toLowerCase();
1771
+ const w = rec.want;
1772
+ const payto = w.payto && ADDR_RE.test(String(w.payto).toLowerCase()) ? String(w.payto).toLowerCase() : seller;
1773
+ return { payto, seller, terms: provenOfferTerms(rec, offerEv.height) };
1774
+ }
1738
1775
 
1739
1776
  // src/paidto.ts
1740
1777
  function paidToFromOutputs(outputs) {
@@ -1838,6 +1875,8 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
1838
1875
  V28_HEIGHT,
1839
1876
  ZERO_ADDR,
1840
1877
  bid,
1878
+ bindOfferTerms,
1879
+ bindProvenOffer,
1841
1880
  blockReward,
1842
1881
  buildFeeHeight,
1843
1882
  buildRecord,
@@ -1852,6 +1891,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
1852
1891
  fclaim,
1853
1892
  fclaimEpochFor,
1854
1893
  fclaimHoldEnd,
1894
+ feeBpsAt,
1855
1895
  fillIsSafe,
1856
1896
  fillTargetId,
1857
1897
  finalizeWinnerCheck,
@@ -1881,6 +1921,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
1881
1921
  pickPrimaryName,
1882
1922
  previewFill,
1883
1923
  primaryRankBefore,
1924
+ provenOfferTerms,
1884
1925
  replayLiveHold,
1885
1926
  requiredClaimDepth,
1886
1927
  requiredFillOutputs,
package/dist/index.d.cts CHANGED
@@ -28,7 +28,7 @@ declare const CLAIM_FILL_GRACE_BLOCKS = 5;
28
28
  declare const MAX_ACTIVE_CLAIMS = 3;
29
29
  declare const CLAIM_COOLDOWN_BLOCKS = 15;
30
30
  declare const FCLAIM_MAX_EPOCH_AHEAD = 2;
31
- declare const FILL_TIP_MARGIN = 2;
31
+ declare const FILL_TIP_MARGIN = 4;
32
32
  declare const CONF_TOKEN_FILL = 1000000;
33
33
  declare const TREASURY_ADDR = "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016";
34
34
  declare const FEE_BPS = 100;
@@ -604,10 +604,41 @@ declare function verifyFillSpv(offerId: string, fclaimTxid: string, me: string,
604
604
  myLiveHoldsAtGrant: number;
605
605
  pay?: bigint | string | number;
606
606
  }): Promise<FillVerdict>;
607
+ interface ProvenOfferTerms {
608
+ height: number;
609
+ feeBps: number;
610
+ value?: string;
611
+ taker?: string;
612
+ bid?: string;
613
+ min?: string;
614
+ }
615
+ declare const feeBpsAt: (height: number) => number;
616
+ declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number): ProvenOfferTerms;
617
+ /**
618
+ * The fill-boundary TERM-MISMATCH verdict: `true` iff any fee/rebate/partial-sizing field of the resolver-
619
+ * SERVED offer diverges from the merkle-proven terms `t`. FAIL-CLOSED semantics (any divergence => true =>
620
+ * the caller refuses). Byte-identical in behaviour to the wallet's old provenTermsMismatch and the site's
621
+ * old inline amount-leg bind (they were reconciled to be one predicate here):
622
+ * - height (offer.height vs t.height)
623
+ * - feeBps (offer.feeBps vs t.feeBps = feeBpsAt(creation height))
624
+ * - value (offer.want.value vs t.value, only when the proven offer is CSD-priced)
625
+ * - taker (offer.taker vs t.taker, case-insensitive, undefined/null == "")
626
+ * - bid (offer.bid vs t.bid, same normalization)
627
+ * - min presence AND value: an ADDED spurious min (whole->partial rebate-drop burn) OR a deflated min
628
+ * both mismatch. EXPLICIT presence (a served min="" must not slip past a proven-absent min).
629
+ * `value` is bound only when `t.value` is defined so a token<->token offer (no CSD value) is not spuriously
630
+ * refused; a caller that binds want.value separately (the site does) may still pass it here (redundant-safe).
631
+ */
632
+ declare function bindOfferTerms(servedOffer: unknown, t: ProvenOfferTerms): boolean;
633
+ declare function bindProvenOffer(offerEv: ProvenPropose): {
634
+ payto: string;
635
+ seller: string;
636
+ terms: ProvenOfferTerms;
637
+ } | null;
607
638
 
608
639
  declare function paidToFromOutputs(outputs: readonly {
609
640
  addr: string;
610
641
  value: number;
611
642
  }[]): Record<string, string>;
612
643
 
613
- export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEntry, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, type Want, ZERO_ADDR, bid, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, fillIsSafe, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, verifyFillSpv };
644
+ export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEntry, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillIsSafe, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, verifyFillSpv };
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ declare const CLAIM_FILL_GRACE_BLOCKS = 5;
28
28
  declare const MAX_ACTIVE_CLAIMS = 3;
29
29
  declare const CLAIM_COOLDOWN_BLOCKS = 15;
30
30
  declare const FCLAIM_MAX_EPOCH_AHEAD = 2;
31
- declare const FILL_TIP_MARGIN = 2;
31
+ declare const FILL_TIP_MARGIN = 4;
32
32
  declare const CONF_TOKEN_FILL = 1000000;
33
33
  declare const TREASURY_ADDR = "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016";
34
34
  declare const FEE_BPS = 100;
@@ -604,10 +604,41 @@ declare function verifyFillSpv(offerId: string, fclaimTxid: string, me: string,
604
604
  myLiveHoldsAtGrant: number;
605
605
  pay?: bigint | string | number;
606
606
  }): Promise<FillVerdict>;
607
+ interface ProvenOfferTerms {
608
+ height: number;
609
+ feeBps: number;
610
+ value?: string;
611
+ taker?: string;
612
+ bid?: string;
613
+ min?: string;
614
+ }
615
+ declare const feeBpsAt: (height: number) => number;
616
+ declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number): ProvenOfferTerms;
617
+ /**
618
+ * The fill-boundary TERM-MISMATCH verdict: `true` iff any fee/rebate/partial-sizing field of the resolver-
619
+ * SERVED offer diverges from the merkle-proven terms `t`. FAIL-CLOSED semantics (any divergence => true =>
620
+ * the caller refuses). Byte-identical in behaviour to the wallet's old provenTermsMismatch and the site's
621
+ * old inline amount-leg bind (they were reconciled to be one predicate here):
622
+ * - height (offer.height vs t.height)
623
+ * - feeBps (offer.feeBps vs t.feeBps = feeBpsAt(creation height))
624
+ * - value (offer.want.value vs t.value, only when the proven offer is CSD-priced)
625
+ * - taker (offer.taker vs t.taker, case-insensitive, undefined/null == "")
626
+ * - bid (offer.bid vs t.bid, same normalization)
627
+ * - min presence AND value: an ADDED spurious min (whole->partial rebate-drop burn) OR a deflated min
628
+ * both mismatch. EXPLICIT presence (a served min="" must not slip past a proven-absent min).
629
+ * `value` is bound only when `t.value` is defined so a token<->token offer (no CSD value) is not spuriously
630
+ * refused; a caller that binds want.value separately (the site does) may still pass it here (redundant-safe).
631
+ */
632
+ declare function bindOfferTerms(servedOffer: unknown, t: ProvenOfferTerms): boolean;
633
+ declare function bindProvenOffer(offerEv: ProvenPropose): {
634
+ payto: string;
635
+ seller: string;
636
+ terms: ProvenOfferTerms;
637
+ } | null;
607
638
 
608
639
  declare function paidToFromOutputs(outputs: readonly {
609
640
  addr: string;
610
641
  value: number;
611
642
  }[]): Record<string, string>;
612
643
 
613
- export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEntry, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, type Want, ZERO_ADDR, bid, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, fillIsSafe, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, verifyFillSpv };
644
+ export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEntry, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillIsSafe, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, verifyFillSpv };
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var CLAIM_FILL_GRACE_BLOCKS = 5;
31
31
  var MAX_ACTIVE_CLAIMS = 3;
32
32
  var CLAIM_COOLDOWN_BLOCKS = 15;
33
33
  var FCLAIM_MAX_EPOCH_AHEAD = 2;
34
- var FILL_TIP_MARGIN = 2;
34
+ var FILL_TIP_MARGIN = 4;
35
35
  var CONF_TOKEN_FILL = 1e6;
36
36
  var TREASURY_ADDR = "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016";
37
37
  var FEE_BPS = 100;
@@ -1571,6 +1571,39 @@ async function verifyFillSpv(offerId, fclaimTxid, me, io, opts) {
1571
1571
  if (holdEnd < tip + FILL_TIP_MARGIN) return no(`too close to the hold deadline (holdEnd ${holdEnd}, tip ${tip}) - would strand`);
1572
1572
  return { safe: true, reason: "ok" };
1573
1573
  }
1574
+ var feeBpsAt = (height) => height >= V11_HEIGHT ? height >= V16_HEIGHT ? FEE_BPS_V16 : FEE_BPS : 0;
1575
+ function provenOfferTerms(offerRec, provenHeight) {
1576
+ const w = offerRec.want;
1577
+ return {
1578
+ height: Number(provenHeight),
1579
+ feeBps: feeBpsAt(Number(provenHeight)),
1580
+ value: w.value !== void 0 ? String(w.value) : void 0,
1581
+ taker: offerRec.taker !== void 0 ? String(offerRec.taker).toLowerCase() : void 0,
1582
+ bid: offerRec.bid !== void 0 ? String(offerRec.bid).toLowerCase() : void 0,
1583
+ min: offerRec.min !== void 0 ? String(offerRec.min) : void 0
1584
+ };
1585
+ }
1586
+ function bindOfferTerms(servedOffer, t) {
1587
+ const o = servedOffer;
1588
+ const s = (v) => v === void 0 || v === null ? "" : String(v).toLowerCase();
1589
+ if (Number(o?.height) !== t.height) return true;
1590
+ if (Number(o?.feeBps) !== t.feeBps) return true;
1591
+ if (t.value !== void 0 && String(o?.want?.value) !== t.value) return true;
1592
+ if (s(o?.taker) !== s(t.taker)) return true;
1593
+ if (s(o?.bid) !== s(t.bid)) return true;
1594
+ const om = o?.min;
1595
+ if ((om !== void 0 && om !== null) !== (t.min !== void 0)) return true;
1596
+ if (t.min !== void 0 && String(om) !== t.min) return true;
1597
+ return false;
1598
+ }
1599
+ function bindProvenOffer(offerEv) {
1600
+ const rec = bindRecord(offerEv);
1601
+ if (!rec || rec.t !== "offer") return null;
1602
+ const seller = String(offerEv.proposer).toLowerCase();
1603
+ const w = rec.want;
1604
+ const payto = w.payto && ADDR_RE.test(String(w.payto).toLowerCase()) ? String(w.payto).toLowerCase() : seller;
1605
+ return { payto, seller, terms: provenOfferTerms(rec, offerEv.height) };
1606
+ }
1574
1607
 
1575
1608
  // src/paidto.ts
1576
1609
  function paidToFromOutputs(outputs) {
@@ -1682,6 +1715,8 @@ export {
1682
1715
  V28_HEIGHT,
1683
1716
  ZERO_ADDR,
1684
1717
  bid,
1718
+ bindOfferTerms,
1719
+ bindProvenOffer,
1685
1720
  blockReward2 as blockReward,
1686
1721
  buildFeeHeight,
1687
1722
  buildRecord,
@@ -1696,6 +1731,7 @@ export {
1696
1731
  fclaim,
1697
1732
  fclaimEpochFor,
1698
1733
  fclaimHoldEnd,
1734
+ feeBpsAt,
1699
1735
  fillIsSafe,
1700
1736
  fillTargetId,
1701
1737
  finalizeWinnerCheck,
@@ -1725,6 +1761,7 @@ export {
1725
1761
  pickPrimaryName,
1726
1762
  previewFill,
1727
1763
  primaryRankBefore,
1764
+ provenOfferTerms,
1728
1765
  replayLiveHold,
1729
1766
  requiredClaimDepth,
1730
1767
  requiredFillOutputs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inversealtruism/cairnx-core",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "engines": {
5
5
  "node": ">=18"
6
6
  },
@@ -45,6 +45,6 @@
45
45
  "homepage": "https://cairn-substrate.com/trade",
46
46
  "scripts": {
47
47
  "build": "tsup src/index.ts --format esm,cjs --dts --clean",
48
- "test": "tsx test/vectors.test.ts && tsx test/name-decoy.test.ts && tsx test/client-helpers.test.ts && tsx test/paidto.test.ts && tsx test/preflight.test.ts && tsx test/primary.test.ts && tsx test/fclaim.test.ts && tsx test/fclaim-v28.test.ts && tsx test/verifyfill.test.ts"
48
+ "test": "tsx test/vectors.test.ts && tsx test/name-decoy.test.ts && tsx test/client-helpers.test.ts && tsx test/paidto.test.ts && tsx test/preflight.test.ts && tsx test/primary.test.ts && tsx test/fclaim.test.ts && tsx test/fclaim-v28.test.ts && tsx test/verifyfill.test.ts && tsx test/wa-parity.test.ts"
49
49
  }
50
50
  }
@@ -7450,6 +7450,129 @@
7450
7450
  }
7451
7451
  }
7452
7452
  }
7453
+ },
7454
+ {
7455
+ "name": "v28-namegive-fclaim-fill",
7456
+ "events": [
7457
+ {
7458
+ "kind": "propose",
7459
+ "id": "0x00000000000000000000000000000000000000000000000000000000fc28001d",
7460
+ "proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
7461
+ "uri": "{\"commit\":\"0x103fb8eeae5e6827389b7a7b51ae659d5d0118d9d21398c3d9f1181440149364\",\"t\":\"ncommit\",\"v\":1}",
7462
+ "payloadHash": "0xaa38d67cedbf151f9f167d49991427d85353017304426db1af63d81e642e6cc5",
7463
+ "expiresEpoch": 900000000000000,
7464
+ "height": 60000,
7465
+ "pos": 1,
7466
+ "paidTo": {}
7467
+ },
7468
+ {
7469
+ "kind": "propose",
7470
+ "id": "0x00000000000000000000000000000000000000000000000000000000fc28001e",
7471
+ "proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
7472
+ "uri": "{\"name\":\"gemname\",\"salt\":\"a1a1a1a1a1a1a1a1\",\"t\":\"name\",\"v\":1}",
7473
+ "payloadHash": "0x4b496fea674f44b47b597633f7317dc0d1f2d871a7c7947a56246181c57fa2b4",
7474
+ "expiresEpoch": 900000000000000,
7475
+ "height": 60002,
7476
+ "pos": 1,
7477
+ "paidTo": {}
7478
+ },
7479
+ {
7480
+ "kind": "propose",
7481
+ "id": "0x00000000000000000000000000000000000000000000000000000000fc28001f",
7482
+ "proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
7483
+ "uri": "{\"name\":\"gemname\",\"salt\":\"a1a1a1a1a1a1a1a1\",\"t\":\"nfinalize\",\"v\":1}",
7484
+ "payloadHash": "0x63926275c4b89a7788ab506af975805569362a347f246ac96454552750167fa8",
7485
+ "expiresEpoch": 900000000000000,
7486
+ "height": 60010,
7487
+ "pos": 1,
7488
+ "paidTo": {
7489
+ "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "500000000"
7490
+ }
7491
+ },
7492
+ {
7493
+ "kind": "propose",
7494
+ "id": "0x00000000000000000000000000000000000000000000000000000000fc280020",
7495
+ "proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
7496
+ "uri": "{\"give\":{\"name\":\"gemname\"},\"t\":\"offer\",\"v\":1,\"want\":{\"payto\":\"0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1\",\"value\":\"1000000000\"}}",
7497
+ "payloadHash": "0x0379d4c9e1aa33fd6159dc46ca69f16e726ef8430618d069da3ed2c0de4e890d",
7498
+ "expiresEpoch": 2024,
7499
+ "height": 60011,
7500
+ "pos": 0,
7501
+ "paidTo": {}
7502
+ },
7503
+ {
7504
+ "kind": "propose",
7505
+ "id": "0x00000000000000000000000000000000000000000000000000000000fc280021",
7506
+ "proposer": "0xb2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2",
7507
+ "uri": "{\"offer\":\"0x00000000000000000000000000000000000000000000000000000000fc280020\",\"t\":\"fclaim\",\"v\":1}",
7508
+ "payloadHash": "0x64dd224736e033203635889c53a4ecd8c58ad20905e38c1465b54874e0e06439",
7509
+ "expiresEpoch": 2002,
7510
+ "height": 60012,
7511
+ "pos": 0,
7512
+ "paidTo": {}
7513
+ },
7514
+ {
7515
+ "kind": "attest",
7516
+ "txid": "0x00000000000000000000000000000000000000000000000000000000fc280022",
7517
+ "proposalId": "0x00000000000000000000000000000000000000000000000000000000fc280021",
7518
+ "attester": "0xb2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2",
7519
+ "score": 100,
7520
+ "confidence": 0,
7521
+ "height": 60089,
7522
+ "pos": 0,
7523
+ "paidTo": {
7524
+ "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1": "1030000000",
7525
+ "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "15000000"
7526
+ }
7527
+ }
7528
+ ],
7529
+ "tipHeight": 60094,
7530
+ "expectedState": {
7531
+ "balances": {},
7532
+ "bids": {},
7533
+ "feesPaid": "515000000",
7534
+ "names": {
7535
+ "gemname": {
7536
+ "claimId": "0x00000000000000000000000000000000000000000000000000000000fc280022",
7537
+ "effectiveHeight": 60089,
7538
+ "height": 60089,
7539
+ "locked": false,
7540
+ "name": "gemname",
7541
+ "owner": "0xb2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2",
7542
+ "paidThroughEpoch": 10760,
7543
+ "viaFill": true
7544
+ }
7545
+ },
7546
+ "offers": {
7547
+ "0x00000000000000000000000000000000000000000000000000000000fc280020": {
7548
+ "claimTxid": "0x00000000000000000000000000000000000000000000000000000000fc280021",
7549
+ "claimUntilHeight": 60090,
7550
+ "claimedBy": "0xb2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2",
7551
+ "expiresEpoch": 2024,
7552
+ "feeBps": 150,
7553
+ "fill": {
7554
+ "buyer": "0xb2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2",
7555
+ "fee": "15000000",
7556
+ "height": 60089,
7557
+ "paid": "1030000000",
7558
+ "txid": "0x00000000000000000000000000000000000000000000000000000000fc280022"
7559
+ },
7560
+ "give": {
7561
+ "name": "gemname"
7562
+ },
7563
+ "height": 60011,
7564
+ "id": "0x00000000000000000000000000000000000000000000000000000000fc280020",
7565
+ "seller": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
7566
+ "status": "filled",
7567
+ "want": {
7568
+ "payto": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
7569
+ "value": "1000000000"
7570
+ }
7571
+ }
7572
+ },
7573
+ "tipHeight": 60094,
7574
+ "tokens": {}
7575
+ }
7453
7576
  }
7454
7577
  ]
7455
7578
  }
@@ -0,0 +1,175 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "note": "WA-PARITY: the SHARED hostile-case corpus that keeps the three fill-boundary seams from ever diverging (cairnx-core verifyFillSpv, cairn-wallet fillspv.ts, cairn public/trade/swapguard.js). Homed here in csd-sdk; each consumer repo vendors a byte-identity-checked copy (the I2 dead-green lesson: the freshness check FAILS, never skips, if a copy drifts). Record-level + seam-agnostic: every seam materializes the SAME scenario in its own injection shape (cairnx-core builds abstract ChainEvents; wallet/site build REAL signed txs + prevout binds), so a wallet-vs-site split goes red. Two families: 'replay' cases exercise the grant/hold/completeness replay that ALL THREE seams share; 'terms' cases exercise the served-offer vs merkle-proven-offer bind that only the CALLERS do (wallet provenTermsMismatch + site verifyOfferContent), because cairnx-core verifyFillSpv takes NO served offer and re-derives everything from proven events.",
4
+ "consts": {
5
+ "V28_HEIGHT": 60000,
6
+ "EPOCH_LEN": 30,
7
+ "FCLAIM_MAX_EPOCH_AHEAD": 2,
8
+ "CLAIM_COOLDOWN_BLOCKS": 15,
9
+ "FILL_TIP_MARGIN": 4,
10
+ "TREASURY_ADDR": "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016",
11
+ "FEE_BPS_V16": 150,
12
+ "note": "Each adapter MUST assert its own vendored constants equal these before running, so a silent constant drift reds the corpus (not a false green)."
13
+ },
14
+ "actors": {
15
+ "A": { "role": "seller" },
16
+ "B": { "role": "buyer" },
17
+ "C": { "role": "third-party" }
18
+ },
19
+ "backing": [
20
+ { "by": "A", "height": "H0", "rec": { "t": "deploy", "ticker": "AAA", "decimals": 0, "supply": "1000", "mint": "issuer" }, "fee": "DEPLOY_FEE" },
21
+ { "by": "A", "height": "H0+1", "rec": { "t": "mint", "ticker": "AAA", "amount": "1000" } }
22
+ ],
23
+ "scenarios": [
24
+ {
25
+ "name": "honest-whole-fill",
26
+ "family": "replay",
27
+ "seams": ["cairnxCore", "wallet", "site"],
28
+ "desc": "The buyer holds a live granted fclaim on an open whole-fill CSD offer, both buried, delivery >= 1. Accepted by every seam (the no-false-refusal baseline).",
29
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
30
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
31
+ "extra": [],
32
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
33
+ "attack": { "type": "none" },
34
+ "expect": "accept"
35
+ },
36
+ {
37
+ "name": "honest-partial-fill",
38
+ "family": "replay",
39
+ "seams": ["cairnxCore", "wallet", "site"],
40
+ "desc": "A partial-enabled offer (min set) with a buyer paying exactly min. Deliverable >= 1, accepted by every seam. Guards against a false-refuse of legitimate partials.",
41
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": "100000000" },
42
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
43
+ "extra": [],
44
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": "100000000" },
45
+ "attack": { "type": "none" },
46
+ "expect": "accept"
47
+ },
48
+ {
49
+ "name": "below-depth-fill",
50
+ "family": "replay",
51
+ "seams": ["cairnxCore", "wallet", "site"],
52
+ "desc": "The fclaim is not yet buried to requiredClaimDepth. Every seam REFUSES (fail-safe wait, not a burn).",
53
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
54
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
55
+ "extra": [],
56
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "absolute", "h": "H0+4" }, "pay": null },
57
+ "attack": { "type": "none" },
58
+ "expect": "reject"
59
+ },
60
+ {
61
+ "name": "denied-fclaim",
62
+ "family": "replay",
63
+ "seams": ["cairnxCore", "wallet", "site"],
64
+ "desc": "B holds fc1 (granted); B posts fc2 while fc1's hold is live -> the resolver DENIES fc2. A lying resolver aliases fc2 as granted. Filling fc2 attests an L0-valid but DELIVERY-LESS target = burn. Every seam re-derives the deny and REFUSES.",
65
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
66
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
67
+ "extra": [
68
+ { "kind": "fclaim", "id": "F2", "by": "B", "offer": "OFFER", "height": "H0+5", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } }
69
+ ],
70
+ "fill": { "me": "B", "fclaim": "F2", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
71
+ "attack": { "type": "none" },
72
+ "expect": "reject"
73
+ },
74
+ {
75
+ "name": "forged-cancel-holder",
76
+ "family": "replay",
77
+ "seams": ["cairnxCore", "wallet", "site"],
78
+ "desc": "C holds a valid fclaim fcC; B forges holdership and tries to fill fcC. resolve() would reject the payment (who !== claimedBy), burning it. Every seam re-derives that the hold is not mine and REFUSES.",
79
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
80
+ "fclaim": { "id": "FC", "by": "C", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
81
+ "extra": [],
82
+ "fill": { "me": "B", "fclaim": "FC", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
83
+ "attack": { "type": "none" },
84
+ "expect": "reject"
85
+ },
86
+ {
87
+ "name": "ocancel-before-grant",
88
+ "family": "replay",
89
+ "seams": ["cairnxCore", "wallet", "site"],
90
+ "desc": "Seller A posts ocancel {AAA} with no live hold -> the offer is cancelled on-chain and any later fclaim is DENIED. A Byzantine/D2-aliasing resolver still reports the offer open and serves B's fclaim as the granted target. THE F8 CASE: the site includes the ocancel in its scan (swapguard.js) and refuses; the wallet's fillspv.ts must too (the R1 F8 fix). Every seam REFUSES; a wallet-vs-site split here goes red.",
91
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
92
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+5", "ee": { "kind": "epochOfPlus", "of": "H0+5", "plus": 2 } },
93
+ "extra": [
94
+ { "kind": "ocancel", "id": "OC", "by": "A", "ticker": "AAA", "height": "H0+3" }
95
+ ],
96
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
97
+ "attack": { "type": "none" },
98
+ "expect": "reject"
99
+ },
100
+ {
101
+ "name": "withheld-cancel",
102
+ "family": "replay",
103
+ "seams": ["wallet", "site"],
104
+ "desc": "Seller A posts ocancel {AAA} on-chain BEFORE the fclaim grant, but a lying resolver OMITS the ocancel from the event/hint list it serves (the F8 COMPLETENESS attack, distinct from ocancel-before-grant where the cancel IS in the served set). Each seam must find the cancel via its OWN PoW-verified block-body scan and REFUSE. cairnx-core verifyFillSpv canNOT catch a withheld event - its event set IS the seam's hint list (io.offerEventIds), so completeness is a SEAM obligation the pure layer cannot verify. Hence this scenario is wallet/site-only; the cairnx-core adapter demonstrates the gap by materialising the withheld cancel on-chain-but-excluded-from-hints and asserting verifyFillSpv ACCEPTS (safe), which is exactly why the seams do their own scan.",
105
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
106
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+5", "ee": { "kind": "epochOfPlus", "of": "H0+5", "plus": 2 } },
107
+ "extra": [
108
+ { "kind": "ocancel", "id": "OC", "by": "A", "ticker": "AAA", "height": "H0+3", "withheld": true }
109
+ ],
110
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
111
+ "attack": { "type": "withheld-event", "event": "OC" },
112
+ "expect": "reject"
113
+ },
114
+ {
115
+ "name": "payto-strip",
116
+ "family": "terms",
117
+ "seams": ["wallet", "site"],
118
+ "desc": "The open CSD offer is payto-LESS on-chain (recipient = the proven prevout owner A). A read-path attacker strips the funding tx scriptSig (recoverAttester -> null) and serves a /proposal whose want.payto is the attacker. The site + wallet bind the recipient to the MERKLE-PROVEN prevout owner and REFUSE. cairnxCore N/A: verifyFillSpv takes no served offer.",
119
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": null }, "min": null },
120
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
121
+ "extra": [],
122
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
123
+ "attack": { "type": "payto-substitute", "servedPayto": "ATTACKER", "scriptSig": "strip" },
124
+ "expect": "reject"
125
+ },
126
+ {
127
+ "name": "payto-resign",
128
+ "family": "terms",
129
+ "seams": ["wallet", "site"],
130
+ "desc": "Same payto-less offer, but the attacker RE-SIGNS the funding tx with a throwaway key so recoverAttester returns the attacker (== served proposer). The bind derives the recipient from the merkle-proven PREVOUT OWNER (not the malleable scriptSig), so both seams still REFUSE.",
131
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": null }, "min": null },
132
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
133
+ "extra": [],
134
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
135
+ "attack": { "type": "payto-substitute", "servedPayto": "ATTACKER", "scriptSig": "resign" },
136
+ "expect": "reject"
137
+ },
138
+ {
139
+ "name": "seller-swap",
140
+ "family": "terms",
141
+ "seams": ["wallet", "site"],
142
+ "desc": "The maker-rebate leg (offer.seller) is swapped to the attacker while want.payto stays honest. resolve() pays the rebate to the on-chain author; a mis-sized rebate leg makes resolve() reject AFTER payment = burn. Both seams bind offer.seller to the proven author and REFUSE.",
143
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
144
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
145
+ "extra": [],
146
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
147
+ "attack": { "type": "seller-substitute", "servedSeller": "ATTACKER" },
148
+ "expect": "reject"
149
+ },
150
+ {
151
+ "name": "spurious-min-whole-fill",
152
+ "family": "terms",
153
+ "seams": ["wallet", "site"],
154
+ "desc": "The offer is a whole-fill open-CSD offer (no on-chain min). A lying resolver ADDS a spurious min -> previewFill flips to the PARTIAL branch (rebate:0) -> requiredFillOutputs drops the maker-rebate leg -> resolve() rejects 'maker rebate unpaid' AFTER payment = full burn (the R1.1 min-bind case). Both seams bind min (present/absent) to the proven record and REFUSE.",
155
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
156
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
157
+ "extra": [],
158
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
159
+ "attack": { "type": "min-substitute", "servedMin": "100000000" },
160
+ "expect": "reject"
161
+ },
162
+ {
163
+ "name": "deflated-feeBps",
164
+ "family": "terms",
165
+ "seams": ["wallet", "site"],
166
+ "desc": "A lying resolver serves feeBps=0 for a >= V16 offer (real FEE_BPS_V16=150). requiredFillOutputs then under-sizes/omits the treasury fee leg -> resolve() rejects AFTER payment = burn. Both seams bind feeBps/height/taker/bid to the proven terms and REFUSE.",
167
+ "offer": { "id": "OFFER", "by": "A", "height": "H0+2", "give": { "ticker": "AAA", "amount": "10" }, "want": { "value": "500000000", "payto": "A" }, "min": null },
168
+ "fclaim": { "id": "F1", "by": "B", "offer": "OFFER", "height": "H0+3", "ee": { "kind": "epochOfPlus", "of": "H0+3", "plus": 2 } },
169
+ "extra": [],
170
+ "fill": { "me": "B", "fclaim": "F1", "tip": { "kind": "holdEndMinus", "n": 5 }, "pay": null },
171
+ "attack": { "type": "feeBps-substitute", "servedFeeBps": 0 },
172
+ "expect": "reject"
173
+ }
174
+ ]
175
+ }