@opcat-labs/scrypt-ts-opcat 1.0.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.
Files changed (537) hide show
  1. package/assets/.templates/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt.map +1 -0
  2. package/assets/.templates/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt.tpl +18 -0
  3. package/assets/.templates/smart-contract/builtin-libs/TxHashPreimageUtils.transformer.json +7 -0
  4. package/assets/.templates/smart-contract/builtin-libs/backtrace.scrypt.map +1 -0
  5. package/assets/.templates/smart-contract/builtin-libs/backtrace.scrypt.tpl +36 -0
  6. package/assets/.templates/smart-contract/builtin-libs/backtrace.transformer.json +7 -0
  7. package/assets/.templates/smart-contract/builtin-libs/byteStringReader.scrypt.map +1 -0
  8. package/assets/.templates/smart-contract/builtin-libs/byteStringReader.scrypt.tpl +64 -0
  9. package/assets/.templates/smart-contract/builtin-libs/byteStringReader.transformer.json +7 -0
  10. package/assets/.templates/smart-contract/builtin-libs/byteStringWriter.scrypt.map +1 -0
  11. package/assets/.templates/smart-contract/builtin-libs/byteStringWriter.scrypt.tpl +48 -0
  12. package/assets/.templates/smart-contract/builtin-libs/byteStringWriter.transformer.json +7 -0
  13. package/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.map +1 -0
  14. package/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl +101 -0
  15. package/assets/.templates/smart-contract/builtin-libs/contextUtils.transformer.json +7 -0
  16. package/assets/.templates/smart-contract/builtin-libs/p2pk.scrypt.map +1 -0
  17. package/assets/.templates/smart-contract/builtin-libs/p2pk.scrypt.tpl +7 -0
  18. package/assets/.templates/smart-contract/builtin-libs/p2pk.transformer.json +7 -0
  19. package/assets/.templates/smart-contract/builtin-libs/p2pkh.scrypt.map +1 -0
  20. package/assets/.templates/smart-contract/builtin-libs/p2pkh.scrypt.tpl +8 -0
  21. package/assets/.templates/smart-contract/builtin-libs/p2pkh.transformer.json +7 -0
  22. package/assets/.templates/smart-contract/builtin-libs/stateLib.scrypt.map +1 -0
  23. package/assets/.templates/smart-contract/builtin-libs/stateLib.scrypt.tpl +3 -0
  24. package/assets/.templates/smart-contract/builtin-libs/stateLib.transformer.json +7 -0
  25. package/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.map +1 -0
  26. package/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.tpl +7 -0
  27. package/assets/.templates/smart-contract/builtin-libs/stateUtils.transformer.json +7 -0
  28. package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.map +1 -0
  29. package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.tpl +89 -0
  30. package/assets/.templates/smart-contract/builtin-libs/stdUtils.transformer.json +7 -0
  31. package/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.map +1 -0
  32. package/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl +42 -0
  33. package/assets/.templates/smart-contract/builtin-libs/txUtils.transformer.json +7 -0
  34. package/assets/.templates/smart-contract/types/structs.scrypt.map +1 -0
  35. package/assets/.templates/smart-contract/types/structs.scrypt.tpl +48 -0
  36. package/assets/.templates/smart-contract/types/structs.transformer.json +7 -0
  37. package/assets/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt +20 -0
  38. package/assets/smart-contract/builtin-libs/backtrace.scrypt +38 -0
  39. package/assets/smart-contract/builtin-libs/byteStringReader.scrypt +66 -0
  40. package/assets/smart-contract/builtin-libs/byteStringWriter.scrypt +50 -0
  41. package/assets/smart-contract/builtin-libs/contextUtils.scrypt +103 -0
  42. package/assets/smart-contract/builtin-libs/p2pk.scrypt +9 -0
  43. package/assets/smart-contract/builtin-libs/p2pkh.scrypt +10 -0
  44. package/assets/smart-contract/builtin-libs/stateLib.scrypt +5 -0
  45. package/assets/smart-contract/builtin-libs/stateUtils.scrypt +9 -0
  46. package/assets/smart-contract/builtin-libs/stdUtils.scrypt +91 -0
  47. package/assets/smart-contract/builtin-libs/txUtils.scrypt +44 -0
  48. package/assets/smart-contract/types/structs.scrypt +50 -0
  49. package/dist/cjs/features/call.cjs +38 -0
  50. package/dist/cjs/features/call.js.map +1 -0
  51. package/dist/cjs/features/deploy.cjs +33 -0
  52. package/dist/cjs/features/deploy.js.map +1 -0
  53. package/dist/cjs/features/index.cjs +8 -0
  54. package/dist/cjs/features/index.js.map +1 -0
  55. package/dist/cjs/globalTypes.cjs +3 -0
  56. package/dist/cjs/globalTypes.js.map +1 -0
  57. package/dist/cjs/index.cjs +55 -0
  58. package/dist/cjs/index.js.map +1 -0
  59. package/dist/cjs/networks.cjs +69 -0
  60. package/dist/cjs/networks.js.map +1 -0
  61. package/dist/cjs/providers/chainProvider.cjs +3 -0
  62. package/dist/cjs/providers/chainProvider.js.map +1 -0
  63. package/dist/cjs/providers/dummyProvider.cjs +87 -0
  64. package/dist/cjs/providers/dummyProvider.js.map +1 -0
  65. package/dist/cjs/providers/index.cjs +13 -0
  66. package/dist/cjs/providers/index.js.map +1 -0
  67. package/dist/cjs/providers/mempoolProvider.cjs +207 -0
  68. package/dist/cjs/providers/mempoolProvider.js.map +1 -0
  69. package/dist/cjs/providers/rpcProvider.cjs +296 -0
  70. package/dist/cjs/providers/rpcProvider.js.map +1 -0
  71. package/dist/cjs/providers/utxoProvider.cjs +18 -0
  72. package/dist/cjs/providers/utxoProvider.js.map +1 -0
  73. package/dist/cjs/psbt/bip66.cjs +182 -0
  74. package/dist/cjs/psbt/bip66.js.map +1 -0
  75. package/dist/cjs/psbt/bufferutils.cjs +186 -0
  76. package/dist/cjs/psbt/bufferutils.js.map +1 -0
  77. package/dist/cjs/psbt/contextProvider.cjs +111 -0
  78. package/dist/cjs/psbt/contextProvider.js.map +1 -0
  79. package/dist/cjs/psbt/extPsbt.cjs +589 -0
  80. package/dist/cjs/psbt/extPsbt.js.map +1 -0
  81. package/dist/cjs/psbt/psbt.cjs +973 -0
  82. package/dist/cjs/psbt/psbt.js.map +1 -0
  83. package/dist/cjs/psbt/psbtutils.cjs +140 -0
  84. package/dist/cjs/psbt/psbtutils.js.map +1 -0
  85. package/dist/cjs/psbt/signatureutils.cjs +230 -0
  86. package/dist/cjs/psbt/signatureutils.js.map +1 -0
  87. package/dist/cjs/psbt/types.cjs +3 -0
  88. package/dist/cjs/psbt/types.js.map +1 -0
  89. package/dist/cjs/signer.cjs +3 -0
  90. package/dist/cjs/signer.js.map +1 -0
  91. package/dist/cjs/signers/defaultSigner.cjs +68 -0
  92. package/dist/cjs/signers/defaultSigner.js.map +1 -0
  93. package/dist/cjs/signers/index.cjs +8 -0
  94. package/dist/cjs/signers/index.js.map +1 -0
  95. package/dist/cjs/signers/unisatSigner.cjs +38 -0
  96. package/dist/cjs/signers/unisatSigner.js.map +1 -0
  97. package/dist/cjs/smart-contract/abi.cjs +380 -0
  98. package/dist/cjs/smart-contract/abi.js.map +1 -0
  99. package/dist/cjs/smart-contract/abiutils.cjs +183 -0
  100. package/dist/cjs/smart-contract/abiutils.js.map +1 -0
  101. package/dist/cjs/smart-contract/abstractContract.cjs +25 -0
  102. package/dist/cjs/smart-contract/abstractContract.js.map +1 -0
  103. package/dist/cjs/smart-contract/builtin-libs/backtrace.cjs +102 -0
  104. package/dist/cjs/smart-contract/builtin-libs/backtrace.js.map +1 -0
  105. package/dist/cjs/smart-contract/builtin-libs/byteStringReader.cjs +138 -0
  106. package/dist/cjs/smart-contract/builtin-libs/byteStringReader.js.map +1 -0
  107. package/dist/cjs/smart-contract/builtin-libs/byteStringWriter.cjs +109 -0
  108. package/dist/cjs/smart-contract/builtin-libs/byteStringWriter.js.map +1 -0
  109. package/dist/cjs/smart-contract/builtin-libs/contextUtils.cjs +304 -0
  110. package/dist/cjs/smart-contract/builtin-libs/contextUtils.js.map +1 -0
  111. package/dist/cjs/smart-contract/builtin-libs/index.cjs +18 -0
  112. package/dist/cjs/smart-contract/builtin-libs/index.js.map +1 -0
  113. package/dist/cjs/smart-contract/builtin-libs/p2pk.cjs +74 -0
  114. package/dist/cjs/smart-contract/builtin-libs/p2pk.js.map +1 -0
  115. package/dist/cjs/smart-contract/builtin-libs/p2pkh.cjs +80 -0
  116. package/dist/cjs/smart-contract/builtin-libs/p2pkh.js.map +1 -0
  117. package/dist/cjs/smart-contract/builtin-libs/stateLib.cjs +65 -0
  118. package/dist/cjs/smart-contract/builtin-libs/stateLib.js.map +1 -0
  119. package/dist/cjs/smart-contract/builtin-libs/stateUtils.cjs +42 -0
  120. package/dist/cjs/smart-contract/builtin-libs/stateUtils.js.map +1 -0
  121. package/dist/cjs/smart-contract/builtin-libs/stdUtils.cjs +192 -0
  122. package/dist/cjs/smart-contract/builtin-libs/stdUtils.js.map +1 -0
  123. package/dist/cjs/smart-contract/builtin-libs/txHashPreimageUtils.cjs +56 -0
  124. package/dist/cjs/smart-contract/builtin-libs/txHashPreimageUtils.js.map +1 -0
  125. package/dist/cjs/smart-contract/builtin-libs/txUtils.cjs +183 -0
  126. package/dist/cjs/smart-contract/builtin-libs/txUtils.js.map +1 -0
  127. package/dist/cjs/smart-contract/consts.cjs +100 -0
  128. package/dist/cjs/smart-contract/consts.js.map +1 -0
  129. package/dist/cjs/smart-contract/decorators.cjs +83 -0
  130. package/dist/cjs/smart-contract/decorators.js.map +1 -0
  131. package/dist/cjs/smart-contract/fns/assert.cjs +17 -0
  132. package/dist/cjs/smart-contract/fns/assert.js.map +1 -0
  133. package/dist/cjs/smart-contract/fns/bitwise.cjs +141 -0
  134. package/dist/cjs/smart-contract/fns/bitwise.js.map +1 -0
  135. package/dist/cjs/smart-contract/fns/byteString.cjs +106 -0
  136. package/dist/cjs/smart-contract/fns/byteString.js.map +1 -0
  137. package/dist/cjs/smart-contract/fns/equals.cjs +66 -0
  138. package/dist/cjs/smart-contract/fns/equals.js.map +1 -0
  139. package/dist/cjs/smart-contract/fns/fill.cjs +19 -0
  140. package/dist/cjs/smart-contract/fns/fill.js.map +1 -0
  141. package/dist/cjs/smart-contract/fns/hashes.cjs +81 -0
  142. package/dist/cjs/smart-contract/fns/hashes.js.map +1 -0
  143. package/dist/cjs/smart-contract/fns/index.cjs +37 -0
  144. package/dist/cjs/smart-contract/fns/index.js.map +1 -0
  145. package/dist/cjs/smart-contract/fns/math.cjs +52 -0
  146. package/dist/cjs/smart-contract/fns/math.js.map +1 -0
  147. package/dist/cjs/smart-contract/fns/pubKey2Addr.cjs +17 -0
  148. package/dist/cjs/smart-contract/fns/pubKey2Addr.js.map +1 -0
  149. package/dist/cjs/smart-contract/methods/backtraceToGenensis.cjs +41 -0
  150. package/dist/cjs/smart-contract/methods/backtraceToGenensis.js.map +1 -0
  151. package/dist/cjs/smart-contract/methods/buildOutput.cjs +41 -0
  152. package/dist/cjs/smart-contract/methods/buildOutput.js.map +1 -0
  153. package/dist/cjs/smart-contract/methods/checkCtx.cjs +58 -0
  154. package/dist/cjs/smart-contract/methods/checkCtx.js.map +1 -0
  155. package/dist/cjs/smart-contract/methods/checkInputState.cjs +16 -0
  156. package/dist/cjs/smart-contract/methods/checkInputState.js.map +1 -0
  157. package/dist/cjs/smart-contract/methods/checkInputStateHashes.cjs +16 -0
  158. package/dist/cjs/smart-contract/methods/checkInputStateHashes.js.map +1 -0
  159. package/dist/cjs/smart-contract/methods/checkSHPreimage.cjs +17 -0
  160. package/dist/cjs/smart-contract/methods/checkSHPreimage.js.map +1 -0
  161. package/dist/cjs/smart-contract/methods/checkSig.cjs +77 -0
  162. package/dist/cjs/smart-contract/methods/checkSig.js.map +1 -0
  163. package/dist/cjs/smart-contract/serializer.cjs +145 -0
  164. package/dist/cjs/smart-contract/serializer.js.map +1 -0
  165. package/dist/cjs/smart-contract/smartContract.cjs +568 -0
  166. package/dist/cjs/smart-contract/smartContract.js.map +1 -0
  167. package/dist/cjs/smart-contract/smartContractLib.cjs +46 -0
  168. package/dist/cjs/smart-contract/smartContractLib.js.map +1 -0
  169. package/dist/cjs/smart-contract/stateSerializer.cjs +134 -0
  170. package/dist/cjs/smart-contract/stateSerializer.js.map +1 -0
  171. package/dist/cjs/smart-contract/types/abi.cjs +69 -0
  172. package/dist/cjs/smart-contract/types/abi.js.map +1 -0
  173. package/dist/cjs/smart-contract/types/artifact.cjs +16 -0
  174. package/dist/cjs/smart-contract/types/artifact.js.map +1 -0
  175. package/dist/cjs/smart-contract/types/bn.cjs +117 -0
  176. package/dist/cjs/smart-contract/types/bn.js.map +1 -0
  177. package/dist/cjs/smart-contract/types/context.cjs +3 -0
  178. package/dist/cjs/smart-contract/types/context.js.map +1 -0
  179. package/dist/cjs/smart-contract/types/index.cjs +16 -0
  180. package/dist/cjs/smart-contract/types/index.js.map +1 -0
  181. package/dist/cjs/smart-contract/types/opCode.cjs +754 -0
  182. package/dist/cjs/smart-contract/types/opCode.js.map +1 -0
  183. package/dist/cjs/smart-contract/types/primitives.cjs +108 -0
  184. package/dist/cjs/smart-contract/types/primitives.js.map +1 -0
  185. package/dist/cjs/smart-contract/types/script.cjs +43 -0
  186. package/dist/cjs/smart-contract/types/script.js.map +1 -0
  187. package/dist/cjs/smart-contract/types/structs.cjs +3 -0
  188. package/dist/cjs/smart-contract/types/structs.js.map +1 -0
  189. package/dist/cjs/smart-contract/types/utils.cjs +21 -0
  190. package/dist/cjs/smart-contract/types/utils.js.map +1 -0
  191. package/dist/cjs/utils/bvm.cjs +30 -0
  192. package/dist/cjs/utils/bvm.js.map +1 -0
  193. package/dist/cjs/utils/checkIntegrity.cjs +49 -0
  194. package/dist/cjs/utils/checkIntegrity.js.map +1 -0
  195. package/dist/cjs/utils/common.cjs +228 -0
  196. package/dist/cjs/utils/common.js.map +1 -0
  197. package/dist/cjs/utils/constants.cjs +5 -0
  198. package/dist/cjs/utils/constants.js.map +1 -0
  199. package/dist/cjs/utils/index.cjs +45 -0
  200. package/dist/cjs/utils/index.js.map +1 -0
  201. package/dist/cjs/utils/preimage.cjs +93 -0
  202. package/dist/cjs/utils/preimage.js.map +1 -0
  203. package/dist/cjs/utils/proof.cjs +110 -0
  204. package/dist/cjs/utils/proof.js.map +1 -0
  205. package/dist/cjs/utils/script_number.cjs +107 -0
  206. package/dist/cjs/utils/script_number.js.map +1 -0
  207. package/dist/esm/features/call.js +34 -0
  208. package/dist/esm/features/call.js.map +1 -0
  209. package/dist/esm/features/deploy.js +29 -0
  210. package/dist/esm/features/deploy.js.map +1 -0
  211. package/dist/esm/features/index.js +3 -0
  212. package/dist/esm/features/index.js.map +1 -0
  213. package/dist/esm/globalTypes.js +2 -0
  214. package/dist/esm/globalTypes.js.map +1 -0
  215. package/dist/esm/index.js +23 -0
  216. package/dist/esm/index.js.map +1 -0
  217. package/dist/esm/networks.js +41 -0
  218. package/dist/esm/networks.js.map +1 -0
  219. package/dist/esm/providers/chainProvider.js +2 -0
  220. package/dist/esm/providers/chainProvider.js.map +1 -0
  221. package/dist/esm/providers/dummyProvider.js +60 -0
  222. package/dist/esm/providers/dummyProvider.js.map +1 -0
  223. package/dist/esm/providers/index.js +5 -0
  224. package/dist/esm/providers/index.js.map +1 -0
  225. package/dist/esm/providers/mempoolProvider.js +200 -0
  226. package/dist/esm/providers/mempoolProvider.js.map +1 -0
  227. package/dist/esm/providers/rpcProvider.js +266 -0
  228. package/dist/esm/providers/rpcProvider.js.map +1 -0
  229. package/dist/esm/providers/utxoProvider.js +13 -0
  230. package/dist/esm/providers/utxoProvider.js.map +1 -0
  231. package/dist/esm/psbt/bip66.js +175 -0
  232. package/dist/esm/psbt/bip66.js.map +1 -0
  233. package/dist/esm/psbt/bufferutils.js +156 -0
  234. package/dist/esm/psbt/bufferutils.js.map +1 -0
  235. package/dist/esm/psbt/contextProvider.js +84 -0
  236. package/dist/esm/psbt/contextProvider.js.map +1 -0
  237. package/dist/esm/psbt/extPsbt.js +562 -0
  238. package/dist/esm/psbt/extPsbt.js.map +1 -0
  239. package/dist/esm/psbt/psbt.js +945 -0
  240. package/dist/esm/psbt/psbt.js.map +1 -0
  241. package/dist/esm/psbt/psbtutils.js +110 -0
  242. package/dist/esm/psbt/psbtutils.js.map +1 -0
  243. package/dist/esm/psbt/signatureutils.js +199 -0
  244. package/dist/esm/psbt/signatureutils.js.map +1 -0
  245. package/dist/esm/psbt/types.js +2 -0
  246. package/dist/esm/psbt/types.js.map +1 -0
  247. package/dist/esm/signer.js +2 -0
  248. package/dist/esm/signer.js.map +1 -0
  249. package/dist/esm/signers/defaultSigner.js +63 -0
  250. package/dist/esm/signers/defaultSigner.js.map +1 -0
  251. package/dist/esm/signers/index.js +3 -0
  252. package/dist/esm/signers/index.js.map +1 -0
  253. package/dist/esm/signers/unisatSigner.js +34 -0
  254. package/dist/esm/signers/unisatSigner.js.map +1 -0
  255. package/dist/esm/smart-contract/abi.js +373 -0
  256. package/dist/esm/smart-contract/abi.js.map +1 -0
  257. package/dist/esm/smart-contract/abiutils.js +171 -0
  258. package/dist/esm/smart-contract/abiutils.js.map +1 -0
  259. package/dist/esm/smart-contract/abstractContract.js +21 -0
  260. package/dist/esm/smart-contract/abstractContract.js.map +1 -0
  261. package/dist/esm/smart-contract/builtin-libs/backtrace.js +98 -0
  262. package/dist/esm/smart-contract/builtin-libs/backtrace.js.map +1 -0
  263. package/dist/esm/smart-contract/builtin-libs/byteStringReader.js +134 -0
  264. package/dist/esm/smart-contract/builtin-libs/byteStringReader.js.map +1 -0
  265. package/dist/esm/smart-contract/builtin-libs/byteStringWriter.js +105 -0
  266. package/dist/esm/smart-contract/builtin-libs/byteStringWriter.js.map +1 -0
  267. package/dist/esm/smart-contract/builtin-libs/contextUtils.js +300 -0
  268. package/dist/esm/smart-contract/builtin-libs/contextUtils.js.map +1 -0
  269. package/dist/esm/smart-contract/builtin-libs/index.js +8 -0
  270. package/dist/esm/smart-contract/builtin-libs/index.js.map +1 -0
  271. package/dist/esm/smart-contract/builtin-libs/p2pk.js +70 -0
  272. package/dist/esm/smart-contract/builtin-libs/p2pk.js.map +1 -0
  273. package/dist/esm/smart-contract/builtin-libs/p2pkh.js +76 -0
  274. package/dist/esm/smart-contract/builtin-libs/p2pkh.js.map +1 -0
  275. package/dist/esm/smart-contract/builtin-libs/stateLib.js +61 -0
  276. package/dist/esm/smart-contract/builtin-libs/stateLib.js.map +1 -0
  277. package/dist/esm/smart-contract/builtin-libs/stateUtils.js +38 -0
  278. package/dist/esm/smart-contract/builtin-libs/stateUtils.js.map +1 -0
  279. package/dist/esm/smart-contract/builtin-libs/stdUtils.js +188 -0
  280. package/dist/esm/smart-contract/builtin-libs/stdUtils.js.map +1 -0
  281. package/dist/esm/smart-contract/builtin-libs/txHashPreimageUtils.js +52 -0
  282. package/dist/esm/smart-contract/builtin-libs/txHashPreimageUtils.js.map +1 -0
  283. package/dist/esm/smart-contract/builtin-libs/txUtils.js +179 -0
  284. package/dist/esm/smart-contract/builtin-libs/txUtils.js.map +1 -0
  285. package/dist/esm/smart-contract/consts.js +97 -0
  286. package/dist/esm/smart-contract/consts.js.map +1 -0
  287. package/dist/esm/smart-contract/decorators.js +78 -0
  288. package/dist/esm/smart-contract/decorators.js.map +1 -0
  289. package/dist/esm/smart-contract/fns/assert.js +13 -0
  290. package/dist/esm/smart-contract/fns/assert.js.map +1 -0
  291. package/dist/esm/smart-contract/fns/bitwise.js +109 -0
  292. package/dist/esm/smart-contract/fns/bitwise.js.map +1 -0
  293. package/dist/esm/smart-contract/fns/byteString.js +97 -0
  294. package/dist/esm/smart-contract/fns/byteString.js.map +1 -0
  295. package/dist/esm/smart-contract/fns/equals.js +62 -0
  296. package/dist/esm/smart-contract/fns/equals.js.map +1 -0
  297. package/dist/esm/smart-contract/fns/fill.js +15 -0
  298. package/dist/esm/smart-contract/fns/fill.js.map +1 -0
  299. package/dist/esm/smart-contract/fns/hashes.js +73 -0
  300. package/dist/esm/smart-contract/fns/hashes.js.map +1 -0
  301. package/dist/esm/smart-contract/fns/index.js +9 -0
  302. package/dist/esm/smart-contract/fns/index.js.map +1 -0
  303. package/dist/esm/smart-contract/fns/math.js +45 -0
  304. package/dist/esm/smart-contract/fns/math.js.map +1 -0
  305. package/dist/esm/smart-contract/fns/pubKey2Addr.js +13 -0
  306. package/dist/esm/smart-contract/fns/pubKey2Addr.js.map +1 -0
  307. package/dist/esm/smart-contract/methods/backtraceToGenensis.js +36 -0
  308. package/dist/esm/smart-contract/methods/backtraceToGenensis.js.map +1 -0
  309. package/dist/esm/smart-contract/methods/buildOutput.js +36 -0
  310. package/dist/esm/smart-contract/methods/buildOutput.js.map +1 -0
  311. package/dist/esm/smart-contract/methods/checkCtx.js +31 -0
  312. package/dist/esm/smart-contract/methods/checkCtx.js.map +1 -0
  313. package/dist/esm/smart-contract/methods/checkInputState.js +12 -0
  314. package/dist/esm/smart-contract/methods/checkInputState.js.map +1 -0
  315. package/dist/esm/smart-contract/methods/checkInputStateHashes.js +12 -0
  316. package/dist/esm/smart-contract/methods/checkInputStateHashes.js.map +1 -0
  317. package/dist/esm/smart-contract/methods/checkSHPreimage.js +13 -0
  318. package/dist/esm/smart-contract/methods/checkSHPreimage.js.map +1 -0
  319. package/dist/esm/smart-contract/methods/checkSig.js +73 -0
  320. package/dist/esm/smart-contract/methods/checkSig.js.map +1 -0
  321. package/dist/esm/smart-contract/serializer.js +112 -0
  322. package/dist/esm/smart-contract/serializer.js.map +1 -0
  323. package/dist/esm/smart-contract/smartContract.js +564 -0
  324. package/dist/esm/smart-contract/smartContract.js.map +1 -0
  325. package/dist/esm/smart-contract/smartContractLib.js +42 -0
  326. package/dist/esm/smart-contract/smartContractLib.js.map +1 -0
  327. package/dist/esm/smart-contract/stateSerializer.js +129 -0
  328. package/dist/esm/smart-contract/stateSerializer.js.map +1 -0
  329. package/dist/esm/smart-contract/types/abi.js +63 -0
  330. package/dist/esm/smart-contract/types/abi.js.map +1 -0
  331. package/dist/esm/smart-contract/types/artifact.js +13 -0
  332. package/dist/esm/smart-contract/types/artifact.js.map +1 -0
  333. package/dist/esm/smart-contract/types/bn.js +89 -0
  334. package/dist/esm/smart-contract/types/bn.js.map +1 -0
  335. package/dist/esm/smart-contract/types/context.js +2 -0
  336. package/dist/esm/smart-contract/types/context.js.map +1 -0
  337. package/dist/esm/smart-contract/types/index.js +3 -0
  338. package/dist/esm/smart-contract/types/index.js.map +1 -0
  339. package/dist/esm/smart-contract/types/opCode.js +750 -0
  340. package/dist/esm/smart-contract/types/opCode.js.map +1 -0
  341. package/dist/esm/smart-contract/types/primitives.js +95 -0
  342. package/dist/esm/smart-contract/types/primitives.js.map +1 -0
  343. package/dist/esm/smart-contract/types/script.js +16 -0
  344. package/dist/esm/smart-contract/types/script.js.map +1 -0
  345. package/dist/esm/smart-contract/types/structs.js +2 -0
  346. package/dist/esm/smart-contract/types/structs.js.map +1 -0
  347. package/dist/esm/smart-contract/types/utils.js +17 -0
  348. package/dist/esm/smart-contract/types/utils.js.map +1 -0
  349. package/dist/esm/utils/bvm.js +26 -0
  350. package/dist/esm/utils/bvm.js.map +1 -0
  351. package/dist/esm/utils/checkIntegrity.js +41 -0
  352. package/dist/esm/utils/checkIntegrity.js.map +1 -0
  353. package/dist/esm/utils/common.js +188 -0
  354. package/dist/esm/utils/common.js.map +1 -0
  355. package/dist/esm/utils/constants.js +2 -0
  356. package/dist/esm/utils/constants.js.map +1 -0
  357. package/dist/esm/utils/index.js +7 -0
  358. package/dist/esm/utils/index.js.map +1 -0
  359. package/dist/esm/utils/preimage.js +65 -0
  360. package/dist/esm/utils/preimage.js.map +1 -0
  361. package/dist/esm/utils/proof.js +98 -0
  362. package/dist/esm/utils/proof.js.map +1 -0
  363. package/dist/esm/utils/script_number.js +79 -0
  364. package/dist/esm/utils/script_number.js.map +1 -0
  365. package/dist/types/features/call.d.ts +21 -0
  366. package/dist/types/features/call.d.ts.map +1 -0
  367. package/dist/types/features/deploy.d.ts +16 -0
  368. package/dist/types/features/deploy.d.ts.map +1 -0
  369. package/dist/types/features/index.d.ts +3 -0
  370. package/dist/types/features/index.d.ts.map +1 -0
  371. package/dist/types/globalTypes.d.ts +37 -0
  372. package/dist/types/globalTypes.d.ts.map +1 -0
  373. package/dist/types/index.d.ts +18 -0
  374. package/dist/types/index.d.ts.map +1 -0
  375. package/dist/types/networks.d.ts +19 -0
  376. package/dist/types/networks.d.ts.map +1 -0
  377. package/dist/types/providers/chainProvider.d.ts +31 -0
  378. package/dist/types/providers/chainProvider.d.ts.map +1 -0
  379. package/dist/types/providers/dummyProvider.d.ts +23 -0
  380. package/dist/types/providers/dummyProvider.d.ts.map +1 -0
  381. package/dist/types/providers/index.d.ts +6 -0
  382. package/dist/types/providers/index.d.ts.map +1 -0
  383. package/dist/types/providers/mempoolProvider.d.ts +28 -0
  384. package/dist/types/providers/mempoolProvider.d.ts.map +1 -0
  385. package/dist/types/providers/rpcProvider.d.ts +34 -0
  386. package/dist/types/providers/rpcProvider.d.ts.map +1 -0
  387. package/dist/types/providers/utxoProvider.d.ts +43 -0
  388. package/dist/types/providers/utxoProvider.d.ts.map +1 -0
  389. package/dist/types/psbt/bip66.d.ts +28 -0
  390. package/dist/types/psbt/bip66.d.ts.map +1 -0
  391. package/dist/types/psbt/bufferutils.d.ts +47 -0
  392. package/dist/types/psbt/bufferutils.d.ts.map +1 -0
  393. package/dist/types/psbt/contextProvider.d.ts +15 -0
  394. package/dist/types/psbt/contextProvider.d.ts.map +1 -0
  395. package/dist/types/psbt/extPsbt.d.ts +131 -0
  396. package/dist/types/psbt/extPsbt.d.ts.map +1 -0
  397. package/dist/types/psbt/psbt.d.ts +194 -0
  398. package/dist/types/psbt/psbt.d.ts.map +1 -0
  399. package/dist/types/psbt/psbtutils.d.ts +37 -0
  400. package/dist/types/psbt/psbtutils.d.ts.map +1 -0
  401. package/dist/types/psbt/signatureutils.d.ts +52 -0
  402. package/dist/types/psbt/signatureutils.d.ts.map +1 -0
  403. package/dist/types/psbt/types.d.ts +63 -0
  404. package/dist/types/psbt/types.d.ts.map +1 -0
  405. package/dist/types/signer.d.ts +48 -0
  406. package/dist/types/signer.d.ts.map +1 -0
  407. package/dist/types/signers/defaultSigner.d.ts +30 -0
  408. package/dist/types/signers/defaultSigner.d.ts.map +1 -0
  409. package/dist/types/signers/index.d.ts +4 -0
  410. package/dist/types/signers/index.d.ts.map +1 -0
  411. package/dist/types/signers/unisatSigner.d.ts +32 -0
  412. package/dist/types/signers/unisatSigner.d.ts.map +1 -0
  413. package/dist/types/smart-contract/abi.d.ts +43 -0
  414. package/dist/types/smart-contract/abi.d.ts.map +1 -0
  415. package/dist/types/smart-contract/abiutils.d.ts +51 -0
  416. package/dist/types/smart-contract/abiutils.d.ts.map +1 -0
  417. package/dist/types/smart-contract/abstractContract.d.ts +115 -0
  418. package/dist/types/smart-contract/abstractContract.d.ts.map +1 -0
  419. package/dist/types/smart-contract/builtin-libs/backtrace.d.ts +43 -0
  420. package/dist/types/smart-contract/builtin-libs/backtrace.d.ts.map +1 -0
  421. package/dist/types/smart-contract/builtin-libs/byteStringReader.d.ts +32 -0
  422. package/dist/types/smart-contract/builtin-libs/byteStringReader.d.ts.map +1 -0
  423. package/dist/types/smart-contract/builtin-libs/byteStringWriter.d.ts +29 -0
  424. package/dist/types/smart-contract/builtin-libs/byteStringWriter.d.ts.map +1 -0
  425. package/dist/types/smart-contract/builtin-libs/contextUtils.d.ts +53 -0
  426. package/dist/types/smart-contract/builtin-libs/contextUtils.d.ts.map +1 -0
  427. package/dist/types/smart-contract/builtin-libs/index.d.ts +8 -0
  428. package/dist/types/smart-contract/builtin-libs/index.d.ts.map +1 -0
  429. package/dist/types/smart-contract/builtin-libs/p2pk.d.ts +8 -0
  430. package/dist/types/smart-contract/builtin-libs/p2pk.d.ts.map +1 -0
  431. package/dist/types/smart-contract/builtin-libs/p2pkh.d.ts +8 -0
  432. package/dist/types/smart-contract/builtin-libs/p2pkh.d.ts.map +1 -0
  433. package/dist/types/smart-contract/builtin-libs/stateLib.d.ts +27 -0
  434. package/dist/types/smart-contract/builtin-libs/stateLib.d.ts.map +1 -0
  435. package/dist/types/smart-contract/builtin-libs/stateUtils.d.ts +18 -0
  436. package/dist/types/smart-contract/builtin-libs/stateUtils.d.ts.map +1 -0
  437. package/dist/types/smart-contract/builtin-libs/stdUtils.d.ts +44 -0
  438. package/dist/types/smart-contract/builtin-libs/stdUtils.d.ts.map +1 -0
  439. package/dist/types/smart-contract/builtin-libs/txHashPreimageUtils.d.ts +8 -0
  440. package/dist/types/smart-contract/builtin-libs/txHashPreimageUtils.d.ts.map +1 -0
  441. package/dist/types/smart-contract/builtin-libs/txUtils.d.ts +69 -0
  442. package/dist/types/smart-contract/builtin-libs/txUtils.d.ts.map +1 -0
  443. package/dist/types/smart-contract/consts.d.ts +97 -0
  444. package/dist/types/smart-contract/consts.d.ts.map +1 -0
  445. package/dist/types/smart-contract/decorators.d.ts +40 -0
  446. package/dist/types/smart-contract/decorators.d.ts.map +1 -0
  447. package/dist/types/smart-contract/fns/assert.d.ts +8 -0
  448. package/dist/types/smart-contract/fns/assert.d.ts.map +1 -0
  449. package/dist/types/smart-contract/fns/bitwise.d.ts +50 -0
  450. package/dist/types/smart-contract/fns/bitwise.d.ts.map +1 -0
  451. package/dist/types/smart-contract/fns/byteString.d.ts +56 -0
  452. package/dist/types/smart-contract/fns/byteString.d.ts.map +1 -0
  453. package/dist/types/smart-contract/fns/equals.d.ts +8 -0
  454. package/dist/types/smart-contract/fns/equals.d.ts.map +1 -0
  455. package/dist/types/smart-contract/fns/fill.d.ts +11 -0
  456. package/dist/types/smart-contract/fns/fill.d.ts.map +1 -0
  457. package/dist/types/smart-contract/fns/hashes.d.ts +60 -0
  458. package/dist/types/smart-contract/fns/hashes.d.ts.map +1 -0
  459. package/dist/types/smart-contract/fns/index.d.ts +9 -0
  460. package/dist/types/smart-contract/fns/index.d.ts.map +1 -0
  461. package/dist/types/smart-contract/fns/math.d.ts +38 -0
  462. package/dist/types/smart-contract/fns/math.d.ts.map +1 -0
  463. package/dist/types/smart-contract/fns/pubKey2Addr.d.ts +11 -0
  464. package/dist/types/smart-contract/fns/pubKey2Addr.d.ts.map +1 -0
  465. package/dist/types/smart-contract/methods/backtraceToGenensis.d.ts +20 -0
  466. package/dist/types/smart-contract/methods/backtraceToGenensis.d.ts.map +1 -0
  467. package/dist/types/smart-contract/methods/buildOutput.d.ts +25 -0
  468. package/dist/types/smart-contract/methods/buildOutput.d.ts.map +1 -0
  469. package/dist/types/smart-contract/methods/checkCtx.d.ts +18 -0
  470. package/dist/types/smart-contract/methods/checkCtx.d.ts.map +1 -0
  471. package/dist/types/smart-contract/methods/checkInputState.d.ts +9 -0
  472. package/dist/types/smart-contract/methods/checkInputState.d.ts.map +1 -0
  473. package/dist/types/smart-contract/methods/checkInputStateHashes.d.ts +10 -0
  474. package/dist/types/smart-contract/methods/checkInputStateHashes.d.ts.map +1 -0
  475. package/dist/types/smart-contract/methods/checkSHPreimage.d.ts +10 -0
  476. package/dist/types/smart-contract/methods/checkSHPreimage.d.ts.map +1 -0
  477. package/dist/types/smart-contract/methods/checkSig.d.ts +11 -0
  478. package/dist/types/smart-contract/methods/checkSig.d.ts.map +1 -0
  479. package/dist/types/smart-contract/serializer.d.ts +48 -0
  480. package/dist/types/smart-contract/serializer.d.ts.map +1 -0
  481. package/dist/types/smart-contract/smartContract.d.ts +274 -0
  482. package/dist/types/smart-contract/smartContract.d.ts.map +1 -0
  483. package/dist/types/smart-contract/smartContractLib.d.ts +26 -0
  484. package/dist/types/smart-contract/smartContractLib.d.ts.map +1 -0
  485. package/dist/types/smart-contract/stateSerializer.d.ts +8 -0
  486. package/dist/types/smart-contract/stateSerializer.d.ts.map +1 -0
  487. package/dist/types/smart-contract/types/abi.d.ts +55 -0
  488. package/dist/types/smart-contract/types/abi.d.ts.map +1 -0
  489. package/dist/types/smart-contract/types/artifact.d.ts +108 -0
  490. package/dist/types/smart-contract/types/artifact.d.ts.map +1 -0
  491. package/dist/types/smart-contract/types/bn.d.ts +3 -0
  492. package/dist/types/smart-contract/types/bn.d.ts.map +1 -0
  493. package/dist/types/smart-contract/types/context.d.ts +126 -0
  494. package/dist/types/smart-contract/types/context.d.ts.map +1 -0
  495. package/dist/types/smart-contract/types/index.d.ts +4 -0
  496. package/dist/types/smart-contract/types/index.d.ts.map +1 -0
  497. package/dist/types/smart-contract/types/opCode.d.ts +747 -0
  498. package/dist/types/smart-contract/types/opCode.d.ts.map +1 -0
  499. package/dist/types/smart-contract/types/primitives.d.ts +217 -0
  500. package/dist/types/smart-contract/types/primitives.d.ts.map +1 -0
  501. package/dist/types/smart-contract/types/script.d.ts +14 -0
  502. package/dist/types/smart-contract/types/script.d.ts.map +1 -0
  503. package/dist/types/smart-contract/types/structs.d.ts +206 -0
  504. package/dist/types/smart-contract/types/structs.d.ts.map +1 -0
  505. package/dist/types/smart-contract/types/utils.d.ts +5 -0
  506. package/dist/types/smart-contract/types/utils.d.ts.map +1 -0
  507. package/dist/types/utils/bvm.d.ts +9 -0
  508. package/dist/types/utils/bvm.d.ts.map +1 -0
  509. package/dist/types/utils/checkIntegrity.d.ts +46 -0
  510. package/dist/types/utils/checkIntegrity.d.ts.map +1 -0
  511. package/dist/types/utils/common.d.ts +61 -0
  512. package/dist/types/utils/common.d.ts.map +1 -0
  513. package/dist/types/utils/constants.d.ts +3 -0
  514. package/dist/types/utils/constants.d.ts.map +1 -0
  515. package/dist/types/utils/index.d.ts +7 -0
  516. package/dist/types/utils/index.d.ts.map +1 -0
  517. package/dist/types/utils/preimage.d.ts +31 -0
  518. package/dist/types/utils/preimage.d.ts.map +1 -0
  519. package/dist/types/utils/proof.d.ts +31 -0
  520. package/dist/types/utils/proof.d.ts.map +1 -0
  521. package/dist/types/utils/script_number.d.ts +19 -0
  522. package/dist/types/utils/script_number.d.ts.map +1 -0
  523. package/package.json +79 -0
  524. package/scrypt.index.json +85 -0
  525. package/src/smart-contract/builtin-libs/backtrace.ts +116 -0
  526. package/src/smart-contract/builtin-libs/byteStringReader.ts +111 -0
  527. package/src/smart-contract/builtin-libs/byteStringWriter.ts +86 -0
  528. package/src/smart-contract/builtin-libs/contextUtils.ts +270 -0
  529. package/src/smart-contract/builtin-libs/index.ts +7 -0
  530. package/src/smart-contract/builtin-libs/p2pk.ts +58 -0
  531. package/src/smart-contract/builtin-libs/p2pkh.ts +67 -0
  532. package/src/smart-contract/builtin-libs/stateLib.ts +82 -0
  533. package/src/smart-contract/builtin-libs/stateUtils.ts +37 -0
  534. package/src/smart-contract/builtin-libs/stdUtils.ts +156 -0
  535. package/src/smart-contract/builtin-libs/txHashPreimageUtils.ts +34 -0
  536. package/src/smart-contract/builtin-libs/txUtils.ts +152 -0
  537. package/src/smart-contract/types/structs.ts +244 -0
