@secondlayer/stacks 0.0.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 (178) hide show
  1. package/README.md +92 -0
  2. package/dist/shared/stacks-02actsrx.cjs +17 -0
  3. package/dist/shared/stacks-02actsrx.cjs.map +10 -0
  4. package/dist/shared/stacks-1aqm7c2h.cjs +110 -0
  5. package/dist/shared/stacks-1aqm7c2h.cjs.map +11 -0
  6. package/dist/shared/stacks-24h5k94q.cjs +74 -0
  7. package/dist/shared/stacks-24h5k94q.cjs.map +11 -0
  8. package/dist/shared/stacks-2ar4prfz.cjs +328 -0
  9. package/dist/shared/stacks-2ar4prfz.cjs.map +11 -0
  10. package/dist/shared/stacks-4py5pm0r.cjs +237 -0
  11. package/dist/shared/stacks-4py5pm0r.cjs.map +10 -0
  12. package/dist/shared/stacks-5tprhns9.cjs +54 -0
  13. package/dist/shared/stacks-5tprhns9.cjs.map +11 -0
  14. package/dist/shared/stacks-61rvzkz1.cjs +132 -0
  15. package/dist/shared/stacks-61rvzkz1.cjs.map +17 -0
  16. package/dist/shared/stacks-709tra19.js +30 -0
  17. package/dist/shared/stacks-709tra19.js.map +10 -0
  18. package/dist/shared/stacks-74k8cxgb.cjs +567 -0
  19. package/dist/shared/stacks-74k8cxgb.cjs.map +13 -0
  20. package/dist/shared/stacks-8m9byk2j.js +7 -0
  21. package/dist/shared/stacks-8m9byk2j.js.map +9 -0
  22. package/dist/shared/stacks-8yykgdww.js +125 -0
  23. package/dist/shared/stacks-8yykgdww.js.map +11 -0
  24. package/dist/shared/stacks-9g0jhab3.cjs +40 -0
  25. package/dist/shared/stacks-9g0jhab3.cjs.map +10 -0
  26. package/dist/shared/stacks-an5k8n4t.cjs +291 -0
  27. package/dist/shared/stacks-an5k8n4t.cjs.map +23 -0
  28. package/dist/shared/stacks-b008c3w8.cjs +214 -0
  29. package/dist/shared/stacks-b008c3w8.cjs.map +11 -0
  30. package/dist/shared/stacks-bnvfmt7y.cjs +31 -0
  31. package/dist/shared/stacks-bnvfmt7y.cjs.map +9 -0
  32. package/dist/shared/stacks-bycy6t9k.js +22 -0
  33. package/dist/shared/stacks-bycy6t9k.js.map +10 -0
  34. package/dist/shared/stacks-d1fmkv3p.js +258 -0
  35. package/dist/shared/stacks-d1fmkv3p.js.map +13 -0
  36. package/dist/shared/stacks-dr5en54r.cjs +119 -0
  37. package/dist/shared/stacks-dr5en54r.cjs.map +10 -0
  38. package/dist/shared/stacks-dxhntr76.js +278 -0
  39. package/dist/shared/stacks-dxhntr76.js.map +10 -0
  40. package/dist/shared/stacks-evnzth1q.cjs +35 -0
  41. package/dist/shared/stacks-evnzth1q.cjs.map +10 -0
  42. package/dist/shared/stacks-f3tk2k5s.js +27 -0
  43. package/dist/shared/stacks-f3tk2k5s.js.map +9 -0
  44. package/dist/shared/stacks-f7wdrzs3.js +285 -0
  45. package/dist/shared/stacks-f7wdrzs3.js.map +11 -0
  46. package/dist/shared/stacks-fcaefc5b.cjs +16 -0
  47. package/dist/shared/stacks-fcaefc5b.cjs.map +10 -0
  48. package/dist/shared/stacks-g9mcjcqg.cjs +3 -0
  49. package/dist/shared/stacks-g9mcjcqg.cjs.map +9 -0
  50. package/dist/shared/stacks-gck1sq7h.cjs +28 -0
  51. package/dist/shared/stacks-gck1sq7h.cjs.map +10 -0
  52. package/dist/shared/stacks-gjvbq6w7.js +46 -0
  53. package/dist/shared/stacks-gjvbq6w7.js.map +10 -0
  54. package/dist/shared/stacks-j2cy7qtt.js +237 -0
  55. package/dist/shared/stacks-j2cy7qtt.js.map +11 -0
  56. package/dist/shared/stacks-k08tgzyp.cjs +232 -0
  57. package/dist/shared/stacks-k08tgzyp.cjs.map +13 -0
  58. package/dist/shared/stacks-k2p5tv6x.js +37 -0
  59. package/dist/shared/stacks-k2p5tv6x.js.map +10 -0
  60. package/dist/shared/stacks-k58k970n.js +234 -0
  61. package/dist/shared/stacks-k58k970n.js.map +10 -0
  62. package/dist/shared/stacks-n2g56wgg.js +338 -0
  63. package/dist/shared/stacks-n2g56wgg.js.map +23 -0
  64. package/dist/shared/stacks-nqytwfcc.js +243 -0
  65. package/dist/shared/stacks-nqytwfcc.js.map +11 -0
  66. package/dist/shared/stacks-qcae5852.js +19 -0
  67. package/dist/shared/stacks-qcae5852.js.map +10 -0
  68. package/dist/shared/stacks-qt8ehebn.js +76 -0
  69. package/dist/shared/stacks-qt8ehebn.js.map +11 -0
  70. package/dist/shared/stacks-qvg7c24g.cjs +232 -0
  71. package/dist/shared/stacks-qvg7c24g.cjs.map +10 -0
  72. package/dist/shared/stacks-r1t6g3c3.cjs +241 -0
  73. package/dist/shared/stacks-r1t6g3c3.cjs.map +11 -0
  74. package/dist/shared/stacks-tjxmrssa.js +282 -0
  75. package/dist/shared/stacks-tjxmrssa.js.map +11 -0
  76. package/dist/shared/stacks-v9jqcpd4.js +18 -0
  77. package/dist/shared/stacks-v9jqcpd4.js.map +10 -0
  78. package/dist/shared/stacks-vdfag81a.cjs +121 -0
  79. package/dist/shared/stacks-vdfag81a.cjs.map +10 -0
  80. package/dist/shared/stacks-vdfs3e5v.js +134 -0
  81. package/dist/shared/stacks-vdfs3e5v.js.map +10 -0
  82. package/dist/shared/stacks-y3dh7hv1.js +60 -0
  83. package/dist/shared/stacks-y3dh7hv1.js.map +11 -0
  84. package/dist/shared/stacks-ya3x01yd.cjs +16 -0
  85. package/dist/shared/stacks-ya3x01yd.cjs.map +10 -0
  86. package/dist/shared/stacks-yfgsm6ap.js +599 -0
  87. package/dist/shared/stacks-yfgsm6ap.js.map +13 -0
  88. package/dist/shared/stacks-yfveb68e.js +121 -0
  89. package/dist/shared/stacks-yfveb68e.js.map +10 -0
  90. package/dist/shared/stacks-zm0b3tgy.js +160 -0
  91. package/dist/shared/stacks-zm0b3tgy.js.map +17 -0
  92. package/dist/shared/stacks-zyv9qqme.cjs +249 -0
  93. package/dist/shared/stacks-zyv9qqme.cjs.map +11 -0
  94. package/dist/src/accounts/index.cjs +90 -0
  95. package/dist/src/accounts/index.cjs.map +12 -0
  96. package/dist/src/accounts/index.d.cts +47 -0
  97. package/dist/src/accounts/index.d.ts +47 -0
  98. package/dist/src/accounts/index.js +104 -0
  99. package/dist/src/accounts/index.js.map +12 -0
  100. package/dist/src/actions/index.cjs +36 -0
  101. package/dist/src/actions/index.cjs.map +9 -0
  102. package/dist/src/actions/index.d.cts +886 -0
  103. package/dist/src/actions/index.d.ts +886 -0
  104. package/dist/src/actions/index.js +81 -0
  105. package/dist/src/actions/index.js.map +9 -0
  106. package/dist/src/bns/index.cjs +590 -0
  107. package/dist/src/bns/index.cjs.map +15 -0
  108. package/dist/src/bns/index.d.cts +241 -0
  109. package/dist/src/bns/index.d.ts +241 -0
  110. package/dist/src/bns/index.js +611 -0
  111. package/dist/src/bns/index.js.map +15 -0
  112. package/dist/src/chains/index.cjs +13 -0
  113. package/dist/src/chains/index.cjs.map +9 -0
  114. package/dist/src/chains/index.d.cts +53 -0
  115. package/dist/src/chains/index.d.ts +53 -0
  116. package/dist/src/chains/index.js +18 -0
  117. package/dist/src/chains/index.js.map +9 -0
  118. package/dist/src/clarity/index.cjs +3 -0
  119. package/dist/src/clarity/index.cjs.map +9 -0
  120. package/dist/src/clarity/index.d.cts +821 -0
  121. package/dist/src/clarity/index.d.ts +821 -0
  122. package/dist/src/clarity/index.js +145 -0
  123. package/dist/src/clarity/index.js.map +9 -0
  124. package/dist/src/connect/index.cjs +480 -0
  125. package/dist/src/connect/index.cjs.map +19 -0
  126. package/dist/src/connect/index.d.cts +110 -0
  127. package/dist/src/connect/index.d.ts +110 -0
  128. package/dist/src/connect/index.js +448 -0
  129. package/dist/src/connect/index.js.map +19 -0
  130. package/dist/src/connect/walletconnect/index.cjs +1322 -0
  131. package/dist/src/connect/walletconnect/index.cjs.map +18 -0
  132. package/dist/src/connect/walletconnect/index.d.cts +132 -0
  133. package/dist/src/connect/walletconnect/index.d.ts +132 -0
  134. package/dist/src/connect/walletconnect/index.js +1290 -0
  135. package/dist/src/connect/walletconnect/index.js.map +18 -0
  136. package/dist/src/index.cjs +557 -0
  137. package/dist/src/index.cjs.map +21 -0
  138. package/dist/src/index.d.cts +847 -0
  139. package/dist/src/index.d.ts +847 -0
  140. package/dist/src/index.js +629 -0
  141. package/dist/src/index.js.map +21 -0
  142. package/dist/src/postconditions/index.cjs +3 -0
  143. package/dist/src/postconditions/index.cjs.map +9 -0
  144. package/dist/src/postconditions/index.d.cts +91 -0
  145. package/dist/src/postconditions/index.d.ts +91 -0
  146. package/dist/src/postconditions/index.js +12 -0
  147. package/dist/src/postconditions/index.js.map +9 -0
  148. package/dist/src/pox/index.cjs +860 -0
  149. package/dist/src/pox/index.cjs.map +15 -0
  150. package/dist/src/pox/index.d.cts +244 -0
  151. package/dist/src/pox/index.d.ts +244 -0
  152. package/dist/src/pox/index.js +877 -0
  153. package/dist/src/pox/index.js.map +15 -0
  154. package/dist/src/stackingdao/index.cjs +300 -0
  155. package/dist/src/stackingdao/index.cjs.map +13 -0
  156. package/dist/src/stackingdao/index.d.cts +179 -0
  157. package/dist/src/stackingdao/index.d.ts +179 -0
  158. package/dist/src/stackingdao/index.js +318 -0
  159. package/dist/src/stackingdao/index.js.map +13 -0
  160. package/dist/src/subscriptions/index.cjs +14 -0
  161. package/dist/src/subscriptions/index.cjs.map +9 -0
  162. package/dist/src/subscriptions/index.d.cts +250 -0
  163. package/dist/src/subscriptions/index.d.ts +250 -0
  164. package/dist/src/subscriptions/index.js +21 -0
  165. package/dist/src/subscriptions/index.js.map +9 -0
  166. package/dist/src/transactions/index.cjs +50 -0
  167. package/dist/src/transactions/index.cjs.map +9 -0
  168. package/dist/src/transactions/index.d.cts +412 -0
  169. package/dist/src/transactions/index.d.ts +412 -0
  170. package/dist/src/transactions/index.js +101 -0
  171. package/dist/src/transactions/index.js.map +9 -0
  172. package/dist/src/utils/index.cjs +168 -0
  173. package/dist/src/utils/index.cjs.map +11 -0
  174. package/dist/src/utils/index.d.cts +140 -0
  175. package/dist/src/utils/index.d.ts +140 -0
  176. package/dist/src/utils/index.js +222 -0
  177. package/dist/src/utils/index.js.map +11 -0
  178. package/package.json +105 -0
