@neuraiproject/neurai-scripts 0.9.1 → 0.10.0

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/types.d.ts CHANGED
@@ -45,17 +45,35 @@ export interface PartialFillExpiration {
45
45
  */
46
46
  value: bigint;
47
47
  }
48
+ /**
49
+ * Seller of an ECDSA-cancel order, in one of two forms:
50
+ * - `sellerAddress` alone: a legacy P2PKH address that is both the
51
+ * payment destination and the cancel key hash;
52
+ * - `paymentAddress` with `sellerPubKeyHash`: any payment destination
53
+ * and the HASH160 of the secp256k1 key that may cancel. This is the
54
+ * form for a strict ECDSA v3 (`nq1r…`) seller, whose address program is
55
+ * a commitment and not a key hash.
56
+ * Passing both forms, or neither, throws.
57
+ */
48
58
  export interface PartialFillOrderParams {
49
59
  /**
50
- * Seller destination. Must be a legacy P2PKH address (base58check,
51
- * "t..." on testnet, "N..." on mainnet). The legacy covenant uses
52
- * `OP_HASH160 + OP_CHECKSIG` in its cancel branch, so every bech32m
53
- * address (AuthScript v1 `nc1p…`, PQ v2 `pq1z…` and ECDSA v3 `nq1r…`,
54
- * whose program is a commitment, not a key hash) is rejected — use
55
- * `buildPartialFillScriptPQ` for those destinations. The decoded 20-byte
56
- * PKH is hardcoded into the covenant (cancel branch + payment scriptPubKey).
60
+ * Legacy P2PKH seller (base58check, "t..." on testnet, "N..." on
61
+ * mainnet). Its 20-byte PKH is hardcoded as the cancel key hash and the
62
+ * payment output must be the P2PKH script of that same PKH. Bech32m
63
+ * addresses are rejected here: use `paymentAddress` + `sellerPubKeyHash`.
64
+ */
65
+ sellerAddress?: string;
66
+ /**
67
+ * Destination for the XNA payment: legacy P2PKH, generic AuthScript v1
68
+ * (`nc1p…`), strict PQ v2 (`pq1z…`) or strict ECDSA v3 (`nq1r…`). The
69
+ * covenant hardcodes its full scriptPubKey. Requires `sellerPubKeyHash`.
57
70
  */
58
- sellerAddress: string;
71
+ paymentAddress?: string;
72
+ /**
73
+ * HASH160 of the compressed secp256k1 public key allowed to cancel the
74
+ * order (20 bytes). Requires `paymentAddress`.
75
+ */
76
+ sellerPubKeyHash?: Uint8Array;
59
77
  /** Name of the asset being sold (e.g. "CAT"). */
60
78
  tokenId: string;
61
79
  /**
@@ -78,11 +96,13 @@ export interface ParsedPartialFillOrder {
78
96
  /** Network the parser was invoked with (used for downstream address formatting). */
79
97
  network: Network;
80
98
  /**
81
- * Seller's 20-byte pubkey hash, extracted from the covenant's cancel
82
- * branch. The caller can base58check-encode this with the network's
83
- * legacy prefix to recover the seller address when needed.
99
+ * 20-byte HASH160 of the key allowed to cancel, extracted from the
100
+ * covenant's cancel branch. It equals the payment P2PKH hash only for
101
+ * orders built with `sellerAddress`.
84
102
  */
85
103
  sellerPubKeyHash: Uint8Array;
104
+ /** scriptPubKey bytes embedded in the covenant for the payment output. */
105
+ paymentScriptPubKey: Uint8Array;
86
106
  /** Asset name parsed from the covenant. */
87
107
  tokenId: string;
88
108
  /** Unit price parsed from the covenant, in XNA satoshis. */
@@ -136,10 +156,10 @@ export interface PartialFillOrderPQParams {
136
156
  /** Price in XNA satoshis per indivisible unit of the asset. */
137
157
  unitPriceSats: bigint;
138
158
  /**
139
- * OP_TXHASH selector byte bound into the script. Default `0xff` (all
140
- * eight fields). The seller must sign `SHA256(OP_TXHASH(selector))` with
141
- * their PQ key at cancel time. See
142
- * `doc/new-opcodes-depin-branch.md` §2.1 for the bit → field mapping.
159
+ * NIP-042 OP_TXHASH selector bound into the script as exactly two
160
+ * little-endian bytes. Default `0x1ff` commits all nine fields, including
161
+ * reference inputs. The seller signs `SHA256(OP_TXHASH(selector))` with
162
+ * their PQ key at cancel time.
143
163
  */
144
164
  txHashSelector?: number;
145
165
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuraiproject/neurai-scripts",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "Script-assembly library for Neurai: opcode constants, ScriptBuilder, standard scripts (P2PKH, P2WPKH, P2WSH, AuthScript, multisig, OP_RETURN) and covenants (partial-fill sell orders, legacy + PQ) targeting the DePIN-Test opcode set",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -43,7 +43,7 @@
43
43
  "test:watch": "vitest"
44
44
  },
45
45
  "dependencies": {
46
- "@neuraiproject/neurai-create-transaction": "^0.9.0"
46
+ "@neuraiproject/neurai-create-transaction": "^0.9.2"
47
47
  },
48
48
  "keywords": [
49
49
  "neurai",
@@ -67,7 +67,7 @@
67
67
  ],
68
68
  "license": "MIT",
69
69
  "devDependencies": {
70
- "@neuraiproject/neurai-key": "^5.0.1",
70
+ "@neuraiproject/neurai-key": "^5.0.3",
71
71
  "@rollup/plugin-commonjs": "^28.0.8",
72
72
  "@rollup/plugin-node-resolve": "^16.0.3",
73
73
  "bech32": "^2.0.0",