@@ -0,0 +1 @@
1
+ [[],[],[],[],[[8,0,9,13]],[[2,0,11,2],[18,0,11,9],[46,0,11,53],[61,0,11,37],[79,0,11,70]],[[4,0,12,4],[12,0,12,11],[16,0,12,15],[30,0,12,30],[40,0,12,11],[43,0,12,42]],[[4,0,13,23],[8,0,13,10],[21,0,13,23],[29,0,13,32],[50,0,13,52],[64,0,13,67],[76,0,13,78]],[[4,0,14,24],[8,0,14,10],[22,0,14,24],[30,0,14,33],[51,0,14,53],[65,0,14,68],[78,0,14,80]],[[4,0,15,4],[11,0,15,11],[19,0,16,6],[33,0,16,21],[42,0,16,6],[44,0,17,6],[52,0,17,15],[65,0,17,27],[77,0,16,6],[79,0,18,6],[93,0,18,21],[104,0,16,6],[106,0,19,6],[114,0,19,15],[127,0,19,27],[140,0,16,6],[142,0,20,6],[156,0,20,21],[168,0,16,6],[170,0,21,6],[184,0,21,21]],[],[[2,0,25,2],[18,0,25,9],[37,0,25,44],[52,0,25,28],[68,0,25,72],[72,0,25,60],[86,0,25,81]],[[4,0,26,4],[11,0,26,17],[25,0,26,32],[36,0,26,43],[47,0,26,43],[49,0,26,56],[55,0,26,76],[66,0,26,76],[68,0,26,89],[71,0,26,75],[73,0,26,95]],[],[[2,0,30,2],[18,0,30,9],[38,0,30,45],[53,0,30,29],[69,0,30,74],[73,0,30,61],[88,0,30,83]],[[4,0,31,4],[11,0,31,17],[25,0,31,32],[37,0,31,44],[49,0,31,44],[51,0,31,58],[57,0,31,79],[69,0,31,79],[71,0,31,93],[74,0,31,78],[76,0,31,99]],[],[]]
@@ -0,0 +1,18 @@
1
+ import "../types/structs.scrypt.tpl";
2
+ import "./stdUtils.scrypt.tpl";
3
+
4
+
5
+ library TxHashPreimageUtils {
6
+ static function getTxHashFromTxHashPreimage(TxHashPreimage txHashPreimage) : bytes {
7
+ require(len(txHashPreimage.version) == 4);
8
+ int inputCount = StdUtils.checkLenDivisibleBy(txHashPreimage.inputList, 72);
9
+ int outputCount = StdUtils.checkLenDivisibleBy(txHashPreimage.outputList, 72);
10
+ return hash256(txHashPreimage.version + StdUtils.writeVarInt(inputCount) + txHashPreimage.inputList + StdUtils.writeVarInt(outputCount) + txHashPreimage.outputList + txHashPreimage.nLockTime);
11
+ }
12
+ static function getInputByteString(TxHashPreimage txHashPreimage, int inputIndex) : bytes {
13
+ return txHashPreimage.inputList[inputIndex * 72 : (inputIndex + 1) * 72];
14
+ }
15
+ static function getOutputByteString(TxHashPreimage txHashPreimage, int outputIndex) : bytes {
16
+ return txHashPreimage.outputList[outputIndex * 72 : (outputIndex + 1) * 72];
17
+ }
18
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/txHashPreimageUtils.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/txHashPreimageUtils.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[],[],[],[],[],[[7,0,11,36]],[[2,0,12,18],[8,0,12,2]],[[2,0,13,20],[8,0,13,2]],[],[],[[8,0,21,13]],[[2,0,24,2],[18,0,24,9],[42,0,25,20],[57,0,25,4],[73,0,26,16],[79,0,26,4],[91,0,27,18],[95,0,27,4]],[[4,0,29,19],[10,0,29,10],[19,0,29,19],[38,0,29,39],[67,0,29,67]],[[4,0,30,4],[12,0,30,11],[19,0,30,11],[22,0,30,27],[33,0,30,39],[46,0,30,39],[48,0,30,54],[53,0,30,59],[66,0,30,59],[68,0,30,74],[71,0,30,59],[73,0,30,80]],[],[],[[2,0,41,2],[18,0,41,9],[37,0,42,19],[51,0,42,4],[66,0,43,23],[72,0,43,4],[91,0,44,18],[97,0,44,4],[111,0,45,23],[117,0,45,4]],[[4,0,47,16],[26,0,47,10],[32,0,47,16],[41,0,47,26],[57,0,47,41],[72,0,47,56]],[[4,0,48,4],[12,0,49,6],[15,0,49,10],[33,0,49,6],[36,0,49,31],[54,0,49,6],[57,0,49,52],[60,0,49,56],[76,0,49,52],[79,0,49,74]],[],[],[[2,0,63,2],[18,0,63,9],[35,0,64,19],[49,0,64,4],[64,0,65,21],[70,0,65,4],[87,0,66,18],[93,0,66,4],[107,0,67,23],[113,0,67,4]],[[4,0,69,16],[26,0,69,10],[32,0,69,16],[41,0,69,26],[57,0,69,41],[72,0,69,56]],[[4,0,70,4],[12,0,71,6],[15,0,71,10],[31,0,71,6],[34,0,71,28],[50,0,71,6],[53,0,71,47],[56,0,71,51],[72,0,71,47],[75,0,71,69]],[],[],[[2,0,85,2],[18,0,85,9],[33,0,86,19],[47,0,86,4],[62,0,87,23],[68,0,87,4],[89,0,88,5]],[[4,0,90,4],[12,0,92,8],[30,0,93,8],[43,0,93,22],[61,0,93,8],[63,0,93,41],[69,0,94,9],[82,0,94,23],[100,0,94,9],[102,0,94,42],[105,0,94,8],[107,0,94,48],[111,0,91,6],[114,0,96,6],[121,0,96,14],[133,0,96,25],[146,0,96,39]],[[4,0,99,27],[10,0,99,10],[27,0,99,27],[40,0,99,41],[52,0,99,53]],[[4,0,100,4],[12,0,101,6],[27,0,101,6],[30,0,102,8],[49,0,102,28],[78,0,102,56],[91,0,102,70]],[[4,0,106,6],[10,0,105,10],[27,0,107,8],[40,0,107,22],[59,0,107,41],[71,0,108,8],[84,0,108,22],[96,0,108,34],[113,0,108,8],[115,0,108,52],[118,0,108,8],[120,0,108,73],[125,0,109,9],[138,0,109,23],[150,0,109,35],[168,0,109,8],[170,0,109,54],[173,0,109,8],[175,0,109,75],[177,0,109,8],[179,0,109,104]],[[4,0,112,6],[10,0,111,10],[29,0,112,6],[44,0,112,6],[46,0,112,23],[54,0,112,32],[74,0,112,51],[87,0,112,65],[99,0,112,77]],[[4,0,113,4],[11,0,113,11]],[],[]]
@@ -0,0 +1,36 @@
1
+ import "../types/structs.scrypt.tpl";
2
+ import "./txHashPreimageUtils.scrypt.tpl";
3
+ import "./txUtils.scrypt.tpl";
4
+ import "./stdUtils.scrypt.tpl";
5
+
6
+
7
+ struct ChainTxVerifyResponse {
8
+ bytes prevPrevScript;
9
+ bytes prevPrevOutpoint;
10
+ }
11
+
12
+ library Backtrace {
13
+ static function checkPrevTxHashPreimage(TxHashPreimage txHashPreimage, bytes t_prevouts, int t_inputIndex) : bool {
14
+ bytes txHash = TxHashPreimageUtils.getTxHashFromTxHashPreimage(txHashPreimage);
15
+ require(txHash == t_prevouts[t_inputIndex * 36 : t_inputIndex * 36 + 32]);
16
+ return true;
17
+ }
18
+ static function verifyFromOutpoint(BacktraceInfo backtraceInfo, bytes t_genesisOutpoint, bytes t_selfScript, bytes t_prevTxInputList) : bool {
19
+ ChainTxVerifyResponse res = Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
20
+ require(res.prevPrevOutpoint == t_genesisOutpoint || res.prevPrevScript == t_selfScript);
21
+ return true;
22
+ }
23
+ static function verifyFromScript(BacktraceInfo backtraceInfo, bytes t_genesisScript, bytes t_selfScript, bytes t_prevTxInputList) : bool {
24
+ ChainTxVerifyResponse res = Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
25
+ require(res.prevPrevScript == t_genesisScript || res.prevPrevScript == t_selfScript);
26
+ return true;
27
+ }
28
+ static function verifyChainTxs(BacktraceInfo backtraceInfo, bytes t_prevTxInputList) : ChainTxVerifyResponse {
29
+ require(t_prevTxInputList[backtraceInfo.prevTxInputIndex * 72 : (backtraceInfo.prevTxInputIndex + 1) * 72] == TxUtils.mergeInput(backtraceInfo.prevTxInput));
30
+ bytes prevPrevTxHash = backtraceInfo.prevTxInput.prevTxHash;
31
+ require(prevPrevTxHash == TxHashPreimageUtils.getTxHashFromTxHashPreimage(backtraceInfo.prevPrevTxPreimage));
32
+ bytes prevPrevScript = backtraceInfo.prevPrevTxPreimage.outputList[backtraceInfo.prevTxInput.prevOutputIndex * 72 + 8 : (backtraceInfo.prevTxInput.prevOutputIndex) * 72 + 8 + 32];
33
+ bytes prevPrevOutpoint = prevPrevTxHash + StdUtils.uint32ToByteString(backtraceInfo.prevTxInput.prevOutputIndex);
34
+ return {prevPrevScript, prevPrevOutpoint};
35
+ }
36
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/backtrace.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/backtrace.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[],[],[[8,0,10,13]],[[2,0,13,9],[8,0,13,4]],[[2,0,15,9],[6,0,15,4]],[[2,0,17,4],[14,0,17,21],[20,0,17,16]],[[4,0,19,8],[8,0,19,13],[13,0,19,8],[15,0,19,19]],[[4,0,20,8],[8,0,20,13],[13,0,20,8],[15,0,20,19]],[],[[11,0,28,4],[19,0,28,11]],[[4,0,29,8],[11,0,29,15],[15,0,29,20],[20,0,29,15],[23,0,29,27],[27,0,29,31],[31,0,29,36]],[],[[11,0,37,4],[25,0,37,17]],[[4,0,38,15],[8,0,38,12],[12,0,38,24]],[[4,0,39,17],[10,0,39,12],[16,0,39,30],[20,0,39,35]],[[4,0,40,17],[10,0,40,12],[16,0,40,43]],[[4,0,41,20],[8,0,41,12],[17,0,41,29],[24,0,41,51],[28,0,41,56],[33,0,41,61],[37,0,41,66],[44,0,41,71],[48,0,41,76],[53,0,41,71],[55,0,41,82]],[[4,0,42,8],[8,0,42,13],[12,0,42,8]],[[4,0,44,8],[7,0,44,12],[14,0,44,12],[16,0,44,21]],[[8,0,45,12],[10,0,45,12],[12,0,45,16]],[[8,0,46,12],[12,0,46,12],[14,0,46,24],[18,0,46,29],[22,0,46,34],[29,0,46,39],[33,0,46,44],[38,0,46,39],[40,0,46,50]],[[13,0,48,13],[16,0,48,17],[23,0,48,17],[26,0,48,27]],[[8,0,49,12],[10,0,49,12],[12,0,49,16],[20,0,49,25],[36,0,49,46],[40,0,49,51],[44,0,49,56],[51,0,49,61],[55,0,49,66],[60,0,49,61],[62,0,49,72]],[[8,0,50,12],[12,0,50,17],[17,0,50,12],[20,0,50,24]],[[8,0,51,12],[12,0,51,12],[14,0,51,24],[18,0,51,29],[23,0,51,34],[27,0,51,39],[34,0,51,44],[38,0,51,49],[43,0,51,44],[45,0,51,55]],[[13,0,53,13],[16,0,53,17],[23,0,53,17],[26,0,53,27]],[[8,0,54,12],[10,0,54,12],[12,0,54,16],[20,0,54,25],[36,0,54,46],[40,0,54,51],[45,0,54,56],[49,0,54,61],[56,0,54,66],[60,0,54,71],[65,0,54,66],[67,0,54,77]],[[8,0,55,12],[12,0,55,17],[17,0,55,12],[20,0,55,24]],[[8,0,56,12],[12,0,56,12],[14,0,56,24],[18,0,56,29],[23,0,56,34],[27,0,56,39],[34,0,56,44],[38,0,56,49],[43,0,56,44],[45,0,56,55]],[[13,0,58,13],[16,0,58,17],[23,0,58,17],[26,0,58,27]],[[8,0,59,12],[10,0,59,12],[12,0,59,16],[20,0,59,25],[36,0,59,46],[40,0,59,51],[45,0,59,56],[49,0,59,61],[56,0,59,66],[60,0,59,71],[65,0,59,66],[67,0,59,77]],[[8,0,60,12],[12,0,60,17],[17,0,60,12],[20,0,60,24]],[[8,0,61,12],[12,0,61,12],[14,0,61,24],[18,0,61,29],[23,0,61,34],[27,0,61,39],[34,0,61,44],[38,0,61,49],[43,0,61,44],[45,0,61,55]],[],[[8,0,65,12],[16,0,65,19]],[],[[4,0,68,8],[8,0,68,13],[13,0,68,8],[16,0,68,20]],[[4,0,69,8],[11,0,69,15]],[],[[11,0,78,4],[24,0,78,16]],[[4,0,79,17],[10,0,79,12],[16,0,79,36],[20,0,79,41],[25,0,79,46],[29,0,79,51],[36,0,79,56],[40,0,79,61],[45,0,79,56],[47,0,79,67]],[[4,0,80,8],[8,0,80,13],[12,0,80,8]],[[4,0,81,8],[11,0,81,28],[17,0,81,15],[20,0,81,37]],[],[[11,0,89,4],[26,0,89,18]],[[4,0,90,18],[10,0,90,12],[16,0,90,31]],[[4,0,91,21],[10,0,91,12],[19,0,91,27],[23,0,91,32],[28,0,91,37],[32,0,91,42],[39,0,91,47],[43,0,91,52],[48,0,91,47],[50,0,91,58]],[[4,0,92,8],[8,0,92,13],[12,0,92,8]],[[4,0,93,8],[7,0,93,12],[14,0,93,12],[17,0,93,35]],[[8,0,94,12],[12,0,94,12],[14,0,94,24],[18,0,94,29],[23,0,94,34],[27,0,94,39],[34,0,94,44],[38,0,94,49],[43,0,94,44],[45,0,94,55]],[[8,0,95,12],[12,0,95,17],[17,0,95,12],[20,0,95,24]],[[13,0,97,13],[16,0,97,17],[23,0,97,17],[26,0,97,40]],[[8,0,98,12],[12,0,98,12],[14,0,98,24],[18,0,98,29],[23,0,98,34],[27,0,98,39],[34,0,98,44],[38,0,98,49],[43,0,98,44],[45,0,98,55]],[[8,0,99,12],[12,0,99,17],[17,0,99,12],[20,0,99,24]],[[13,0,101,13],[16,0,101,17],[23,0,101,17],[26,0,101,40]],[[8,0,102,12],[12,0,102,12],[14,0,102,24],[18,0,102,29],[23,0,102,34],[27,0,102,39],[34,0,102,44],[38,0,102,49],[43,0,102,44],[45,0,102,55]],[[8,0,103,12],[12,0,103,17],[17,0,103,12],[20,0,103,24]],[],[[8,0,106,12],[12,0,106,12],[14,0,106,18]],[],[[4,0,108,8],[11,0,108,15],[19,0,108,24],[35,0,108,39]],[],[]]
@@ -0,0 +1,64 @@
1
+ import "./stdUtils.scrypt.tpl";
2
+
3
+
4
+ library ByteStringReader {
5
+ bytes buf;
6
+ int pos;
7
+ constructor(bytes buf) {
8
+ this.buf = buf;
9
+ this.pos = 0;
10
+ }
11
+ function eof() : bool {
12
+ return this.pos >= len(this.buf);
13
+ }
14
+ function readBytes() : bytes {
15
+ int l = 0;
16
+ bytes buf = this.buf;
17
+ bytes ret = b'';
18
+ int header = unpack(this.buf[this.pos : this.pos + 1]);
19
+ this.pos++;
20
+ if(header < 0x4c) {
21
+ l = header;
22
+ ret = buf[this.pos : this.pos + l];
23
+ } else if(header == 0x4c) {
24
+ l = StdUtils.fromLEUnsigned(buf[this.pos : this.pos + 1]);
25
+ this.pos += 1;
26
+ ret = this.buf[this.pos : this.pos + l];
27
+ } else if(header == 0x4d) {
28
+ l = StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 2]);
29
+ this.pos += 2;
30
+ ret = this.buf[this.pos : this.pos + l];
31
+ } else if(header == 0x4e) {
32
+ l = StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 4]);
33
+ this.pos += 4;
34
+ ret = this.buf[this.pos : this.pos + l];
35
+ } else {
36
+ require(false);
37
+ }
38
+ this.pos += l;
39
+ return ret;
40
+ }
41
+ function readBool() : bool {
42
+ bytes buf = this.buf[this.pos : this.pos + 1];
43
+ this.pos++;
44
+ return b'00' != buf;
45
+ }
46
+ function readVarint() : int {
47
+ bytes ret = b'';
48
+ bytes header = this.buf[this.pos : this.pos + 1];
49
+ this.pos++;
50
+ if(header == b'fd') {
51
+ ret = this.buf[this.pos : this.pos + 2];
52
+ this.pos += 2;
53
+ } else if(header == b'fe') {
54
+ ret = this.buf[this.pos : this.pos + 4];
55
+ this.pos += 4;
56
+ } else if(header == b'ff') {
57
+ ret = this.buf[this.pos : this.pos + 8];
58
+ this.pos += 8;
59
+ } else {
60
+ ret = header;
61
+ }
62
+ return StdUtils.fromLEUnsigned(ret);
63
+ }
64
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/byteStringReader.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/byteStringReader.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[],[],[[8,0,10,13]],[[2,0,12,9],[8,0,12,4]],[[2,0,14,4]],[[4,0,16,8],[8,0,16,13],[13,0,16,8],[15,0,16,32]],[],[[11,0,24,4],[22,0,24,20],[28,0,24,15]],[[4,0,25,16],[8,0,25,12],[12,0,25,16],[16,0,25,20]],[[4,0,27,20],[10,0,27,12],[19,0,27,46]],[[4,0,29,8],[7,0,29,12],[9,0,29,12],[11,0,29,16]],[[8,0,30,12],[15,0,30,12],[17,0,30,21],[25,0,30,30],[39,0,30,43],[42,0,30,46]],[[13,0,32,13],[16,0,32,17],[18,0,32,17],[20,0,32,21]],[[8,0,33,12],[15,0,33,12],[17,0,33,34],[23,0,33,21],[25,0,33,42],[33,0,33,51],[47,0,33,64],[50,0,33,67]],[[13,0,35,13],[16,0,35,17],[18,0,35,17],[20,0,35,21]],[[8,0,36,12],[15,0,36,12],[17,0,36,34],[23,0,36,21],[25,0,36,42],[33,0,36,51],[47,0,36,64],[50,0,36,67]],[[13,0,38,13],[16,0,38,17],[18,0,38,17],[20,0,38,21]],[[8,0,39,12],[15,0,39,12],[17,0,39,34],[23,0,39,21],[25,0,39,42],[33,0,39,51],[47,0,39,64],[50,0,39,67]],[],[[8,0,43,12],[16,0,43,19]],[],[[4,0,46,8],[8,0,46,13],[13,0,46,8],[16,0,46,20],[23,0,46,20],[25,0,46,29]],[],[],[[11,0,55,4],[21,0,55,17],[26,0,55,14]],[[4,0,56,8],[8,0,56,13],[13,0,56,8],[16,0,56,20],[20,0,56,37],[28,0,56,58]],[],[],[[11,0,65,4],[23,0,65,19],[27,0,65,16]],[[4,0,66,8],[12,0,66,15],[14,0,66,15],[17,0,66,20]],[[4,0,67,19],[8,0,67,12],[15,0,67,19]],[[4,0,68,8],[7,0,68,12],[9,0,68,12],[11,0,68,16]],[[8,0,69,12],[13,0,69,12],[15,0,69,19]],[[13,0,71,13],[16,0,71,17],[18,0,71,17],[20,0,71,21]],[[8,0,72,12],[12,0,72,17],[17,0,72,12],[20,0,72,37]],[[8,0,73,12],[13,0,73,12],[15,0,73,19]],[[13,0,75,13],[16,0,75,17],[18,0,75,17],[20,0,75,21]],[[8,0,76,12],[13,0,76,12],[15,0,76,19]],[[8,0,77,12],[12,0,77,17],[17,0,77,12],[20,0,77,37]],[],[[8,0,80,12],[13,0,80,12],[15,0,80,19]],[[8,0,81,12],[12,0,81,17],[17,0,81,12],[20,0,81,37]],[],[[4,0,83,8],[8,0,83,13],[13,0,83,8],[16,0,83,20],[24,0,83,29],[38,0,83,42],[41,0,83,45]],[],[],[]]
@@ -0,0 +1,48 @@
1
+ import "./stdUtils.scrypt.tpl";
2
+
3
+
4
+ library ByteStringWriter {
5
+ bytes buf;
6
+ constructor() {
7
+ this.buf = b'';
8
+ }
9
+ function writeBytes(bytes buf) : bool {
10
+ int n = len(buf);
11
+ bytes header = b'';
12
+ if(n < 0x4c) {
13
+ header = StdUtils.toLEUnsigned(n, 1);
14
+ } else if(n < 0x100) {
15
+ header = b'4c' + StdUtils.toLEUnsigned(n, 1);
16
+ } else if(n < 0x10000) {
17
+ header = b'4d' + StdUtils.toLEUnsigned(n, 2);
18
+ } else if(n < 0x100000000) {
19
+ header = b'4e' + StdUtils.toLEUnsigned(n, 4);
20
+ } else {
21
+ require(false);
22
+ }
23
+ this.buf += header + buf;
24
+ return true;
25
+ }
26
+ function writeBool(bool x) : bool {
27
+ this.buf += x ? b'01' : b'00';
28
+ return true;
29
+ }
30
+ function writeVarInt(int x) : bool {
31
+ require(x >= 0);
32
+ int size = 0;
33
+ if(x < 0xfd) {
34
+ size = 1;
35
+ } else if(x < 0x10000) {
36
+ this.buf += b'fd';
37
+ size = 2;
38
+ } else if(x < 0x100000000) {
39
+ size = 4;
40
+ this.buf += b'fe';
41
+ } else {
42
+ size = 8;
43
+ this.buf += b'ff';
44
+ }
45
+ this.buf += StdUtils.toLEUnsigned(x, size);
46
+ return true;
47
+ }
48
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/byteStringWriter.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/byteStringWriter.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[],[],[],[],[[8,0,15,13]],[[2,0,20,2],[9,0,20,9],[15,0,20,27],[23,0,20,18],[33,0,20,37],[41,0,20,45]],[[2,0,22,2],[9,0,22,9],[15,0,22,26],[22,0,22,18],[31,0,22,35],[38,0,22,55]],[[2,0,25,2],[9,0,25,9],[15,0,25,24],[19,0,25,18],[26,0,25,33]],[[2,0,28,2],[9,0,28,9],[15,0,28,21],[19,0,28,18],[23,0,28,30]],[[2,0,31,2],[9,0,31,9],[15,0,31,30],[21,0,31,18],[34,0,31,56]],[[2,0,35,2],[18,0,35,9],[28,0,35,22],[32,0,35,19],[35,0,35,39],[39,0,35,30],[50,0,35,48]],[[4,0,36,15],[8,0,36,10],[14,0,36,24],[16,0,36,24],[18,0,36,28]],[[4,0,38,4],[12,0,38,12],[16,0,38,12],[18,0,38,18],[23,0,38,23],[27,0,38,23],[29,0,38,29],[39,0,38,39]],[],[[2,0,41,2],[18,0,41,9],[23,0,41,17],[27,0,41,14],[30,0,41,34],[38,0,41,25],[47,0,41,53],[51,0,41,43],[61,0,41,64],[65,0,41,61],[68,0,41,84],[74,0,41,72],[86,0,41,109],[92,0,41,96],[107,0,41,122]],[[4,0,43,11],[8,0,43,8],[12,0,43,20],[21,0,43,20],[24,0,43,32],[26,0,43,32],[28,0,43,36],[30,0,43,36],[33,0,43,41]],[],[[4,0,45,4],[6,0,45,4],[8,0,45,8],[20,0,45,21],[31,0,45,31],[34,0,44,22]],[[4,0,47,4],[7,0,47,8],[9,0,47,8],[11,0,44,22],[90,0,47,12],[92,0,47,16]],[[8,0,48,6],[10,0,48,6],[12,0,44,22],[91,0,48,10],[93,0,48,14]],[],[[4,0,55,16],[8,0,55,10],[15,0,55,25],[16,0,55,32],[20,0,55,36]],[[4,0,56,17],[8,0,56,10],[15,0,56,17],[19,0,56,21],[24,0,56,37]],[[4,0,59,22],[10,0,59,10],[23,0,59,41],[36,0,59,59],[44,0,59,75],[47,0,59,78],[52,0,59,84],[53,0,59,91],[58,0,59,97],[61,0,59,97],[63,0,59,103],[74,0,59,41],[87,0,59,59],[95,0,59,75],[98,0,59,78],[103,0,59,84],[104,0,59,91]],[[4,0,61,13],[8,0,61,10],[12,0,61,22],[14,0,61,22],[16,0,61,27],[21,0,61,22],[23,0,61,34],[24,0,61,41]],[[4,0,63,14],[10,0,63,10],[15,0,63,40],[21,0,63,27],[23,0,64,6],[28,0,64,22],[31,0,63,27],[33,0,65,19],[39,0,63,27],[41,0,66,6],[46,0,66,22],[52,0,63,27],[54,0,67,6],[65,0,63,27],[67,0,68,19],[73,0,63,27],[75,0,69,6],[80,0,69,22],[86,0,63,27],[88,0,70,6],[99,0,63,27],[101,0,71,19]],[[4,0,72,4],[11,0,72,11],[15,0,72,15]],[],[[2,0,76,2],[18,0,76,9],[33,0,76,27],[39,0,76,24],[44,0,76,40]],[[4,0,79,4],[11,0,79,11],[18,0,79,27],[31,0,79,45],[34,0,79,48],[38,0,79,27],[40,0,79,68]],[],[[2,0,88,2],[18,0,88,9],[34,0,88,37],[45,0,88,25],[57,0,88,62],[63,0,88,49],[78,0,88,75]],[[4,0,89,4],[12,0,89,11],[16,0,89,15],[26,0,89,26],[37,0,89,11],[40,0,89,39]],[[4,0,90,4],[12,0,90,11],[16,0,90,15],[26,0,90,26],[41,0,90,11],[44,0,90,43]],[[4,0,91,4],[12,0,91,11],[16,0,91,15],[26,0,91,26],[44,0,91,11],[47,0,91,46]],[[4,0,92,4],[12,0,92,11],[16,0,92,15],[26,0,92,26],[42,0,92,11],[45,0,92,44]],[[4,0,93,4],[12,0,93,11],[22,0,93,22],[29,0,93,11],[32,0,93,31]],[[4,0,94,4],[12,0,94,11],[16,0,94,15],[26,0,94,26],[38,0,94,11],[41,0,94,40]],[[4,0,95,4],[12,0,95,11],[16,0,95,15],[26,0,95,26],[45,0,95,11],[48,0,95,47]],[[4,0,96,4],[12,0,96,11],[16,0,96,15],[26,0,96,26],[50,0,96,11],[53,0,96,52]],[[4,0,97,4],[12,0,97,11],[16,0,97,15],[26,0,97,26],[48,0,97,11],[51,0,97,50]],[[4,0,98,4],[12,0,98,11],[16,0,98,15],[26,0,98,26],[42,0,98,11],[45,0,98,44]],[[4,0,99,4],[12,0,99,11],[16,0,99,15],[26,0,99,26],[40,0,99,11],[43,0,99,42]],[[4,0,100,4],[12,0,100,11],[22,0,100,22],[34,0,100,11],[37,0,100,36]],[[4,0,101,4],[12,0,101,11],[22,0,101,22],[33,0,101,11],[36,0,101,35]],[[4,0,102,4],[12,0,102,11],[22,0,102,22],[35,0,102,11],[38,0,102,37],[40,0,102,11],[43,0,103,9],[53,0,103,20],[66,0,103,9],[69,0,103,35],[71,0,102,11],[74,0,104,9],[84,0,104,20],[97,0,104,9],[100,0,104,35],[102,0,102,11],[105,0,105,9],[115,0,105,20],[128,0,105,9],[131,0,105,35],[136,0,102,11],[139,0,106,9],[149,0,106,20],[162,0,106,9],[165,0,106,35],[170,0,102,11],[173,0,107,9],[183,0,107,20],[196,0,107,9],[199,0,107,35]],[[4,0,110,21],[10,0,110,10],[21,0,110,21],[31,0,110,32],[41,0,110,21],[43,0,111,8],[53,0,111,19],[67,0,110,21],[69,0,112,8],[79,0,112,19],[96,0,110,21],[98,0,113,8],[108,0,113,19],[123,0,110,21],[125,0,114,8],[132,0,114,16],[154,0,114,37],[164,0,114,48],[172,0,110,21],[174,0,115,8],[184,0,115,19],[195,0,110,21],[197,0,116,8],[207,0,116,19],[225,0,110,21],[227,0,117,8],[237,0,117,19],[260,0,110,21],[262,0,118,8],[272,0,118,19],[293,0,110,21],[295,0,119,8],[305,0,119,19],[320,0,110,21],[322,0,120,8],[332,0,120,19],[345,0,110,21],[347,0,121,8],[355,0,121,17],[369,0,121,30],[379,0,121,41],[392,0,121,53],[395,0,110,21],[397,0,122,8],[405,0,122,17],[419,0,122,30],[429,0,122,41],[441,0,122,52],[444,0,110,21],[446,0,123,8],[454,0,123,24],[464,0,123,35],[478,0,123,48]],[[4,0,125,13],[10,0,125,10],[14,0,125,26],[22,0,125,34]],[[4,0,126,15],[8,0,126,10],[14,0,126,21],[26,0,126,34],[32,0,127,6],[44,0,127,19],[60,0,127,34],[64,0,128,6],[76,0,128,19],[86,0,25,33],[165,0,28,30],[243,0,131,7],[255,0,131,20],[268,0,132,8]],[[4,0,133,4],[11,0,133,11]],[],[[2,0,137,2],[18,0,137,9],[38,0,137,41],[49,0,137,29],[63,0,137,54]],[[4,0,138,4],[12,0,138,11],[16,0,138,15],[26,0,138,26],[37,0,138,11],[40,0,138,39]],[[4,0,139,4],[12,0,139,11],[16,0,139,15],[26,0,139,26],[41,0,139,11],[44,0,139,43]],[[4,0,140,4],[12,0,140,11],[16,0,140,15],[26,0,140,26],[44,0,140,11],[47,0,140,46]],[[4,0,141,4],[12,0,141,11],[16,0,141,15],[26,0,141,26],[42,0,141,11],[45,0,141,44]],[[4,0,142,4],[12,0,142,11],[22,0,142,22],[29,0,142,11],[32,0,142,31]],[[4,0,143,4],[12,0,143,11],[16,0,143,15],[26,0,143,26],[38,0,143,11],[41,0,143,40]],[[4,0,144,4],[12,0,144,11],[16,0,144,15],[26,0,144,26],[45,0,144,11],[48,0,144,47]],[[4,0,145,4],[12,0,145,11],[16,0,145,15],[26,0,145,26],[50,0,145,11],[53,0,145,52]],[[4,0,146,4],[12,0,146,11],[16,0,146,15],[26,0,146,26],[48,0,146,11],[51,0,146,50]],[[4,0,147,4],[12,0,147,11],[16,0,147,15],[26,0,147,26],[42,0,147,11],[45,0,147,44]],[[4,0,148,4],[12,0,148,11],[16,0,148,15],[26,0,148,26],[40,0,148,11],[43,0,148,42]],[[4,0,149,4],[12,0,149,11],[22,0,149,22],[34,0,149,11],[37,0,149,36]],[[4,0,150,4],[12,0,150,11],[22,0,150,22],[33,0,150,11],[36,0,150,35]],[[4,0,151,4],[12,0,151,11],[22,0,151,22],[35,0,151,11],[38,0,151,37],[40,0,151,11],[43,0,152,9],[53,0,152,20],[66,0,152,9],[69,0,152,35],[71,0,151,11],[74,0,153,9],[84,0,153,20],[97,0,153,9],[100,0,153,35],[102,0,151,11],[105,0,154,9],[115,0,154,20],[128,0,154,9],[131,0,154,35],[136,0,151,11],[139,0,155,9],[149,0,155,20],[162,0,155,9],[165,0,155,35],[170,0,151,11],[173,0,156,9],[183,0,156,20],[196,0,156,9],[199,0,156,35]],[[4,0,159,21],[10,0,159,10],[21,0,159,21],[31,0,159,32],[41,0,159,21],[43,0,160,8],[53,0,160,19],[67,0,159,21],[69,0,161,8],[79,0,161,19],[96,0,159,21],[98,0,162,8],[108,0,162,19],[123,0,159,21],[125,0,163,8],[132,0,163,16],[154,0,163,37],[164,0,163,48],[172,0,159,21],[174,0,164,8],[184,0,164,19],[195,0,159,21],[197,0,165,8],[207,0,165,19],[225,0,159,21],[227,0,166,8],[237,0,166,19],[260,0,159,21],[262,0,167,8],[272,0,167,19],[293,0,159,21],[295,0,168,8],[305,0,168,19],[320,0,159,21],[322,0,169,8],[332,0,169,19],[345,0,159,21],[347,0,170,8],[355,0,170,17],[369,0,170,30],[379,0,170,41],[392,0,170,53],[395,0,159,21],[397,0,171,8],[405,0,171,17],[419,0,171,30],[429,0,171,41],[441,0,171,52],[444,0,159,21],[446,0,172,8],[454,0,172,24],[464,0,172,35],[478,0,172,48]],[[4,0,173,4],[11,0,173,11],[27,0,173,27]],[],[[2,0,185,2],[18,0,185,9],[32,0,186,14],[38,0,186,4],[48,0,187,20],[54,0,187,4],[70,0,188,18],[74,0,188,4],[88,0,189,18],[92,0,189,4],[108,0,190,5]],[[4,0,192,4],[12,0,192,11],[20,0,192,19],[30,0,192,11],[33,0,192,32]],[[4,0,193,4],[12,0,193,11],[25,0,193,11],[27,0,193,26]],[[4,0,194,4],[12,0,194,11],[25,0,194,11],[28,0,194,27],[36,0,194,36],[57,0,194,56],[67,0,194,66]],[[4,0,196,14],[10,0,196,10],[14,0,196,20],[23,0,196,30],[36,0,196,30],[38,0,196,45],[44,0,196,51],[57,0,196,51],[59,0,196,66],[62,0,196,50],[64,0,196,72]],[[4,0,197,4],[11,0,197,11],[12,0,198,20],[14,0,198,23],[18,0,198,27],[23,0,199,19],[31,0,199,28],[51,0,199,53],[53,0,199,56],[58,0,199,61]],[],[[2,0,210,2],[18,0,210,9],[36,0,211,23],[42,0,211,4],[61,0,212,24],[67,0,212,4],[87,0,213,18],[91,0,213,4]],[[4,0,215,4],[12,0,215,11],[20,0,215,19],[39,0,215,11],[42,0,215,41]],[[4,0,216,4],[12,0,216,11],[25,0,216,11],[28,0,216,27],[36,0,216,36],[57,0,216,56],[76,0,216,75]],[],[],[[2,0,226,2],[18,0,226,9],[36,0,227,18],[42,0,227,4],[56,0,228,24],[62,0,228,4],[84,0,229,5]],[[4,0,230,4],[12,0,230,11],[20,0,230,19],[34,0,230,11],[37,0,230,36]],[[4,0,231,4],[11,0,231,11],[19,0,231,20],[40,0,231,40],[54,0,231,54]],[],[[2,0,235,2],[18,0,235,9],[39,0,236,21],[45,0,236,4],[62,0,237,27],[68,0,237,4],[91,0,238,18],[95,0,238,4]],[[4,0,240,4],[12,0,240,11],[20,0,240,19],[37,0,240,11],[40,0,240,39]],[[4,0,241,4],[12,0,241,11],[25,0,241,11],[28,0,241,27],[36,0,241,36],[57,0,241,56],[74,0,241,73]],[],[],[[2,0,246,2],[18,0,246,9],[37,0,247,23],[43,0,247,4],[62,0,248,16],[66,0,248,4],[80,0,249,5]],[[4,0,250,4],[11,0,250,17],[29,0,250,36],[40,0,250,36],[42,0,250,49],[48,0,250,55],[59,0,250,55],[61,0,250,68],[64,0,250,54],[66,0,250,74]],[],[[2,0,254,2],[18,0,254,9],[33,0,255,18],[39,0,255,4],[53,0,256,16],[57,0,256,4],[71,0,257,5]],[[4,0,258,4],[11,0,258,11],[19,0,258,20],[35,0,258,41],[48,0,258,55],[59,0,258,55],[61,0,258,68],[66,0,258,73],[77,0,258,73],[79,0,258,86],[82,0,258,72],[84,0,258,92]],[],[[2,0,262,2],[18,0,262,9],[35,0,263,21],[41,0,263,4],[58,0,264,16],[62,0,264,4],[76,0,265,5]],[[4,0,266,4],[11,0,266,17],[27,0,266,34],[38,0,266,34],[40,0,266,47],[46,0,266,53],[57,0,266,53],[59,0,266,66],[62,0,266,52],[64,0,266,72]],[],[]]
@@ -0,0 +1,101 @@
1
+ import "../types/structs.scrypt.tpl";
2
+ import "./txUtils.scrypt.tpl";
3
+ import "./stdUtils.scrypt.tpl";
4
+
5
+
6
+ library ContextUtils {
7
+ static const PrivKey privKey = PrivKey(0x26f00fe2340a84335ebdf30f57e9bb58487117b29355718f5e46bf5168d7df97);
8
+ static const PubKey pubKey = PubKey(b'02ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382');
9
+ static const int invK = 0xc8ffdbaa05d93aa4ede79ec58f06a72562048b775a3507c2bf44bde4f007c40a;
10
+ static const int r = 0x1008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c;
11
+ static const bytes rBigEndian = b'1008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c';
12
+ static function normalize(int k, int modulus) : int {
13
+ int res = k % modulus;
14
+ return (res < 0) ? res + modulus : res;
15
+ }
16
+ static function sign(int h, PrivKey privKey, int inverseK, int r, bytes rBigEndian, bytes sigHashType) : Sig {
17
+ int s = inverseK * (h + r * (privKey));
18
+
19
+ s = ContextUtils.normalize(s, 115792089237316195423570985008687907852837564279074904382605163141518161494337);
20
+ if(s > 115792089237316195423570985008687907852837564279074904382605163141518161494337 / 2) {
21
+ s = 115792089237316195423570985008687907852837564279074904382605163141518161494337 - s;
22
+ }
23
+ int rlen = (len(rBigEndian));
24
+ int slen = len(pack(s));
25
+ bytes sBigEndian = reverseBytes(num2bin(s, 32), (32))[32 - slen : len(reverseBytes(num2bin(s, 32), (32)))];
26
+ int l = 4 + rlen + (slen);
27
+ bytes rb = b'30' + pack(l) + b'02' + pack(rlen) + rBigEndian + b'02' + pack(slen) + sBigEndian + sigHashType;
28
+ return Sig(rb);
29
+ }
30
+ static function fromBEUnsigned(bytes b) : int {
31
+ return unpack(reverseBytes(b, 32) + b'00');
32
+ }
33
+ static function checkSHPreimage(SHPreimage shPreimage, bytes sigHashType) : Sig {
34
+ require(len(shPreimage.nVersion) == 4);
35
+ require(len(shPreimage.hashPrevouts) == 32);
36
+ require(len(shPreimage.spentScriptHash) == 32);
37
+ require(len(shPreimage.spentDataHash) == 32);
38
+ require(shPreimage.value >= 0);
39
+ require(len(shPreimage.nSequence) == 4);
40
+ require(len(shPreimage.hashSpentAmounts) == 32);
41
+ require(len(shPreimage.hashSpentScriptHashes) == 32);
42
+ require(len(shPreimage.hashSpentDataHashes) == 32);
43
+ require(len(shPreimage.hashSequences) == 32);
44
+ require(len(shPreimage.hashOutputs) == 32);
45
+ require(shPreimage.inputIndex >= 0);
46
+ require(shPreimage.nLockTime >= 0);
47
+ require(shPreimage.sigHashType == 1 || shPreimage.sigHashType == 2 || shPreimage.sigHashType == 3 || shPreimage.sigHashType == 0x81 || shPreimage.sigHashType == 0x82 || shPreimage.sigHashType == 0x83);
48
+ bytes preimage = shPreimage.nVersion + shPreimage.hashPrevouts + shPreimage.spentScriptHash + shPreimage.spentDataHash + TxUtils.satoshisToByteString(shPreimage.value) + shPreimage.nSequence + shPreimage.hashSpentAmounts + shPreimage.hashSpentScriptHashes + shPreimage.hashSpentDataHashes + shPreimage.hashSequences + shPreimage.hashOutputs + StdUtils.toLEUnsigned(shPreimage.inputIndex, 4) + StdUtils.toLEUnsigned(shPreimage.nLockTime, 4) + num2bin(shPreimage.sigHashType, 4);
49
+ bytes h = hash256(preimage);
50
+ Sig sig = ContextUtils.sign(ContextUtils.fromBEUnsigned(h), ContextUtils.privKey, 90914631784428570546048907090666684794265392153046400654824470772421497439242, 7252565254521500021189571868467740368187828957595681190666767817830690399852, ContextUtils.rBigEndian, sigHashType);
51
+ return sig;
52
+ }
53
+ static function serializeSHPreimage(SHPreimage shPreimage) : SigHashPreimage {
54
+ require(len(shPreimage.nVersion) == 4);
55
+ require(len(shPreimage.hashPrevouts) == 32);
56
+ require(len(shPreimage.spentScriptHash) == 32);
57
+ require(len(shPreimage.spentDataHash) == 32);
58
+ require(shPreimage.value >= 0);
59
+ require(len(shPreimage.nSequence) == 4);
60
+ require(len(shPreimage.hashSpentAmounts) == 32);
61
+ require(len(shPreimage.hashSpentScriptHashes) == 32);
62
+ require(len(shPreimage.hashSpentDataHashes) == 32);
63
+ require(len(shPreimage.hashSequences) == 32);
64
+ require(len(shPreimage.hashOutputs) == 32);
65
+ require(shPreimage.inputIndex >= 0);
66
+ require(shPreimage.nLockTime >= 0);
67
+ require(shPreimage.sigHashType == 1 || shPreimage.sigHashType == 2 || shPreimage.sigHashType == 3 || shPreimage.sigHashType == 0x81 || shPreimage.sigHashType == 0x82 || shPreimage.sigHashType == 0x83);
68
+ bytes preimage = shPreimage.nVersion + shPreimage.hashPrevouts + shPreimage.spentScriptHash + shPreimage.spentDataHash + TxUtils.satoshisToByteString(shPreimage.value) + shPreimage.nSequence + shPreimage.hashSpentAmounts + shPreimage.hashSpentScriptHashes + shPreimage.hashSpentDataHashes + shPreimage.hashSequences + shPreimage.hashOutputs + StdUtils.toLEUnsigned(shPreimage.inputIndex, 4) + StdUtils.toLEUnsigned(shPreimage.nLockTime, 4) + num2bin(shPreimage.sigHashType, 4);
69
+ return SigHashPreimage(preimage);
70
+ }
71
+ static function checkPrevouts(bytes prevouts, bytes t_hashPrevouts, int t_inputIndex, int t_inputCount) : Outpoint {
72
+ require(hash256(prevouts) == t_hashPrevouts);
73
+ require(t_inputIndex < t_inputCount);
74
+ require(t_inputCount == StdUtils.checkLenDivisibleBy(prevouts, 36));
75
+ bytes b = prevouts[t_inputIndex * 36 : (t_inputIndex + 1) * 36];
76
+ return {b[0 : 32], StdUtils.byteStringToUInt32(b[32 : 36])};
77
+ }
78
+ static function checkSpentScripts(bytes spentScriptHashes, bytes t_hashSpentScripts, int t_inputCount) : bool {
79
+ require(hash256(spentScriptHashes) == t_hashSpentScripts);
80
+ require(t_inputCount == StdUtils.checkLenDivisibleBy(spentScriptHashes, 32));
81
+ return true;
82
+ }
83
+ static function checkSpentAmounts(bytes spentAmounts, bytes t_hashSpentAmounts) : int {
84
+ require(hash256(spentAmounts) == t_hashSpentAmounts);
85
+ return StdUtils.checkLenDivisibleBy(spentAmounts, 8);
86
+ }
87
+ static function checkSpentDataHashes(bytes spentDataHashes, bytes t_hashSpentDataHashes, int t_inputCount) : bool {
88
+ require(hash256(spentDataHashes) == t_hashSpentDataHashes);
89
+ require(t_inputCount == StdUtils.checkLenDivisibleBy(spentDataHashes, 32));
90
+ return true;
91
+ }
92
+ static function getSpentScriptHash(bytes spentScriptHashes, int inputIndex) : bytes {
93
+ return spentScriptHashes[inputIndex * 32 : (inputIndex + 1) * 32];
94
+ }
95
+ static function getSpentAmount(bytes spentAmounts, int inputIndex) : int {
96
+ return StdUtils.fromLEUnsigned(spentAmounts[inputIndex * 8 : (inputIndex + 1) * 8]);
97
+ }
98
+ static function getSpentDataHash(bytes spentDataHashes, int inputIndex) : bytes {
99
+ return spentDataHashes[inputIndex * 32 : (inputIndex + 1) * 32];
100
+ }
101
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/contextUtils.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/contextUtils.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[[9,0,5,13]],[[2,0,7,4],[8,0,7,21],[15,0,7,13]],[[2,0,15,4],[18,0,15,11],[25,0,15,23],[29,0,15,18]],[[4,0,16,8],[12,0,16,20],[20,0,16,15],[21,0,16,29],[26,0,16,34],[30,0,16,39],[37,0,16,15]],[],[]]
@@ -0,0 +1,7 @@
1
+
2
+ contract P2PK {
3
+ const PubKey pubKey;
4
+ public function unlock(Sig sig) {
5
+ require(checkSig(sig, this.pubKey));
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/p2pk.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/p2pk.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[[9,0,6,13]],[[2,0,8,4],[8,0,8,19],[18,0,8,13]],[[2,0,16,4],[18,0,16,11],[25,0,16,23],[29,0,16,18],[34,0,16,36],[41,0,16,28]],[[4,0,17,8],[12,0,18,12],[20,0,18,24],[28,0,18,12],[31,0,18,35],[35,0,18,40]],[[4,0,21,8],[12,0,21,20],[20,0,21,15],[21,0,21,29],[26,0,21,34],[32,0,21,15]],[],[]]
@@ -0,0 +1,8 @@
1
+
2
+ contract P2PKH {
3
+ const Ripemd160 addr;
4
+ public function unlock(Sig sig, PubKey pubkey) {
5
+ require(hash160(pubkey) == this.addr);
6
+ require(checkSig(sig, pubkey));
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/p2pkh.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/p2pkh.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[[8,0,12,13]],[]]
@@ -0,0 +1,3 @@
1
+
2
+ library StateLib {
3
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/stateLib.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/stateLib.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[[8,0,14,13]],[[2,0,22,2],[18,0,22,9],[34,0,23,18],[38,0,23,4],[52,0,24,14],[58,0,24,4],[68,0,25,23],[74,0,25,4]],[[4,0,27,4],[12,0,29,8],[30,0,30,8],[43,0,30,8],[45,0,30,23],[51,0,31,9],[64,0,31,9],[66,0,31,24],[69,0,31,8],[71,0,31,30],[75,0,28,6],[78,0,32,11],[85,0,32,18]],[],[],[]]
@@ -0,0 +1,7 @@
1
+
2
+ library StateUtils {
3
+ static function checkInputState(int t_inputIndex, bytes rawState, bytes t_spentDataHashes) : bool {
4
+ require(t_spentDataHashes[t_inputIndex * 32 : (t_inputIndex + 1) * 32] == sha256(rawState));
5
+ return true;
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/stateUtils.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/stateUtils.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[[7,0,12,24]],[[2,0,13,8],[8,0,13,2]],[[2,0,14,11],[6,0,14,2]],[],[],[[8,0,17,13]],[[2,0,19,2],[18,0,19,9],[38,0,19,32],[44,0,19,29],[47,0,19,47],[51,0,19,44],[56,0,19,56]],[[4,0,20,14],[8,0,20,10],[12,0,20,14],[16,0,20,18]],[[4,0,21,4],[12,0,21,11],[14,0,21,11],[16,0,21,15],[18,0,21,11],[21,0,21,20]],[[4,0,22,4],[11,0,22,11],[13,0,22,11],[15,0,22,15]],[],[[2,0,27,2],[18,0,27,9],[37,0,27,31],[41,0,27,28],[46,0,27,40]],[[4,0,28,4],[12,0,28,11],[14,0,28,11],[17,0,8,26],[19,0,28,11],[22,0,28,30],[24,0,28,30],[27,0,7,26]],[[4,0,29,4],[11,0,29,11],[19,0,29,20],[33,0,29,33],[36,0,29,36]],[],[[2,0,33,2],[18,0,33,9],[37,0,33,31],[41,0,33,28],[46,0,33,40]],[[4,0,34,4],[12,0,34,11],[14,0,34,11],[17,0,10,26],[19,0,34,11],[22,0,34,30],[24,0,34,30],[27,0,9,26]],[[4,0,35,4],[11,0,35,11],[19,0,35,20],[33,0,35,33],[36,0,35,36]],[],[[2,0,39,2],[18,0,39,9],[37,0,39,31],[43,0,39,28],[48,0,39,44]],[[4,0,40,4],[12,0,40,11],[16,0,40,15],[19,0,40,11],[22,0,40,21]],[[4,0,41,4],[11,0,41,11],[19,0,41,20],[35,0,41,35]],[],[[2,0,51,2],[18,0,51,9],[31,0,51,25],[35,0,51,22],[38,0,51,36],[42,0,51,33],[47,0,51,45]],[[4,0,52,14],[10,0,52,10],[14,0,52,14],[22,0,52,30],[25,0,52,33],[27,0,52,33],[29,0,52,37]],[[4,0,54,4],[11,0,54,17],[13,0,54,20],[17,0,54,24]],[],[[2,0,63,2],[18,0,63,9],[33,0,63,27],[39,0,63,24],[44,0,63,40]],[[4,0,64,4],[11,0,64,11],[18,0,64,27],[20,0,64,27],[22,0,64,44]],[],[[2,0,68,2],[18,0,68,9],[30,0,68,24],[34,0,68,21],[39,0,68,33]],[[4,0,69,11],[10,0,69,8],[14,0,69,37]],[[4,0,70,15],[8,0,70,8],[15,0,70,15]],[[4,0,71,4],[7,0,71,8],[9,0,71,8],[11,0,71,12]],[[8,0,72,6],[13,0,72,6],[15,0,72,13]],[[13,0,74,9],[16,0,74,13],[18,0,74,13],[20,0,74,17]],[[8,0,75,6],[10,0,75,6],[12,0,75,23]],[[8,0,76,6],[13,0,76,6],[15,0,76,13]],[[13,0,78,9],[16,0,78,13],[18,0,78,13],[20,0,78,17]],[[8,0,79,6],[10,0,79,6],[12,0,79,23]],[[8,0,80,6],[13,0,80,6],[15,0,80,13]],[],[[8,0,83,6],[10,0,83,6],[12,0,83,23]],[[8,0,84,6],[13,0,84,6],[15,0,84,13]],[],[[4,0,86,4],[11,0,86,11],[13,0,86,11],[15,0,86,15],[23,0,86,24],[37,0,86,37],[40,0,86,40]],[],[[2,0,96,2],[18,0,96,9],[27,0,96,23],[33,0,96,18],[40,0,96,36]],[[4,0,97,12],[8,0,97,8],[12,0,97,12],[16,0,97,16]],[[4,0,99,16],[10,0,99,8],[19,0,99,42]],[[4,0,101,4],[7,0,101,8],[9,0,101,8],[11,0,101,12]],[[8,0,102,6],[15,0,102,6],[17,0,102,15],[25,0,102,24],[39,0,102,37],[42,0,102,40]],[[13,0,104,9],[16,0,104,13],[18,0,104,13],[20,0,104,17]],[[8,0,105,6],[15,0,105,6],[17,0,105,28],[23,0,105,15],[25,0,105,36],[33,0,105,45],[47,0,105,58],[50,0,105,61]],[[13,0,107,9],[16,0,107,13],[18,0,107,13],[20,0,107,17]],[[8,0,108,6],[15,0,108,6],[17,0,108,28],[23,0,108,15],[25,0,108,36],[33,0,108,45],[47,0,108,58],[50,0,108,61]],[[13,0,110,9],[16,0,110,13],[18,0,110,13],[20,0,110,17]],[[8,0,111,6],[15,0,111,6],[17,0,111,28],[23,0,111,15],[25,0,111,36],[33,0,111,45],[47,0,111,58],[50,0,111,61]],[],[[8,0,115,6],[16,0,115,13]],[],[[4,0,118,4],[11,0,118,11],[18,0,118,11],[20,0,118,20]],[],[[2,0,127,2],[18,0,127,9],[29,0,127,25],[35,0,127,20],[40,0,127,42],[44,0,127,37],[51,0,127,51]],[[4,0,128,11],[8,0,128,8],[12,0,128,20]],[[4,0,129,13],[10,0,129,8],[16,0,129,39]],[[4,0,130,17],[8,0,130,8],[18,0,130,26]],[[4,0,131,18],[10,0,131,10],[19,0,131,37],[23,0,131,42],[29,0,131,47],[33,0,131,47],[35,0,131,53]],[[4,0,133,4],[7,0,133,8],[14,0,133,8],[17,0,133,31]],[[8,0,134,6],[10,0,134,6],[12,0,134,10],[20,0,134,19],[36,0,134,40],[40,0,134,45],[44,0,134,45],[46,0,134,51],[50,0,134,55],[54,0,134,55],[56,0,134,61]],[[8,0,135,6],[12,0,135,6],[14,0,135,18],[18,0,135,23],[22,0,135,27],[24,0,135,27],[26,0,135,32]],[[8,0,136,6],[16,0,136,6],[18,0,136,16],[22,0,136,16],[24,0,136,22],[26,0,136,16],[28,0,136,27]],[[13,0,138,9],[16,0,138,13],[23,0,138,13],[26,0,138,36]],[[8,0,139,6],[10,0,139,6],[12,0,139,10],[20,0,139,19],[36,0,139,40],[40,0,139,45],[44,0,139,45],[46,0,139,51],[50,0,139,55],[54,0,139,55],[56,0,139,61]],[[8,0,140,6],[12,0,140,6],[14,0,140,18],[18,0,140,23],[22,0,140,23],[24,0,140,29],[28,0,140,33],[32,0,140,33],[34,0,140,39],[36,0,140,33],[38,0,140,44]],[[8,0,141,6],[16,0,141,6],[18,0,141,16],[22,0,141,16],[24,0,141,22],[26,0,141,16],[28,0,141,27]],[[13,0,143,9],[16,0,143,13],[23,0,143,13],[26,0,143,36]],[[8,0,144,6],[10,0,144,6],[12,0,144,10],[20,0,144,19],[36,0,144,40],[40,0,144,45],[44,0,144,45],[46,0,144,51],[50,0,144,55],[54,0,144,55],[56,0,144,61]],[[8,0,145,6],[12,0,145,6],[14,0,145,18],[18,0,145,23],[22,0,145,23],[24,0,145,29],[28,0,145,33],[32,0,145,33],[34,0,145,39],[36,0,145,33],[38,0,145,44]],[[8,0,146,6],[16,0,146,6],[18,0,146,16],[22,0,146,16],[24,0,146,22],[26,0,146,16],[28,0,146,27]],[],[[8,0,148,6],[10,0,148,6],[12,0,148,10],[20,0,148,19],[36,0,148,40],[40,0,148,45],[46,0,148,50],[50,0,148,50],[52,0,148,56]],[[8,0,149,6],[12,0,149,6],[14,0,149,18],[18,0,149,23],[22,0,149,23],[24,0,149,29],[28,0,149,33],[32,0,149,33],[34,0,149,39],[36,0,149,33],[38,0,149,44]],[[8,0,150,6],[16,0,150,6],[18,0,150,16],[22,0,150,16],[24,0,150,22],[26,0,150,16],[28,0,150,27]],[],[[4,0,153,4],[11,0,153,11],[12,0,153,19],[17,0,153,33]],[],[]]
@@ -0,0 +1,89 @@
1
+
2
+ struct ReadVarintResult {
3
+ bytes data;
4
+ int nextPos;
5
+ }
6
+
7
+ library StdUtils {
8
+ static function checkLenDivisibleBy(bytes b, int n) : int {
9
+ int l = len(b);
10
+ require(l % n == 0);
11
+ return l / n;
12
+ }
13
+ static function uint64ToByteString(int n) : bytes {
14
+ require(n >= 0 && n <= 18446744073709551615);
15
+ return StdUtils.toLEUnsigned(n, 8);
16
+ }
17
+ static function uint32ToByteString(int n) : bytes {
18
+ require(n >= 0 && n <= 4294967295);
19
+ return StdUtils.toLEUnsigned(n, 4);
20
+ }
21
+ static function byteStringToUInt32(bytes b) : int {
22
+ require(len(b) == 4);
23
+ return StdUtils.fromLEUnsigned(b);
24
+ }
25
+ static function toLEUnsigned(int n, int l) : bytes {
26
+ bytes m = num2bin(n, l + 1);
27
+ return m[0 : l];
28
+ }
29
+ static function fromLEUnsigned(bytes b) : int {
30
+ return unpack(b + b'00');
31
+ }
32
+ static function writeVarInt(int n) : bytes {
33
+ bytes b = b'';
34
+ int size = 0;
35
+ if(n < 0xfd) {
36
+ size = 1;
37
+ } else if(n < 0x10000) {
38
+ b = b'fd';
39
+ size = 2;
40
+ } else if(n < 0x100000000) {
41
+ b = b'fe';
42
+ size = 4;
43
+ } else {
44
+ b = b'ff';
45
+ size = 8;
46
+ }
47
+ return b + StdUtils.toLEUnsigned(n, size);
48
+ }
49
+ static function pushData(bytes buf) : bytes {
50
+ int n = len(buf);
51
+ bytes header = b'';
52
+ if(n < 0x4c) {
53
+ header = StdUtils.toLEUnsigned(n, 1);
54
+ } else if(n < 0x100) {
55
+ header = b'4c' + StdUtils.toLEUnsigned(n, 1);
56
+ } else if(n < 0x10000) {
57
+ header = b'4d' + StdUtils.toLEUnsigned(n, 2);
58
+ } else if(n < 0x100000000) {
59
+ header = b'4e' + StdUtils.toLEUnsigned(n, 4);
60
+ } else {
61
+ require(false);
62
+ }
63
+ return header + buf;
64
+ }
65
+ static function readVarint(bytes buf, int pos) : ReadVarintResult {
66
+ int l = 0;
67
+ bytes ret = b'';
68
+ int nextPos = pos;
69
+ bytes header = buf[pos : pos + 1];
70
+ if(header == b'fd') {
71
+ l = StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 3]);
72
+ ret = buf[3 : 3 + l];
73
+ nextPos = pos + 3 + l;
74
+ } else if(header == b'fe') {
75
+ l = StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 5]);
76
+ ret = buf[pos + 5 : pos + 5 + l];
77
+ nextPos = pos + 5 + l;
78
+ } else if(header == b'ff') {
79
+ l = StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 9]);
80
+ ret = buf[pos + 9 : pos + 9 + l];
81
+ nextPos = pos + 9 + l;
82
+ } else {
83
+ l = StdUtils.fromLEUnsigned(buf[pos : pos + 1]);
84
+ ret = buf[pos + 1 : pos + 1 + l];
85
+ nextPos = pos + 1 + l;
86
+ }
87
+ return {ret, nextPos};
88
+ }
89
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/stdUtils.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/stdUtils.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[],[],[],[[8,0,29,13]],[[2,0,32,2],[9,0,32,9],[15,0,32,29],[19,0,32,18],[31,0,32,38]],[[2,0,41,2],[18,0,41,9],[30,0,41,33],[36,0,41,21],[48,0,41,55],[52,0,41,45],[64,0,41,64]],[[4,0,42,4],[11,0,42,11],[18,0,42,19],[35,0,42,35],[47,0,42,47],[57,0,42,57],[64,0,42,77]],[],[[2,0,53,2],[18,0,53,9],[34,0,53,37],[40,0,53,25],[52,0,53,59],[56,0,53,49],[66,0,53,77],[72,0,53,67],[84,0,53,90]],[[4,0,54,26],[8,0,54,10],[24,0,54,26],[28,0,54,30]],[[4,0,55,24],[8,0,55,10],[22,0,55,24],[26,0,55,28]],[[4,0,57,4],[12,0,57,11],[26,0,57,11],[29,0,57,28]],[[4,0,58,4],[12,0,58,11],[24,0,58,11],[27,0,58,26]],[[4,0,59,4],[12,0,59,11],[21,0,59,11],[24,0,59,23]],[[4,0,60,4],[11,0,60,11],[19,0,60,27],[29,0,60,37],[32,0,60,11],[34,0,60,43],[45,0,60,11],[47,0,60,56]],[],[[2,0,69,2],[18,0,69,9],[36,0,69,35],[42,0,69,27],[52,0,69,43]],[[4,0,70,4],[11,0,70,11],[17,0,70,18],[27,0,70,11],[29,0,70,29],[33,0,71,8],[40,0,71,16],[57,0,71,32],[63,0,71,39],[76,0,71,51],[82,0,71,58],[93,0,71,68],[99,0,71,75],[112,0,72,21]],[],[[2,0,81,2],[18,0,81,9],[29,0,81,29],[34,0,81,20],[45,0,81,36]],[[4,0,82,4],[12,0,82,11],[16,0,82,15],[23,0,82,23],[36,0,82,11],[39,0,82,38]],[[4,0,83,4],[12,0,83,11],[16,0,83,15],[23,0,83,23],[36,0,83,11],[39,0,83,38]],[[4,0,84,4],[12,0,85,6],[19,0,85,14],[31,0,85,6],[33,0,86,6],[41,0,86,15],[61,0,86,34],[68,0,86,42],[86,0,85,6],[88,0,87,6],[95,0,87,14],[107,0,85,6],[109,0,88,6],[117,0,88,15],[137,0,88,34],[144,0,88,42]],[],[[2,0,98,2],[18,0,98,9],[38,0,98,35],[44,0,98,29],[52,0,98,48]],[[4,0,99,19],[10,0,99,10],[19,0,99,32],[25,0,99,19],[27,0,99,40],[32,0,99,56],[36,0,99,60],[43,0,99,19],[45,0,99,69]],[[4,0,100,4],[11,0,100,11],[18,0,100,19],[40,0,32,38],[43,0,100,11],[45,0,100,61],[52,0,100,68],[60,0,100,11],[62,0,100,78],[69,0,100,98]],[],[[2,0,109,2],[18,0,109,9],[35,0,109,32],[45,0,109,26],[53,0,109,39]],[[4,0,110,4],[12,0,111,19],[18,0,111,26],[26,0,111,6],[28,0,112,19],[34,0,112,26],[46,0,111,6],[48,0,113,6],[53,0,113,22],[57,0,111,6],[59,0,114,6],[64,0,111,6],[66,0,115,19],[72,0,115,26],[88,0,111,6],[90,0,116,19],[96,0,116,26]],[],[[2,0,127,2],[18,0,127,9],[35,0,127,34],[39,0,127,26],[47,0,127,48],[57,0,127,42],[63,0,127,64],[69,0,127,54],[81,0,127,77]],[[4,0,128,4],[11,0,128,11],[18,0,128,19],[35,0,128,35],[42,0,128,42],[49,0,128,50],[67,0,128,67],[75,0,128,75],[83,0,128,83]],[],[[2,0,137,2],[18,0,137,9],[38,0,137,35],[44,0,137,29],[52,0,137,48]],[[4,0,138,4],[11,0,138,24],[17,0,138,31],[27,0,138,11],[29,0,138,56],[35,0,138,63],[46,0,138,11],[48,0,138,76],[56,0,138,85],[66,0,138,94]],[],[[2,0,147,2],[18,0,147,9],[39,0,147,33],[43,0,147,30],[48,0,147,42]],[[4,0,148,4],[11,0,148,11],[19,0,148,20],[39,0,148,39]],[],[]]
@@ -0,0 +1,42 @@
1
+ import "../types/structs.scrypt.tpl";
2
+ import "./stdUtils.scrypt.tpl";
3
+
4
+
5
+ library TxUtils {
6
+ static const int ZERO_SATS = 0;
7
+ static function buildOutput(bytes scriptHash, int satoshis) : bytes {
8
+ return TxUtils.buildDataOutput(scriptHash, satoshis, sha256(b''));
9
+ }
10
+ static function buildDataOutput(bytes scriptHash, int satoshis, bytes dataHash) : bytes {
11
+ int scriptHashLen = len(scriptHash);
12
+ int dataHashLen = len(dataHash);
13
+ require(scriptHashLen == 32);
14
+ require(dataHashLen == 32);
15
+ require(satoshis >= 0);
16
+ return num2bin(satoshis, 8) + scriptHash + dataHash;
17
+ }
18
+ static function buildChangeOutput(TxOut change) : bytes {
19
+ return change.satoshis > 0 ? TxUtils.buildDataOutput(change.scriptHash, change.satoshis, change.dataHash) : b'';
20
+ }
21
+ static function mergeInput(TxIn txInput) : bytes {
22
+ require(len(txInput.prevTxHash) == 32);
23
+ require(len(txInput.scriptHash) == 32);
24
+ return (txInput.prevTxHash + StdUtils.uint32ToByteString(txInput.prevOutputIndex) + txInput.scriptHash + StdUtils.uint32ToByteString(txInput.sequence));
25
+ }
26
+ static function buildOpReturnOutput(bytes data) : bytes {
27
+ bytes script = b'6a' + pack(len(data)) + data;
28
+ return TxUtils.satoshisToByteString(0) + sha256(script) + sha256(b'');
29
+ }
30
+ static function buildP2PKHScript(Ripemd160 addr) : bytes {
31
+ return (OpCode.OP_DUP + OpCode.OP_HASH160 + pack(20) + addr + OpCode.OP_EQUALVERIFY + OpCode.OP_CHECKSIG);
32
+ }
33
+ static function buildP2PKHOutput(int amount, Ripemd160 addr, bytes dataHash) : bytes {
34
+ return TxUtils.buildDataOutput(sha256(TxUtils.buildP2PKHScript(addr)), amount, dataHash);
35
+ }
36
+ static function buildOpreturnScript(bytes data) : bytes {
37
+ return OpCode.OP_FALSE + OpCode.OP_RETURN + StdUtils.pushData(data);
38
+ }
39
+ static function satoshisToByteString(int n) : bytes {
40
+ return StdUtils.uint64ToByteString(n);
41
+ }
42
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": [],
4
+ "scryptfile": "smart-contract/builtin-libs/txUtils.scrypt.tpl",
5
+ "sourceMapFile": "smart-contract/builtin-libs/txUtils.scrypt.map",
6
+ "ctxMethods": []
7
+ }
@@ -0,0 +1 @@
1
+ [[],[[7,0,24,20]],[[2,0,25,14],[8,0,25,2]],[[2,0,26,12],[8,0,26,2]],[[2,0,27,12],[6,0,27,2]],[],[],[[7,0,35,19]],[[2,0,40,14],[8,0,40,2]],[[2,0,46,19],[6,0,46,2]],[[2,0,52,12],[6,0,52,2]],[[2,0,58,14],[8,0,58,2]],[],[],[[7,0,192,29]],[[2,0,196,11],[8,0,196,2]],[[2,0,202,13],[8,0,202,2]],[[2,0,208,14],[8,0,208,2]],[[2,0,213,13],[8,0,213,2]],[],[],[[7,0,223,28]],[[2,0,228,15],[7,0,228,2]],[[2,0,234,20],[6,0,234,2]],[[2,0,240,22],[17,0,240,2]],[],[],[[7,0,66,25]],[[2,0,71,12],[8,0,71,2]],[[2,0,77,16],[8,0,77,2]],[[2,0,83,19],[8,0,83,2]],[[2,0,89,17],[8,0,89,2]],[[2,0,94,9],[6,0,94,2]],[[2,0,99,13],[8,0,99,2]],[[2,0,105,20],[8,0,105,2]],[[2,0,111,25],[8,0,111,2]],[[2,0,117,23],[8,0,117,2]],[[2,0,123,17],[8,0,123,2]],[[2,0,129,15],[8,0,129,2]],[[2,0,134,14],[6,0,134,2]],[[2,0,140,13],[6,0,140,2]],[[2,0,145,15],[6,0,145,2]],[],[],[[7,0,7,23]],[[2,0,11,10],[8,0,11,2]],[[2,0,16,15],[6,0,16,2]],[]]