@@ -0,0 +1,567 @@
1
+ // src/transactions/multisig.ts
2
+ var import_secp256k12 = require("@noble/secp256k1");
3
+
4
+ // src/transactions/authorization.ts
5
+ var import_secp256k1 = require("@noble/secp256k1");
6
+ var import_hmac = require("@noble/hashes/hmac.js");
7
+ var import_sha2 = require("@noble/hashes/sha2.js");
8
+
9
+ // src/transactions/types.ts
10
+ var AuthType = {
11
+ Standard: 4,
12
+ Sponsored: 5
13
+ };
14
+ var PayloadType = {
15
+ TokenTransfer: 0,
16
+ SmartContract: 1,
17
+ ContractCall: 2,
18
+ PoisonMicroblock: 3,
19
+ Coinbase: 4,
20
+ CoinbaseToAltRecipient: 5,
21
+ VersionedSmartContract: 6,
22
+ TenureChange: 7,
23
+ NakamotoCoinbase: 8
24
+ };
25
+ var ClarityVersion = {
26
+ Clarity1: 1,
27
+ Clarity2: 2,
28
+ Clarity3: 3
29
+ };
30
+ var AnchorMode = {
31
+ OnChainOnly: 1,
32
+ OffChainOnly: 2,
33
+ Any: 3
34
+ };
35
+ var PostConditionModeWire = {
36
+ Allow: 1,
37
+ Deny: 2
38
+ };
39
+ var AddressHashMode = {
40
+ P2PKH: 0,
41
+ P2SH: 1,
42
+ P2WPKH: 2,
43
+ P2WSH: 3,
44
+ P2SH_NonSequential: 5,
45
+ P2WSH_P2SH_NonSequential: 7
46
+ };
47
+ var PubKeyEncoding = {
48
+ Compressed: 0,
49
+ Uncompressed: 1
50
+ };
51
+ var FungibleConditionCode = {
52
+ Equal: 1,
53
+ Greater: 2,
54
+ GreaterEqual: 3,
55
+ Less: 4,
56
+ LessEqual: 5
57
+ };
58
+ var NonFungibleConditionCode = {
59
+ Sends: 16,
60
+ DoesNotSend: 17
61
+ };
62
+ var PostConditionPrincipalId = {
63
+ Origin: 1,
64
+ Standard: 2,
65
+ Contract: 3
66
+ };
67
+ var AssetType = {
68
+ STX: 0,
69
+ Fungible: 1,
70
+ NonFungible: 2
71
+ };
72
+ var AuthFieldType = {
73
+ PublicKeyCompressed: 0,
74
+ PublicKeyUncompressed: 1,
75
+ SignatureCompressed: 2,
76
+ SignatureUncompressed: 3
77
+ };
78
+ var RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;
79
+ var MEMO_MAX_LENGTH_BYTES = 34;
80
+ var MAX_STRING_LENGTH_BYTES = 128;
81
+
82
+ // src/transactions/authorization.ts
83
+ import_secp256k1.etc.hmacSha256Sync = (key, ...msgs) => {
84
+ const h = import_hmac.hmac.create(import_sha2.sha256, key);
85
+ msgs.forEach((msg) => h.update(msg));
86
+ return h.digest();
87
+ };
88
+ var EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));
89
+ function createSingleSigSpendingCondition(publicKey, nonce, fee) {
90
+ const pubKeyBytes = hexToBytes(publicKey);
91
+ const signer = hashP2PKH(pubKeyBytes);
92
+ const isCompressed = pubKeyBytes.length === 33;
93
+ return {
94
+ hashMode: AddressHashMode.P2PKH,
95
+ signer,
96
+ nonce,
97
+ fee,
98
+ keyEncoding: isCompressed ? PubKeyEncoding.Compressed : PubKeyEncoding.Uncompressed,
99
+ signature: EMPTY_SIG
100
+ };
101
+ }
102
+ function createStandardAuth(spendingCondition) {
103
+ return { authType: AuthType.Standard, spendingCondition };
104
+ }
105
+ function createSponsoredAuth(spendingCondition, sponsorSpendingCondition) {
106
+ return {
107
+ authType: AuthType.Sponsored,
108
+ spendingCondition,
109
+ sponsorSpendingCondition: sponsorSpendingCondition ?? createSingleSigSpendingCondition("0".repeat(66), 0n, 0n)
110
+ };
111
+ }
112
+ function clearCondition(condition) {
113
+ if ("signature" in condition) {
114
+ return {
115
+ ...condition,
116
+ nonce: 0n,
117
+ fee: 0n,
118
+ signature: EMPTY_SIG
119
+ };
120
+ }
121
+ return {
122
+ ...condition,
123
+ nonce: 0n,
124
+ fee: 0n,
125
+ fields: []
126
+ };
127
+ }
128
+ function intoInitialSighashAuth(auth) {
129
+ if (auth.authType === AuthType.Standard) {
130
+ return createStandardAuth(clearCondition(auth.spendingCondition));
131
+ }
132
+ return createSponsoredAuth(clearCondition(auth.spendingCondition), clearCondition(createSingleSigSpendingCondition("0".repeat(66), 0n, 0n)));
133
+ }
134
+ function sigHashPreSign(curSigHash, authType, fee, nonce) {
135
+ const data = concatBytes(hexToBytes(curSigHash), new Uint8Array([authType]), intToBytes(fee, 8), intToBytes(nonce, 8));
136
+ return txidFromBytes(data);
137
+ }
138
+ function sigHashPostSign(curSigHash, pubKeyEncoding, signature) {
139
+ const data = concatBytes(hexToBytes(curSigHash), new Uint8Array([pubKeyEncoding]), hexToBytes(signature));
140
+ return txidFromBytes(data);
141
+ }
142
+ function signWithKey(privateKey, messageHash) {
143
+ const keyBytes = hexToBytes(privateKey).slice(0, 32);
144
+ const sig = import_secp256k1.sign(messageHash, keyBytes, { lowS: true });
145
+ const recoveryIdHex = intToHex(sig.recovery, 1);
146
+ return recoveryIdHex + sig.toCompactHex();
147
+ }
148
+ function nextSignature(curSigHash, authType, fee, nonce, privateKey) {
149
+ const sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);
150
+ const keyBytes = hexToBytes(privateKey).slice(0, 32);
151
+ const pubKey = import_secp256k1.getPublicKey(keyBytes, true);
152
+ const isCompressed = pubKey.length === 33;
153
+ const pubKeyEncoding = isCompressed ? PubKeyEncoding.Compressed : PubKeyEncoding.Uncompressed;
154
+ const nextSig = signWithKey(privateKey, sigHashPre);
155
+ const nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);
156
+ return { nextSig, nextSigHash };
157
+ }
158
+
159
+ // src/transactions/wire/serialize.ts
160
+ function serializeAddress(c32Address) {
161
+ const [version, hash1602] = c32addressDecode(c32Address);
162
+ return concatBytes(new Uint8Array([version]), hexToBytes(hash1602));
163
+ }
164
+ function serializeLPString(str, prefixBytes = 1) {
165
+ const content = utf8ToBytes(str);
166
+ const prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));
167
+ return concatBytes(prefix, content);
168
+ }
169
+ function serializeLPStringLong(str) {
170
+ return serializeLPString(str, 4);
171
+ }
172
+ function serializeMemo(memo) {
173
+ const content = asciiToBytes(memo);
174
+ const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);
175
+ padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));
176
+ return concatBytes(writeUInt8(content.length), padded);
177
+ }
178
+ function serializeSpendingCondition(condition) {
179
+ const parts = [
180
+ writeUInt8(condition.hashMode),
181
+ hexToBytes(condition.signer),
182
+ intToBytes(condition.nonce, 8),
183
+ intToBytes(condition.fee, 8)
184
+ ];
185
+ if ("signature" in condition) {
186
+ const sc = condition;
187
+ parts.push(writeUInt8(sc.keyEncoding));
188
+ parts.push(hexToBytes(sc.signature));
189
+ } else {
190
+ const mc = condition;
191
+ parts.push(writeUInt32BE(mc.fields.length));
192
+ for (const field of mc.fields) {
193
+ parts.push(serializeAuthField(field));
194
+ }
195
+ parts.push(writeUInt16BE(mc.signaturesRequired));
196
+ }
197
+ return concatBytes(...parts);
198
+ }
199
+ function serializeAuthField(field) {
200
+ if (field.type === "publicKey") {
201
+ const typeId = field.pubKeyEncoding === 0 ? 0 : 1;
202
+ return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
203
+ } else {
204
+ const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
205
+ return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
206
+ }
207
+ }
208
+ function serializeAuthorization(auth) {
209
+ const parts = [writeUInt8(auth.authType)];
210
+ parts.push(serializeSpendingCondition(auth.spendingCondition));
211
+ if (auth.authType === AuthType.Sponsored) {
212
+ parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));
213
+ }
214
+ return concatBytes(...parts);
215
+ }
216
+ function serializePrincipal(principal) {
217
+ switch (principal.type) {
218
+ case "origin":
219
+ return writeUInt8(PostConditionPrincipalId.Origin);
220
+ case "standard":
221
+ return concatBytes(writeUInt8(PostConditionPrincipalId.Standard), serializeAddress(principal.address));
222
+ case "contract":
223
+ return concatBytes(writeUInt8(PostConditionPrincipalId.Contract), serializeAddress(principal.address), serializeLPString(principal.contractName));
224
+ }
225
+ }
226
+ function serializeAssetInfo(asset) {
227
+ return concatBytes(serializeAddress(asset.address), serializeLPString(asset.contractName), serializeLPString(asset.assetName));
228
+ }
229
+ function serializePostCondition(pc) {
230
+ const parts = [serializePrincipal(pc.principal)];
231
+ switch (pc.type) {
232
+ case "stx":
233
+ parts.push(writeUInt8(AssetType.STX));
234
+ parts.push(writeUInt8(pc.conditionCode));
235
+ parts.push(intToBytes(pc.amount, 8));
236
+ break;
237
+ case "ft":
238
+ parts.push(writeUInt8(AssetType.Fungible));
239
+ parts.push(serializeAssetInfo(pc.asset));
240
+ parts.push(writeUInt8(pc.conditionCode));
241
+ parts.push(intToBytes(pc.amount, 8));
242
+ break;
243
+ case "nft":
244
+ parts.push(writeUInt8(AssetType.NonFungible));
245
+ parts.push(serializeAssetInfo(pc.asset));
246
+ parts.push(serializeCVBytes(pc.assetId));
247
+ parts.push(writeUInt8(pc.conditionCode));
248
+ break;
249
+ }
250
+ return concatBytes(...parts);
251
+ }
252
+ function serializePostConditions(pcs) {
253
+ const parts = [writeUInt32BE(pcs.length)];
254
+ for (const pc of pcs) {
255
+ parts.push(serializePostCondition(pc));
256
+ }
257
+ return concatBytes(...parts);
258
+ }
259
+ function serializePayload(payload) {
260
+ const parts = [writeUInt8(payload.payloadType)];
261
+ switch (payload.payloadType) {
262
+ case PayloadType.TokenTransfer:
263
+ parts.push(serializeCVBytes(payload.recipient));
264
+ parts.push(intToBytes(payload.amount, 8));
265
+ parts.push(serializeMemo(payload.memo));
266
+ break;
267
+ case PayloadType.ContractCall:
268
+ parts.push(serializeAddress(payload.contractAddress));
269
+ parts.push(serializeLPString(payload.contractName));
270
+ parts.push(serializeLPString(payload.functionName));
271
+ parts.push(writeUInt32BE(payload.functionArgs.length));
272
+ for (const arg of payload.functionArgs) {
273
+ parts.push(serializeCVBytes(arg));
274
+ }
275
+ break;
276
+ case PayloadType.SmartContract:
277
+ parts.push(serializeLPString(payload.contractName));
278
+ parts.push(serializeLPStringLong(payload.codeBody));
279
+ break;
280
+ case PayloadType.VersionedSmartContract:
281
+ parts.push(writeUInt8(payload.clarityVersion ?? 2));
282
+ parts.push(serializeLPString(payload.contractName));
283
+ parts.push(serializeLPStringLong(payload.codeBody));
284
+ break;
285
+ }
286
+ return concatBytes(...parts);
287
+ }
288
+ function serializeTransaction(tx) {
289
+ return concatBytes(writeUInt8(tx.version), writeUInt32BE(tx.chainId), serializeAuthorization(tx.auth), writeUInt8(tx.anchorMode), writeUInt8(tx.postConditionMode), serializePostConditions(tx.postConditions), serializePayload(tx.payload));
290
+ }
291
+ function serializeTransactionHex(tx) {
292
+ return bytesToHex(serializeTransaction(tx));
293
+ }
294
+
295
+ // src/transactions/multisig.ts
296
+ var OP_CHECKMULTISIG = 174;
297
+ function isNonSequential(hashMode) {
298
+ return (hashMode & 4) !== 0;
299
+ }
300
+ function makeRedeemScript(publicKeys, signaturesRequired) {
301
+ const parts = [];
302
+ parts.push(new Uint8Array([80 + signaturesRequired]));
303
+ for (const pk of publicKeys) {
304
+ const pkBytes = hexToBytes(pk);
305
+ parts.push(new Uint8Array([pkBytes.length]));
306
+ parts.push(pkBytes);
307
+ }
308
+ parts.push(new Uint8Array([80 + publicKeys.length]));
309
+ parts.push(new Uint8Array([OP_CHECKMULTISIG]));
310
+ return concatBytes(...parts);
311
+ }
312
+ function makeMultiSigAddress(publicKeys, signaturesRequired, chain) {
313
+ if (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {
314
+ throw new Error(`signaturesRequired must be between 1 and ${publicKeys.length}`);
315
+ }
316
+ const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);
317
+ const signer = hash160(redeemScript);
318
+ const version = chain?.addressVersion?.multiSig ?? 20;
319
+ return c32address(version, bytesToHex(signer));
320
+ }
321
+ function createMultiSigSpendingCondition(publicKeys, signaturesRequired, nonce, fee, hashMode = AddressHashMode.P2SH) {
322
+ const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);
323
+ const signer = bytesToHex(hash160(redeemScript));
324
+ return {
325
+ hashMode,
326
+ signer,
327
+ nonce,
328
+ fee,
329
+ fields: [],
330
+ signaturesRequired
331
+ };
332
+ }
333
+ function initialSigHash(tx) {
334
+ const cleared = {
335
+ ...tx,
336
+ auth: intoInitialSighashAuth(tx.auth)
337
+ };
338
+ return txidFromBytes(serializeTransaction(cleared));
339
+ }
340
+ function nonSequentialPreSignHash(tx) {
341
+ const condition = tx.auth.spendingCondition;
342
+ const initHash = initialSigHash(tx);
343
+ return sigHashPreSign(initHash, AuthType.Standard, condition.fee, condition.nonce);
344
+ }
345
+ function replayMultiSigSigHash(tx) {
346
+ const condition = tx.auth.spendingCondition;
347
+ if (isNonSequential(condition.hashMode)) {
348
+ const preSign = nonSequentialPreSignHash(tx);
349
+ let curSigHash2 = preSign;
350
+ for (const field of condition.fields) {
351
+ curSigHash2 = sigHashPostSign(curSigHash2, field.pubKeyEncoding, field.data);
352
+ }
353
+ return curSigHash2;
354
+ }
355
+ let curSigHash = initialSigHash(tx);
356
+ for (const field of condition.fields) {
357
+ const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
358
+ curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);
359
+ }
360
+ return curSigHash;
361
+ }
362
+ function signMultiSig(tx, privateKey, publicKeys) {
363
+ const keyBytes = hexToBytes(privateKey).slice(0, 32);
364
+ const signerPubKey = bytesToHex(import_secp256k12.getPublicKey(keyBytes, true));
365
+ const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);
366
+ if (signerIndex === -1) {
367
+ throw new Error("Private key does not correspond to any signer in the multi-sig");
368
+ }
369
+ const condition = { ...tx.auth.spendingCondition };
370
+ if (isNonSequential(condition.hashMode)) {
371
+ return signNonSequential(tx, condition, privateKey);
372
+ }
373
+ return signSequential(tx, condition, privateKey, publicKeys, signerIndex);
374
+ }
375
+ function signNonSequential(tx, condition, privateKey) {
376
+ const fields = [...condition.fields];
377
+ const preSignHash = nonSequentialPreSignHash(tx);
378
+ const keyBytes = hexToBytes(privateKey).slice(0, 32);
379
+ const sig = import_secp256k12.sign(preSignHash, keyBytes, { lowS: true });
380
+ const recoveryIdHex = intToHex(sig.recovery, 1);
381
+ const nextSig = recoveryIdHex + sig.toCompactHex();
382
+ fields.push({
383
+ type: "signature",
384
+ pubKeyEncoding: PubKeyEncoding.Compressed,
385
+ data: nextSig
386
+ });
387
+ const newCondition = { ...condition, fields };
388
+ const sigCount = fields.filter((f) => f.type === "signature").length;
389
+ if (sigCount >= condition.signaturesRequired) {
390
+ return {
391
+ ...tx,
392
+ auth: { ...tx.auth, spendingCondition: newCondition }
393
+ };
394
+ }
395
+ return {
396
+ ...tx,
397
+ auth: { ...tx.auth, spendingCondition: newCondition }
398
+ };
399
+ }
400
+ function signSequential(tx, condition, privateKey, publicKeys, signerIndex) {
401
+ const fields = [...condition.fields];
402
+ let curSigHash = initialSigHash(tx);
403
+ for (const field of fields) {
404
+ const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
405
+ curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);
406
+ }
407
+ for (let i = fields.length;i < signerIndex; i++) {
408
+ const pubKeyField = {
409
+ type: "publicKey",
410
+ pubKeyEncoding: PubKeyEncoding.Compressed,
411
+ data: publicKeys[i]
412
+ };
413
+ fields.push(pubKeyField);
414
+ const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
415
+ curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);
416
+ }
417
+ const { nextSig, nextSigHash } = nextSignature(curSigHash, AuthType.Standard, condition.fee, condition.nonce, privateKey);
418
+ fields.push({
419
+ type: "signature",
420
+ pubKeyEncoding: PubKeyEncoding.Compressed,
421
+ data: nextSig
422
+ });
423
+ curSigHash = nextSigHash;
424
+ const newCondition = { ...condition, fields };
425
+ const sigCount = fields.filter((f) => f.type === "signature").length;
426
+ let finalCondition = newCondition;
427
+ if (sigCount >= condition.signaturesRequired) {
428
+ finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);
429
+ }
430
+ return {
431
+ ...tx,
432
+ auth: {
433
+ ...tx.auth,
434
+ spendingCondition: finalCondition
435
+ }
436
+ };
437
+ }
438
+ async function signMultiSigWithAccount(tx, account, publicKeys) {
439
+ const signerPubKey = account.publicKey;
440
+ const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);
441
+ if (signerIndex === -1) {
442
+ throw new Error("Account does not correspond to any signer in the multi-sig");
443
+ }
444
+ const condition = { ...tx.auth.spendingCondition };
445
+ if (isNonSequential(condition.hashMode)) {
446
+ return signNonSequentialWithAccount(tx, condition, account);
447
+ }
448
+ return signSequentialWithAccount(tx, condition, account, publicKeys, signerIndex);
449
+ }
450
+ async function signNonSequentialWithAccount(tx, condition, account) {
451
+ const fields = [...condition.fields];
452
+ const preSignHash = nonSequentialPreSignHash(tx);
453
+ const sigBytes = await account.sign(hexToBytes(preSignHash));
454
+ const nextSig = bytesToHex(sigBytes);
455
+ fields.push({
456
+ type: "signature",
457
+ pubKeyEncoding: PubKeyEncoding.Compressed,
458
+ data: nextSig
459
+ });
460
+ const newCondition = { ...condition, fields };
461
+ return {
462
+ ...tx,
463
+ auth: { ...tx.auth, spendingCondition: newCondition }
464
+ };
465
+ }
466
+ async function signSequentialWithAccount(tx, condition, account, publicKeys, signerIndex) {
467
+ const fields = [...condition.fields];
468
+ let curSigHash = initialSigHash(tx);
469
+ for (const field of fields) {
470
+ const preSign2 = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
471
+ curSigHash = sigHashPostSign(preSign2, field.pubKeyEncoding, field.data);
472
+ }
473
+ for (let i = fields.length;i < signerIndex; i++) {
474
+ const pubKeyField = {
475
+ type: "publicKey",
476
+ pubKeyEncoding: PubKeyEncoding.Compressed,
477
+ data: publicKeys[i]
478
+ };
479
+ fields.push(pubKeyField);
480
+ const preSign2 = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
481
+ curSigHash = sigHashPostSign(preSign2, pubKeyField.pubKeyEncoding, pubKeyField.data);
482
+ }
483
+ const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);
484
+ const sigBytes = await account.sign(hexToBytes(preSign));
485
+ const nextSig = bytesToHex(sigBytes);
486
+ const nextSigHash = sigHashPostSign(preSign, PubKeyEncoding.Compressed, nextSig);
487
+ fields.push({
488
+ type: "signature",
489
+ pubKeyEncoding: PubKeyEncoding.Compressed,
490
+ data: nextSig
491
+ });
492
+ curSigHash = nextSigHash;
493
+ const newCondition = { ...condition, fields };
494
+ const sigCount = fields.filter((f) => f.type === "signature").length;
495
+ let finalCondition = newCondition;
496
+ if (sigCount >= condition.signaturesRequired) {
497
+ finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);
498
+ }
499
+ return {
500
+ ...tx,
501
+ auth: {
502
+ ...tx.auth,
503
+ spendingCondition: finalCondition
504
+ }
505
+ };
506
+ }
507
+ function finalizeMultiSig(tx, publicKeys) {
508
+ const condition = tx.auth.spendingCondition;
509
+ if (isNonSequential(condition.hashMode)) {
510
+ return tx;
511
+ }
512
+ const curSigHash = replayMultiSigSigHash(tx);
513
+ const finalCondition = finalizeMultiSigCondition(condition, publicKeys, curSigHash);
514
+ return {
515
+ ...tx,
516
+ auth: {
517
+ ...tx.auth,
518
+ spendingCondition: finalCondition
519
+ }
520
+ };
521
+ }
522
+ function finalizeMultiSigCondition(condition, publicKeys, curSigHash) {
523
+ const fields = [...condition.fields];
524
+ let sigHash = curSigHash;
525
+ for (let i = fields.length;i < publicKeys.length; i++) {
526
+ const pubKeyField = {
527
+ type: "publicKey",
528
+ pubKeyEncoding: PubKeyEncoding.Compressed,
529
+ data: publicKeys[i]
530
+ };
531
+ fields.push(pubKeyField);
532
+ const preSign = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);
533
+ sigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);
534
+ }
535
+ return { ...condition, fields };
536
+ }
537
+ function combineMultiSigSignatures(baseTx, signedTxs) {
538
+ const condition = baseTx.auth.spendingCondition;
539
+ if (!isNonSequential(condition.hashMode)) {
540
+ throw new Error("combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)");
541
+ }
542
+ const seenSigs = new Set;
543
+ const signatures = [];
544
+ for (const stx of signedTxs) {
545
+ const stxCondition = stx.auth.spendingCondition;
546
+ for (const field of stxCondition.fields) {
547
+ if (field.type === "signature" && !seenSigs.has(field.data)) {
548
+ seenSigs.add(field.data);
549
+ signatures.push(field);
550
+ }
551
+ }
552
+ }
553
+ if (signatures.length === 0) {
554
+ throw new Error("No signatures found in the provided transactions");
555
+ }
556
+ const newCondition = {
557
+ ...condition,
558
+ fields: signatures
559
+ };
560
+ return {
561
+ ...baseTx,
562
+ auth: { ...baseTx.auth, spendingCondition: newCondition }
563
+ };
564
+ }
565
+
566
+ //# debugId=281F100A87B1568364756E2164756E21
567
+ //# sourceMappingURL=stacks-74k8cxgb.cjs.map
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/transactions/multisig.ts", "../src/transactions/authorization.ts", "../src/transactions/types.ts", "../src/transactions/wire/serialize.ts"],
4
+ "sourcesContent": [
5
+ "import {\n getPublicKey as nobleGetPublicKey,\n sign as nobleSign,\n} from \"@noble/secp256k1\";\nimport { c32address } from \"../utils/c32.ts\";\nimport { bytesToHex, hexToBytes, intToHex, concatBytes } from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport {\n sigHashPreSign,\n sigHashPostSign,\n intoInitialSighashAuth,\n nextSignature,\n} from \"./authorization.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n type MultiSigSpendingCondition,\n type MultiSigHashMode,\n type TransactionAuthField,\n type StacksTransaction,\n} from \"./types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport type { LocalAccount, CustomAccount } from \"../accounts/types.ts\";\n\n// OP codes for redeem script\nconst OP_CHECKMULTISIG = 0xae;\n\n/** Check if hash mode is non-sequential (SIP-027) */\nexport function isNonSequential(hashMode: number): boolean {\n return (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(publicKeys: string[], signaturesRequired: number): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n for (const pk of publicKeys) {\n const pkBytes = hexToBytes(pk);\n parts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n parts.push(pkBytes);\n }\n parts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n parts.push(new Uint8Array([OP_CHECKMULTISIG]));\n return concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n publicKeys: string[],\n signaturesRequired: number,\n chain?: StacksChain\n): string {\n if (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n throw new Error(`signaturesRequired must be between 1 and ${publicKeys.length}`);\n }\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = hash160(redeemScript);\n const version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n return c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n publicKeys: string[],\n signaturesRequired: number,\n nonce: bigint,\n fee: bigint,\n hashMode: MultiSigHashMode = AddressHashMode.P2SH\n): MultiSigSpendingCondition {\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = bytesToHex(hash160(redeemScript));\n\n return {\n hashMode,\n signer,\n nonce,\n fee,\n fields: [],\n signaturesRequired,\n };\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n const cleared: StacksTransaction = {\n ...tx,\n auth: intoInitialSighashAuth(tx.auth),\n };\n return txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n const initHash = initialSigHash(tx);\n return sigHashPreSign(initHash, AuthType.Standard, condition.fee, condition.nonce);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: all signers sign the same presign-sighash, no field chaining\n if (isNonSequential(condition.hashMode)) {\n const preSign = nonSequentialPreSignHash(tx);\n // Chain through all fields to get the final sighash\n let curSigHash = preSign;\n for (const field of condition.fields) {\n curSigHash = sigHashPostSign(curSigHash, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n }\n\n // Sequential: chain through all fields\n let curSigHash = initialSigHash(tx);\n for (const field of condition.fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n tx: StacksTransaction,\n privateKey: string,\n publicKeys: string[]\n): StacksTransaction {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Private key does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequential(tx, condition, privateKey);\n }\n\n // Sequential: existing P2SH behavior\n return signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string\n): StacksTransaction {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n // Sign the presign-sighash directly\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n const nextSig = recoveryIdHex + sig.toCompactHex();\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n // Auto-finalize: non-sequential needs no pubkey gap-filling\n if (sigCount >= condition.signaturesRequired) {\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n }\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string,\n publicKeys: string[],\n signerIndex: number\n): StacksTransaction {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const { nextSig, nextSigHash } = nextSignature(\n curSigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce,\n privateKey\n );\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount,\n publicKeys: string[]\n): Promise<StacksTransaction> {\n const signerPubKey = account.publicKey;\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Account does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequentialWithAccount(tx, condition, account);\n }\n\n // Sequential: existing behavior\n return signSequentialWithAccount(tx, condition, account, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n const sigBytes = await account.sign(hexToBytes(preSignHash));\n const nextSig = bytesToHex(sigBytes);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount,\n publicKeys: string[],\n signerIndex: number\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n const sigBytes = await account.sign(hexToBytes(preSign));\n const nextSig = bytesToHex(sigBytes);\n const nextSigHash = sigHashPostSign(preSign, PubKeyEncoding.Compressed, nextSig);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n tx: StacksTransaction,\n publicKeys: string[]\n): StacksTransaction {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: no pubkey gap-filling needed\n if (isNonSequential(condition.hashMode)) {\n return tx;\n }\n\n const curSigHash = replayMultiSigSigHash(tx);\n const finalCondition = finalizeMultiSigCondition(condition, publicKeys, curSigHash);\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n condition: MultiSigSpendingCondition,\n publicKeys: string[],\n curSigHash: string\n): MultiSigSpendingCondition {\n const fields = [...condition.fields];\n let sigHash = curSigHash;\n\n // Fill remaining positions\n for (let i = fields.length; i < publicKeys.length; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);\n sigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n return { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n baseTx: StacksTransaction,\n signedTxs: StacksTransaction[]\n): StacksTransaction {\n const condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n if (!isNonSequential(condition.hashMode)) {\n throw new Error(\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\");\n }\n\n // Collect all signature fields from each signed tx\n const seenSigs = new Set<string>();\n const signatures: TransactionAuthField[] = [];\n\n for (const stx of signedTxs) {\n const stxCondition = stx.auth.spendingCondition as MultiSigSpendingCondition;\n for (const field of stxCondition.fields) {\n if (field.type === \"signature\" && !seenSigs.has(field.data)) {\n seenSigs.add(field.data);\n signatures.push(field);\n }\n }\n }\n\n if (signatures.length === 0) {\n throw new Error(\"No signatures found in the provided transactions\");\n }\n\n const newCondition: MultiSigSpendingCondition = {\n ...condition,\n fields: signatures,\n };\n\n return {\n ...baseTx,\n auth: { ...baseTx.auth, spendingCondition: newCondition },\n };\n}\n",
6
+ "import {\n getPublicKey as nobleGetPublicKey,\n sign,\n etc,\n} from \"@noble/secp256k1\";\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n bytesToHex,\n hexToBytes,\n intToBytes,\n intToHex,\n concatBytes,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n type SingleSigSpendingCondition,\n type SpendingCondition,\n type Authorization,\n type StandardAuthorization,\n type SponsoredAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n const h = hmac.create(sha256, key);\n msgs.forEach((msg) => h.update(msg));\n return h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));\n\nexport function createSingleSigSpendingCondition(\n publicKey: string,\n nonce: bigint,\n fee: bigint\n): SingleSigSpendingCondition {\n const pubKeyBytes = hexToBytes(publicKey);\n const signer = hashP2PKH(pubKeyBytes);\n const isCompressed = pubKeyBytes.length === 33;\n\n return {\n hashMode: AddressHashMode.P2PKH,\n signer,\n nonce,\n fee,\n keyEncoding: isCompressed ? PubKeyEncoding.Compressed : PubKeyEncoding.Uncompressed,\n signature: EMPTY_SIG,\n };\n}\n\nexport function createStandardAuth(\n spendingCondition: SpendingCondition\n): StandardAuthorization {\n return { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n spendingCondition: SpendingCondition,\n sponsorSpendingCondition?: SpendingCondition\n): SponsoredAuthorization {\n return {\n authType: AuthType.Sponsored,\n spendingCondition,\n sponsorSpendingCondition: sponsorSpendingCondition ?? createSingleSigSpendingCondition(\n \"0\".repeat(66),\n 0n,\n 0n\n ),\n };\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n if (\"signature\" in condition) {\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n signature: EMPTY_SIG,\n };\n }\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n fields: [],\n };\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n if (auth.authType === AuthType.Standard) {\n return createStandardAuth(clearCondition(auth.spendingCondition));\n }\n return createSponsoredAuth(\n clearCondition(auth.spendingCondition),\n clearCondition(createSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n))\n );\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([authType]),\n intToBytes(fee, 8),\n intToBytes(nonce, 8)\n );\n return txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n curSigHash: string,\n pubKeyEncoding: number,\n signature: string\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([pubKeyEncoding]),\n hexToBytes(signature)\n );\n return txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = sign(messageHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n return recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint,\n privateKey: string\n): { nextSig: string; nextSigHash: string } {\n const sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const pubKey = nobleGetPublicKey(keyBytes, true);\n const isCompressed = pubKey.length === 33;\n const pubKeyEncoding = isCompressed\n ? PubKeyEncoding.Compressed\n : PubKeyEncoding.Uncompressed;\n\n const nextSig = signWithKey(privateKey, sigHashPre);\n const nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n return { nextSig, nextSigHash };\n}\n",
7
+ "import type { ClarityValue } from \"../clarity/types.ts\";\n\n// Auth types\nexport const AuthType = {\n Standard: 0x04,\n Sponsored: 0x05,\n} as const;\nexport type AuthType = (typeof AuthType)[keyof typeof AuthType];\n\n// Payload types\nexport const PayloadType = {\n TokenTransfer: 0x00,\n SmartContract: 0x01,\n ContractCall: 0x02,\n PoisonMicroblock: 0x03,\n Coinbase: 0x04,\n CoinbaseToAltRecipient: 0x05,\n VersionedSmartContract: 0x06,\n TenureChange: 0x07,\n NakamotoCoinbase: 0x08,\n} as const;\nexport type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];\n\n// Clarity version\nexport const ClarityVersion = {\n Clarity1: 1,\n Clarity2: 2,\n Clarity3: 3,\n} as const;\nexport type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];\n\n// Anchor mode (deprecated post-Nakamoto, but needed for wire format)\nexport const AnchorMode = {\n OnChainOnly: 0x01,\n OffChainOnly: 0x02,\n Any: 0x03,\n} as const;\nexport type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];\n\n// Post condition mode\nexport const PostConditionModeWire = {\n Allow: 0x01,\n Deny: 0x02,\n} as const;\nexport type PostConditionModeWire =\n (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];\n\n// Address hash modes\nexport const AddressHashMode = {\n P2PKH: 0x00,\n P2SH: 0x01,\n P2WPKH: 0x02,\n P2WSH: 0x03,\n P2SH_NonSequential: 0x05, // SIP-027\n P2WSH_P2SH_NonSequential: 0x07, // SIP-027\n} as const;\nexport type AddressHashMode = (typeof AddressHashMode)[keyof typeof AddressHashMode];\n\n// Pub key encoding\nexport const PubKeyEncoding = {\n Compressed: 0x00,\n Uncompressed: 0x01,\n} as const;\nexport type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];\n\n// Fungible condition codes (wire format)\nexport const FungibleConditionCode = {\n Equal: 0x01,\n Greater: 0x02,\n GreaterEqual: 0x03,\n Less: 0x04,\n LessEqual: 0x05,\n} as const;\n\n// Non-fungible condition codes (wire format)\nexport const NonFungibleConditionCode = {\n Sends: 0x10,\n DoesNotSend: 0x11,\n} as const;\n\n// Post condition principal types\nexport const PostConditionPrincipalId = {\n Origin: 0x01,\n Standard: 0x02,\n Contract: 0x03,\n} as const;\n\n// Post condition asset types\nexport const AssetType = {\n STX: 0x00,\n Fungible: 0x01,\n NonFungible: 0x02,\n} as const;\n\n// Auth field types\nexport const AuthFieldType = {\n PublicKeyCompressed: 0x00,\n PublicKeyUncompressed: 0x01,\n SignatureCompressed: 0x02,\n SignatureUncompressed: 0x03,\n} as const;\n\nexport const RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;\nexport const MEMO_MAX_LENGTH_BYTES = 34;\nexport const MAX_STRING_LENGTH_BYTES = 128;\n\n// Token transfer payload\nexport type TokenTransferPayload = {\n payloadType: typeof PayloadType.TokenTransfer;\n recipient: ClarityValue; // PrincipalCV\n amount: bigint;\n memo: string;\n};\n\n// Contract call payload\nexport type ContractCallPayload = {\n payloadType: typeof PayloadType.ContractCall;\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n};\n\n// Smart contract deploy payload\nexport type SmartContractPayload = {\n payloadType: typeof PayloadType.SmartContract | typeof PayloadType.VersionedSmartContract;\n clarityVersion?: ClarityVersion;\n contractName: string;\n codeBody: string;\n};\n\nexport type TransactionPayload =\n | TokenTransferPayload\n | ContractCallPayload\n | SmartContractPayload;\n\n// Spending condition\nexport type SingleSigSpendingCondition = {\n hashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH;\n signer: string; // hash160 hex\n nonce: bigint;\n fee: bigint;\n keyEncoding: PubKeyEncoding;\n signature: string; // 65-byte recoverable sig hex\n};\n\nexport type TransactionAuthField = {\n pubKeyEncoding: PubKeyEncoding;\n type: \"publicKey\" | \"signature\";\n data: string; // hex\n};\n\nexport type MultiSigHashMode =\n | typeof AddressHashMode.P2SH\n | typeof AddressHashMode.P2WSH\n | typeof AddressHashMode.P2SH_NonSequential\n | typeof AddressHashMode.P2WSH_P2SH_NonSequential;\n\nexport type MultiSigSpendingCondition = {\n hashMode: MultiSigHashMode;\n signer: string;\n nonce: bigint;\n fee: bigint;\n fields: TransactionAuthField[];\n signaturesRequired: number;\n};\n\nexport type SpendingCondition = SingleSigSpendingCondition | MultiSigSpendingCondition;\n\nexport type StandardAuthorization = {\n authType: typeof AuthType.Standard;\n spendingCondition: SpendingCondition;\n};\n\nexport type SponsoredAuthorization = {\n authType: typeof AuthType.Sponsored;\n spendingCondition: SpendingCondition;\n sponsorSpendingCondition: SpendingCondition;\n};\n\nexport type Authorization = StandardAuthorization | SponsoredAuthorization;\n\n// Full transaction\nexport type StacksTransaction = {\n version: number;\n chainId: number;\n auth: Authorization;\n anchorMode: AnchorMode;\n postConditionMode: PostConditionModeWire;\n postConditions: PostConditionWire[];\n payload: TransactionPayload;\n};\n\n// Wire post condition types\nexport type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;\n\nexport type StxPostConditionWire = {\n type: \"stx\";\n principal: PostConditionPrincipalWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type FtPostConditionWire = {\n type: \"ft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type NftPostConditionWire = {\n type: \"nft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n assetId: ClarityValue;\n};\n\nexport type PostConditionPrincipalWire =\n | { type: \"origin\" }\n | { type: \"standard\"; address: string }\n | { type: \"contract\"; address: string; contractName: string };\n\nexport type AssetInfoWire = {\n address: string;\n contractName: string;\n assetName: string;\n};\n",
8
+ "import {\n bytesToHex,\n hexToBytes,\n concatBytes,\n intToBytes,\n intToHex,\n utf8ToBytes,\n asciiToBytes,\n writeUInt32BE,\n writeUInt16BE,\n writeUInt8,\n} from \"../../utils/encoding.ts\";\nimport { c32addressDecode } from \"../../utils/c32.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport {\n AuthType,\n PayloadType,\n PostConditionPrincipalId,\n AssetType,\n RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n MEMO_MAX_LENGTH_BYTES,\n type StacksTransaction,\n type Authorization,\n type SpendingCondition,\n type SingleSigSpendingCondition,\n type MultiSigSpendingCondition,\n type TransactionPayload,\n type PostConditionWire,\n type PostConditionPrincipalWire,\n type AssetInfoWire,\n type TransactionAuthField,\n type AuthFieldType,\n} from \"../types.ts\";\n\n// Address serialization: version (1 byte) + hash160 (20 bytes)\nfunction serializeAddress(c32Address: string): Uint8Array {\n const [version, hash160] = c32addressDecode(c32Address);\n return concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\n// LP string: length prefix (n bytes) + content bytes\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n const content = utf8ToBytes(str);\n const prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n return concatBytes(prefix, content);\n}\n\n// LP string for code body (4-byte prefix)\nfunction serializeLPStringLong(str: string): Uint8Array {\n return serializeLPString(str, 4);\n}\n\n// Memo: padded to MEMO_MAX_LENGTH_BYTES\nfunction serializeMemo(memo: string): Uint8Array {\n const content = asciiToBytes(memo);\n const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);\n padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));\n return concatBytes(writeUInt8(content.length), padded);\n}\n\nfunction serializeSpendingCondition(condition: SpendingCondition): Uint8Array {\n const parts: Uint8Array[] = [\n writeUInt8(condition.hashMode),\n hexToBytes(condition.signer), // 20 bytes\n intToBytes(condition.nonce, 8),\n intToBytes(condition.fee, 8),\n ];\n\n if (\"signature\" in condition) {\n // Single sig\n const sc = condition as SingleSigSpendingCondition;\n parts.push(writeUInt8(sc.keyEncoding));\n parts.push(hexToBytes(sc.signature)); // 65 bytes\n } else {\n // Multi sig\n const mc = condition as MultiSigSpendingCondition;\n // Fields as LP list\n parts.push(writeUInt32BE(mc.fields.length));\n for (const field of mc.fields) {\n parts.push(serializeAuthField(field));\n }\n parts.push(writeUInt16BE(mc.signaturesRequired));\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializeAuthField(field: TransactionAuthField): Uint8Array {\n if (field.type === \"publicKey\") {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x00 : 0x01;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n } else {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x02 : 0x03;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n }\n}\n\nfunction serializeAuthorization(auth: Authorization): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(auth.authType)];\n parts.push(serializeSpendingCondition(auth.spendingCondition));\n if (auth.authType === AuthType.Sponsored) {\n parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));\n }\n return concatBytes(...parts);\n}\n\nfunction serializePrincipal(principal: PostConditionPrincipalWire): Uint8Array {\n switch (principal.type) {\n case \"origin\":\n return writeUInt8(PostConditionPrincipalId.Origin);\n case \"standard\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Standard),\n serializeAddress(principal.address)\n );\n case \"contract\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Contract),\n serializeAddress(principal.address),\n serializeLPString(principal.contractName)\n );\n }\n}\n\nfunction serializeAssetInfo(asset: AssetInfoWire): Uint8Array {\n return concatBytes(\n serializeAddress(asset.address),\n serializeLPString(asset.contractName),\n serializeLPString(asset.assetName)\n );\n}\n\nfunction serializePostCondition(pc: PostConditionWire): Uint8Array {\n const parts: Uint8Array[] = [serializePrincipal(pc.principal)];\n\n switch (pc.type) {\n case \"stx\":\n parts.push(writeUInt8(AssetType.STX));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"ft\":\n parts.push(writeUInt8(AssetType.Fungible));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"nft\":\n parts.push(writeUInt8(AssetType.NonFungible));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(serializeCVBytes(pc.assetId));\n parts.push(writeUInt8(pc.conditionCode));\n break;\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializePostConditions(pcs: PostConditionWire[]): Uint8Array {\n const parts: Uint8Array[] = [writeUInt32BE(pcs.length)];\n for (const pc of pcs) {\n parts.push(serializePostCondition(pc));\n }\n return concatBytes(...parts);\n}\n\nexport function serializePayload(payload: TransactionPayload): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(payload.payloadType)];\n\n switch (payload.payloadType) {\n case PayloadType.TokenTransfer:\n parts.push(serializeCVBytes(payload.recipient));\n parts.push(intToBytes(payload.amount, 8));\n parts.push(serializeMemo(payload.memo));\n break;\n\n case PayloadType.ContractCall:\n parts.push(serializeAddress(payload.contractAddress));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPString(payload.functionName));\n parts.push(writeUInt32BE(payload.functionArgs.length));\n for (const arg of payload.functionArgs) {\n parts.push(serializeCVBytes(arg));\n }\n break;\n\n case PayloadType.SmartContract:\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n\n case PayloadType.VersionedSmartContract:\n parts.push(writeUInt8(payload.clarityVersion ?? 2));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n }\n\n return concatBytes(...parts);\n}\n\nexport function serializeTransaction(tx: StacksTransaction): Uint8Array {\n return concatBytes(\n writeUInt8(tx.version),\n writeUInt32BE(tx.chainId),\n serializeAuthorization(tx.auth),\n writeUInt8(tx.anchorMode),\n writeUInt8(tx.postConditionMode),\n serializePostConditions(tx.postConditions),\n serializePayload(tx.payload)\n );\n}\n\nexport function serializeTransactionHex(tx: StacksTransaction): string {\n return bytesToHex(serializeTransaction(tx));\n}\n"
9
+ ],
10
+ "mappings": ";AAGO,IAHP;;;ACIO,IAJP;AAKqB,IAArB;AACuB,IAAvB;;;ACHO,IAAM,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AACb;AAIO,IAAM,cAAc;AAAA,EACzB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,kBAAkB;AACpB;AAIO,IAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;AAIO,IAAM,aAAa;AAAA,EACxB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,KAAK;AACP;AAIO,IAAM,wBAAwB;AAAA,EACnC,OAAO;AAAA,EACP,MAAM;AACR;AAKO,IAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAIO,IAAM,iBAAiB;AAAA,EAC5B,YAAY;AAAA,EACZ,cAAc;AAChB;AAIO,IAAM,wBAAwB;AAAA,EACnC,OAAO;AAAA,EACP,SAAS;AAAA,EACT,cAAc;AAAA,EACd,MAAM;AAAA,EACN,WAAW;AACb;AAGO,IAAM,2BAA2B;AAAA,EACtC,OAAO;AAAA,EACP,aAAa;AACf;AAGO,IAAM,2BAA2B;AA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