@opcat-labs/scrypt-ts-opcat 3.2.0 → 3.4.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 (45) hide show
  1. package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.map +1 -1
  2. package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.tpl +1 -1
  3. package/assets/.templates/smart-contract/types/structs.scrypt.tpl +7 -1
  4. package/assets/smart-contract/builtin-libs/backtrace.scrypt +13 -13
  5. package/assets/smart-contract/builtin-libs/byteStringReader.scrypt +5 -5
  6. package/assets/smart-contract/builtin-libs/byteStringWriter.scrypt +6 -6
  7. package/assets/smart-contract/builtin-libs/contextUtils.scrypt +16 -16
  8. package/assets/smart-contract/builtin-libs/genesis.scrypt +8 -8
  9. package/assets/smart-contract/builtin-libs/p2pk.scrypt +1 -1
  10. package/assets/smart-contract/builtin-libs/p2pkh.scrypt +1 -1
  11. package/assets/smart-contract/builtin-libs/stateLib.scrypt +1 -1
  12. package/assets/smart-contract/builtin-libs/stateUtils.scrypt +1 -1
  13. package/assets/smart-contract/builtin-libs/stdUtils.scrypt +13 -13
  14. package/assets/smart-contract/builtin-libs/txHashPreimageUtils.scrypt +7 -7
  15. package/assets/smart-contract/builtin-libs/txUtils.scrypt +12 -12
  16. package/assets/smart-contract/types/structs.scrypt +8 -8
  17. package/dist/cjs/psbt/extPsbt.cjs +14 -4
  18. package/dist/cjs/psbt/extPsbt.js.map +1 -1
  19. package/dist/cjs/smart-contract/builtin-libs/stdUtils.cjs +1 -1
  20. package/dist/cjs/smart-contract/builtin-libs/stdUtils.js.map +1 -1
  21. package/dist/cjs/smart-contract/methods/buildOutput.cjs +3 -1
  22. package/dist/cjs/smart-contract/methods/buildOutput.js.map +1 -1
  23. package/dist/cjs/smart-contract/types/index.js.map +1 -1
  24. package/dist/esm/psbt/extPsbt.js +15 -5
  25. package/dist/esm/psbt/extPsbt.js.map +1 -1
  26. package/dist/esm/smart-contract/builtin-libs/stdUtils.js +1 -1
  27. package/dist/esm/smart-contract/builtin-libs/stdUtils.js.map +1 -1
  28. package/dist/esm/smart-contract/methods/buildOutput.js +3 -1
  29. package/dist/esm/smart-contract/methods/buildOutput.js.map +1 -1
  30. package/dist/esm/smart-contract/types/index.js.map +1 -1
  31. package/dist/types/psbt/extPsbt.d.ts +5 -4
  32. package/dist/types/psbt/extPsbt.d.ts.map +1 -1
  33. package/dist/types/smart-contract/methods/buildOutput.d.ts.map +1 -1
  34. package/dist/types/smart-contract/smartContract.d.ts +1 -1
  35. package/dist/types/smart-contract/smartContract.d.ts.map +1 -1
  36. package/dist/types/smart-contract/types/context.d.ts +2 -2
  37. package/dist/types/smart-contract/types/context.d.ts.map +1 -1
  38. package/dist/types/smart-contract/types/index.d.ts +1 -1
  39. package/dist/types/smart-contract/types/index.d.ts.map +1 -1
  40. package/dist/types/smart-contract/types/structs.d.ts +20 -1
  41. package/dist/types/smart-contract/types/structs.d.ts.map +1 -1
  42. package/package.json +2 -2
  43. package/scrypt.index.json +4 -0
  44. package/src/smart-contract/builtin-libs/stdUtils.ts +1 -1
  45. package/src/smart-contract/types/structs.ts +21 -1
@@ -1 +1 @@
1
- [[],[[7,0,12,24]],[[2,0,13,8],[8,0,13,2]],[[2,0,14,11],[6,0,14,2]],[],[],[[8,0,27,13]],[[2,0,36,2],[18,0,36,9],[38,0,36,32],[44,0,36,29],[47,0,36,47],[51,0,36,44],[56,0,36,56]],[[4,0,37,14],[8,0,37,10],[12,0,37,14],[16,0,37,18]],[[4,0,38,4],[12,0,38,11],[14,0,38,11],[16,0,38,15],[18,0,38,11],[21,0,38,20]],[[4,0,39,4],[11,0,39,11],[13,0,39,11],[15,0,39,15]],[],[[2,0,50,2],[18,0,50,9],[37,0,50,31],[41,0,50,28],[46,0,50,40]],[[4,0,51,4],[12,0,51,11],[14,0,51,11],[17,0,8,26],[19,0,51,11],[22,0,51,30],[24,0,51,30],[27,0,7,26]],[[4,0,52,4],[11,0,52,11],[19,0,52,20],[33,0,52,33],[36,0,52,36]],[],[[2,0,62,2],[18,0,62,9],[37,0,62,31],[41,0,62,28],[46,0,62,40]],[[4,0,63,4],[12,0,63,11],[14,0,63,11],[17,0,10,26],[19,0,63,11],[22,0,63,30],[24,0,63,30],[27,0,9,26]],[[4,0,64,4],[11,0,64,11],[19,0,64,20],[33,0,64,33],[36,0,64,36]],[],[[2,0,74,2],[18,0,74,9],[37,0,74,31],[43,0,74,28],[48,0,74,44]],[[4,0,75,4],[12,0,75,11],[16,0,75,15],[19,0,75,11],[22,0,75,21]],[[4,0,76,4],[11,0,76,11],[19,0,76,20],[35,0,76,35]],[],[[2,0,86,2],[18,0,86,9],[31,0,86,25],[35,0,86,22],[38,0,86,36],[42,0,86,33],[47,0,86,45]],[[4,0,87,14],[10,0,87,10],[14,0,87,14],[22,0,87,30],[25,0,87,33],[27,0,87,33],[29,0,87,37]],[[4,0,89,4],[11,0,89,17],[13,0,89,20],[17,0,89,24]],[],[[2,0,98,2],[18,0,98,9],[33,0,98,27],[39,0,98,24],[44,0,98,40]],[[4,0,99,4],[11,0,99,11],[18,0,99,27],[20,0,99,27],[22,0,99,44]],[],[[2,0,113,2],[18,0,113,9],[30,0,113,24],[34,0,113,21],[39,0,113,33]],[[4,0,114,11],[10,0,114,8],[14,0,114,37]],[[4,0,115,15],[8,0,115,8],[15,0,115,15]],[[4,0,116,4],[7,0,116,8],[9,0,116,8],[11,0,116,12]],[[8,0,117,6],[13,0,117,6],[15,0,117,13]],[[13,0,119,9],[16,0,119,13],[18,0,119,13],[20,0,119,17]],[[8,0,120,6],[10,0,120,6],[12,0,120,23]],[[8,0,121,6],[13,0,121,6],[15,0,121,13]],[[13,0,123,9],[16,0,123,13],[18,0,123,13],[20,0,123,17]],[[8,0,124,6],[10,0,124,6],[12,0,124,23]],[[8,0,125,6],[13,0,125,6],[15,0,125,13]],[],[[8,0,128,6],[10,0,128,6],[12,0,128,23]],[[8,0,129,6],[13,0,129,6],[15,0,129,13]],[],[[4,0,131,4],[11,0,131,11],[13,0,131,11],[15,0,131,15],[23,0,131,24],[37,0,131,37],[40,0,131,40]],[],[[2,0,148,2],[18,0,148,9],[27,0,148,23],[33,0,148,18],[40,0,148,36]],[[4,0,149,14],[8,0,149,10],[12,0,149,14],[16,0,149,18]],[[4,0,150,15],[8,0,150,8],[15,0,150,15]],[[4,0,151,16],[10,0,151,8],[19,0,151,42]],[[4,0,153,4],[7,0,153,8],[9,0,153,8],[11,0,153,12]],[[8,0,154,6],[13,0,154,6],[15,0,154,13]],[[8,0,155,6],[15,0,155,6],[17,0,155,28]],[[13,0,157,9],[16,0,157,13],[18,0,157,13],[20,0,157,17]],[[8,0,158,6],[13,0,158,6],[15,0,158,13]],[[8,0,159,6],[15,0,159,6],[17,0,159,28]],[[13,0,161,9],[16,0,161,13],[18,0,161,13],[20,0,161,17]],[[8,0,162,6],[13,0,162,6],[15,0,162,13]],[[8,0,163,6],[15,0,163,6],[17,0,163,28]],[[13,0,165,9],[16,0,165,13],[18,0,165,13],[20,0,165,17]],[[8,0,166,6],[13,0,166,6],[15,0,166,13]],[[8,0,167,6],[15,0,167,6],[17,0,167,28]],[],[[8,0,171,6],[16,0,171,13]],[],[[4,0,174,4],[11,0,174,11],[18,0,174,11],[20,0,174,20],[28,0,174,29],[42,0,174,42],[45,0,174,45]],[],[[2,0,183,2],[18,0,183,9],[29,0,183,25],[35,0,183,20],[40,0,183,42],[44,0,183,37],[51,0,183,51]],[[4,0,184,11],[8,0,184,8],[12,0,184,20]],[[4,0,185,13],[10,0,185,8],[16,0,185,39]],[[4,0,186,17],[8,0,186,8],[18,0,186,26]],[[4,0,187,18],[10,0,187,10],[19,0,187,37],[23,0,187,42],[29,0,187,47],[33,0,187,47],[35,0,187,53]],[[4,0,189,4],[7,0,189,8],[14,0,189,8],[17,0,189,31]],[[8,0,190,6],[10,0,190,6],[12,0,190,10],[20,0,190,19],[36,0,190,40],[40,0,190,45],[44,0,190,45],[46,0,190,51],[50,0,190,55],[54,0,190,55],[56,0,190,61]],[[8,0,191,6],[12,0,191,6],[14,0,191,18],[18,0,191,23],[22,0,191,27],[24,0,191,27],[26,0,191,32]],[[8,0,192,6],[16,0,192,6],[18,0,192,16],[22,0,192,16],[24,0,192,22],[26,0,192,16],[28,0,192,27]],[[13,0,194,9],[16,0,194,13],[23,0,194,13],[26,0,194,36]],[[8,0,195,6],[10,0,195,6],[12,0,195,10],[20,0,195,19],[36,0,195,40],[40,0,195,45],[44,0,195,45],[46,0,195,51],[50,0,195,55],[54,0,195,55],[56,0,195,61]],[[8,0,196,6],[12,0,196,6],[14,0,196,18],[18,0,196,23],[22,0,196,23],[24,0,196,29],[28,0,196,33],[32,0,196,33],[34,0,196,39],[36,0,196,33],[38,0,196,44]],[[8,0,197,6],[16,0,197,6],[18,0,197,16],[22,0,197,16],[24,0,197,22],[26,0,197,16],[28,0,197,27]],[[13,0,199,9],[16,0,199,13],[23,0,199,13],[26,0,199,36]],[[8,0,200,6],[10,0,200,6],[12,0,200,10],[20,0,200,19],[36,0,200,40],[40,0,200,45],[44,0,200,45],[46,0,200,51],[50,0,200,55],[54,0,200,55],[56,0,200,61]],[[8,0,201,6],[12,0,201,6],[14,0,201,18],[18,0,201,23],[22,0,201,23],[24,0,201,29],[28,0,201,33],[32,0,201,33],[34,0,201,39],[36,0,201,33],[38,0,201,44]],[[8,0,202,6],[16,0,202,6],[18,0,202,16],[22,0,202,16],[24,0,202,22],[26,0,202,16],[28,0,202,27]],[],[[8,0,204,6],[10,0,204,6],[12,0,204,10],[20,0,204,19],[36,0,204,40],[40,0,204,45],[46,0,204,50],[50,0,204,50],[52,0,204,56]],[[8,0,205,6],[12,0,205,6],[14,0,205,18],[18,0,205,23],[22,0,205,23],[24,0,205,29],[28,0,205,33],[32,0,205,33],[34,0,205,39],[36,0,205,33],[38,0,205,44]],[[8,0,206,6],[16,0,206,6],[18,0,206,16],[22,0,206,16],[24,0,206,22],[26,0,206,16],[28,0,206,27]],[],[[4,0,209,4],[11,0,209,11],[12,0,209,19],[17,0,209,33]],[],[]]
1
+ [[],[[7,0,12,24]],[[2,0,13,8],[8,0,13,2]],[[2,0,14,11],[6,0,14,2]],[],[],[[8,0,27,13]],[[2,0,36,2],[18,0,36,9],[38,0,36,32],[44,0,36,29],[47,0,36,47],[51,0,36,44],[56,0,36,56]],[[4,0,37,14],[8,0,37,10],[12,0,37,14],[16,0,37,18]],[[4,0,38,4],[12,0,38,11],[14,0,38,11],[16,0,38,15],[18,0,38,11],[21,0,38,20]],[[4,0,39,4],[11,0,39,11],[13,0,39,11],[15,0,39,15]],[],[[2,0,50,2],[18,0,50,9],[37,0,50,31],[41,0,50,28],[46,0,50,40]],[[4,0,51,4],[12,0,51,11],[14,0,51,11],[17,0,8,26],[19,0,51,11],[22,0,51,30],[24,0,51,30],[27,0,7,26]],[[4,0,52,4],[11,0,52,11],[19,0,52,20],[33,0,52,33],[36,0,52,36]],[],[[2,0,62,2],[18,0,62,9],[37,0,62,31],[41,0,62,28],[46,0,62,40]],[[4,0,63,4],[12,0,63,11],[14,0,63,11],[17,0,10,26],[19,0,63,11],[22,0,63,30],[24,0,63,30],[27,0,9,26]],[[4,0,64,4],[11,0,64,11],[19,0,64,20],[33,0,64,33],[36,0,64,36]],[],[[2,0,74,2],[18,0,74,9],[37,0,74,31],[43,0,74,28],[48,0,74,44]],[[4,0,75,4],[12,0,75,11],[16,0,75,15],[19,0,75,11],[22,0,75,21]],[[4,0,76,4],[11,0,76,11],[19,0,76,20],[35,0,76,35]],[],[[2,0,86,2],[18,0,86,9],[31,0,86,25],[35,0,86,22],[38,0,86,36],[42,0,86,33],[47,0,86,45]],[[4,0,87,14],[10,0,87,10],[14,0,87,14],[22,0,87,30],[25,0,87,33],[27,0,87,33],[29,0,87,37]],[[4,0,89,4],[11,0,89,17],[13,0,89,20],[17,0,89,24]],[],[[2,0,98,2],[18,0,98,9],[33,0,98,27],[39,0,98,24],[44,0,98,40]],[[4,0,99,4],[11,0,99,11],[18,0,99,27],[20,0,99,27],[22,0,99,44]],[],[[2,0,113,2],[18,0,113,9],[30,0,113,24],[34,0,113,21],[39,0,113,33]],[[4,0,114,11],[10,0,114,8],[14,0,114,37]],[[4,0,115,15],[8,0,115,8],[15,0,115,15]],[[4,0,116,4],[7,0,116,8],[9,0,116,8],[11,0,116,12]],[[8,0,117,6],[13,0,117,6],[15,0,117,13]],[[13,0,119,9],[16,0,119,13],[18,0,119,13],[20,0,119,17]],[[8,0,120,6],[10,0,120,6],[12,0,120,23]],[[8,0,121,6],[13,0,121,6],[15,0,121,13]],[[13,0,123,9],[16,0,123,13],[18,0,123,13],[20,0,123,17]],[[8,0,124,6],[10,0,124,6],[12,0,124,23]],[[8,0,125,6],[13,0,125,6],[15,0,125,13]],[],[[8,0,128,6],[10,0,128,6],[12,0,128,23]],[[8,0,129,6],[13,0,129,6],[15,0,129,13]],[],[[4,0,131,4],[11,0,131,11],[13,0,131,11],[15,0,131,15],[23,0,131,24],[37,0,131,37],[40,0,131,40]],[],[[2,0,148,2],[18,0,148,9],[27,0,148,23],[33,0,148,18],[40,0,148,36]],[[4,0,149,14],[8,0,149,10],[12,0,149,14],[16,0,149,18]],[[4,0,150,15],[8,0,150,8],[15,0,150,15]],[[4,0,151,16],[10,0,151,8],[19,0,151,42]],[[4,0,153,4],[7,0,153,8],[9,0,153,8],[11,0,153,12]],[[8,0,154,6],[13,0,154,6],[15,0,154,13]],[[8,0,155,6],[15,0,155,6],[17,0,155,28]],[[13,0,157,9],[16,0,157,13],[18,0,157,13],[20,0,157,17]],[[8,0,158,6],[13,0,158,6],[15,0,158,13]],[[8,0,159,6],[15,0,159,6],[17,0,159,28]],[[13,0,161,9],[16,0,161,13],[18,0,161,13],[20,0,161,17]],[[8,0,162,6],[13,0,162,6],[15,0,162,13]],[[8,0,163,6],[15,0,163,6],[17,0,163,28]],[[13,0,165,9],[16,0,165,13],[18,0,165,13],[20,0,165,17]],[[8,0,166,6],[13,0,166,6],[15,0,166,13]],[[8,0,167,6],[15,0,167,6],[17,0,167,28]],[],[[8,0,171,6],[16,0,171,13]],[],[[4,0,174,4],[11,0,174,11],[18,0,174,11],[20,0,174,20],[28,0,174,29],[42,0,174,42],[45,0,174,45]],[],[[2,0,183,2],[18,0,183,9],[29,0,183,25],[35,0,183,20],[40,0,183,42],[44,0,183,37],[51,0,183,51]],[[4,0,184,11],[8,0,184,8],[12,0,184,20]],[[4,0,185,13],[10,0,185,8],[16,0,185,39]],[[4,0,186,17],[8,0,186,8],[18,0,186,26]],[[4,0,187,18],[10,0,187,10],[19,0,187,37],[23,0,187,42],[29,0,187,47],[33,0,187,47],[35,0,187,53]],[[4,0,189,4],[7,0,189,8],[14,0,189,8],[17,0,189,31]],[[8,0,190,6],[10,0,190,6],[12,0,190,10],[20,0,190,19],[36,0,190,40],[40,0,190,45],[44,0,190,45],[46,0,190,51],[50,0,190,55],[54,0,190,55],[56,0,190,61]],[[8,0,191,6],[12,0,191,6],[14,0,191,18],[18,0,191,23],[22,0,191,23],[24,0,191,29],[28,0,191,33],[32,0,191,33],[34,0,191,39],[36,0,191,33],[38,0,191,44]],[[8,0,192,6],[16,0,192,6],[18,0,192,16],[22,0,192,16],[24,0,192,22],[26,0,192,16],[28,0,192,27]],[[13,0,194,9],[16,0,194,13],[23,0,194,13],[26,0,194,36]],[[8,0,195,6],[10,0,195,6],[12,0,195,10],[20,0,195,19],[36,0,195,40],[40,0,195,45],[44,0,195,45],[46,0,195,51],[50,0,195,55],[54,0,195,55],[56,0,195,61]],[[8,0,196,6],[12,0,196,6],[14,0,196,18],[18,0,196,23],[22,0,196,23],[24,0,196,29],[28,0,196,33],[32,0,196,33],[34,0,196,39],[36,0,196,33],[38,0,196,44]],[[8,0,197,6],[16,0,197,6],[18,0,197,16],[22,0,197,16],[24,0,197,22],[26,0,197,16],[28,0,197,27]],[[13,0,199,9],[16,0,199,13],[23,0,199,13],[26,0,199,36]],[[8,0,200,6],[10,0,200,6],[12,0,200,10],[20,0,200,19],[36,0,200,40],[40,0,200,45],[44,0,200,45],[46,0,200,51],[50,0,200,55],[54,0,200,55],[56,0,200,61]],[[8,0,201,6],[12,0,201,6],[14,0,201,18],[18,0,201,23],[22,0,201,23],[24,0,201,29],[28,0,201,33],[32,0,201,33],[34,0,201,39],[36,0,201,33],[38,0,201,44]],[[8,0,202,6],[16,0,202,6],[18,0,202,16],[22,0,202,16],[24,0,202,22],[26,0,202,16],[28,0,202,27]],[],[[8,0,204,6],[10,0,204,6],[12,0,204,10],[20,0,204,19],[36,0,204,40],[40,0,204,45],[46,0,204,50],[50,0,204,50],[52,0,204,56]],[[8,0,205,6],[12,0,205,6],[14,0,205,18],[18,0,205,23],[22,0,205,23],[24,0,205,29],[28,0,205,33],[32,0,205,33],[34,0,205,39],[36,0,205,33],[38,0,205,44]],[[8,0,206,6],[16,0,206,6],[18,0,206,16],[22,0,206,16],[24,0,206,22],[26,0,206,16],[28,0,206,27]],[],[[4,0,209,4],[11,0,209,11],[12,0,209,19],[17,0,209,33]],[],[]]
@@ -74,7 +74,7 @@ library StdUtils {
74
74
  bytes header = buf[pos : pos + 1];
75
75
  if(header == b'fd') {
76
76
  l = StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 3]);
77
- ret = buf[3 : 3 + l];
77
+ ret = buf[pos + 3 : pos + 3 + l];
78
78
  nextPos = pos + 3 + l;
79
79
  } else if(header == b'fe') {
80
80
  l = StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 5]);
@@ -45,4 +45,10 @@ struct SHPreimage {
45
45
  struct Outpoint {
46
46
  bytes txHash;
47
47
  int outputIndex;
48
- }
48
+ }
49
+
50
+ struct ChangeInfo {
51
+ Ripemd160 pubkeyhash;
52
+ int satoshis;
53
+ Sha256 dataHash;
54
+ }
@@ -6,37 +6,37 @@ import "stdUtils.scrypt";
6
6
 
7
7
 
8
8
 
9
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ChainTxVerifyResponse {
9
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ChainTxVerifyResponse {
10
10
  bytes prevPrevScript;
11
11
  bytes prevPrevOutpoint;
12
12
  }
13
13
 
14
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Backtrace {
14
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__Backtrace {
15
15
  static const bytes GENESIS_SCRIPT_HASH = b'836c4b45ab7a625549ca7c799b02d3304adf996557929ee809613e602d26c1f8';
16
- static function checkPrevTxHashPreimage(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimage txHashPreimage, bytes t_prevouts, int t_inputIndex) : bool {
17
- bytes txHash = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimageUtils.getTxHashFromTxHashPreimage(txHashPreimage);
16
+ static function checkPrevTxHashPreimage(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimage txHashPreimage, bytes t_prevouts, int t_inputIndex) : bool {
17
+ bytes txHash = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimageUtils.getTxHashFromTxHashPreimage(txHashPreimage);
18
18
  require(txHash == t_prevouts[t_inputIndex * 36 : t_inputIndex * 36 + 32]);
19
19
  return true;
20
20
  }
21
- static function verifyFromOutpoint(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__BacktraceInfo backtraceInfo, bytes t_genesisOutpoint, bytes t_selfScript, bytes t_prevTxInputList) : bool {
22
- _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ChainTxVerifyResponse res = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
21
+ static function verifyFromOutpoint(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__BacktraceInfo backtraceInfo, bytes t_genesisOutpoint, bytes t_selfScript, bytes t_prevTxInputList) : bool {
22
+ _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ChainTxVerifyResponse res = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
23
23
  if(res.prevPrevOutpoint == t_genesisOutpoint) {
24
- require(res.prevPrevScript == _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Backtrace.GENESIS_SCRIPT_HASH);
24
+ require(res.prevPrevScript == _opcat_labs_scrypt_ts_opcat_3_4_0__rs__Backtrace.GENESIS_SCRIPT_HASH);
25
25
  }
26
26
  require(res.prevPrevOutpoint == t_genesisOutpoint || res.prevPrevScript == t_selfScript);
27
27
  return true;
28
28
  }
29
- static function verifyFromScript(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__BacktraceInfo backtraceInfo, bytes t_genesisScript, bytes t_selfScript, bytes t_prevTxInputList) : bool {
30
- _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ChainTxVerifyResponse res = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
29
+ static function verifyFromScript(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__BacktraceInfo backtraceInfo, bytes t_genesisScript, bytes t_selfScript, bytes t_prevTxInputList) : bool {
30
+ _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ChainTxVerifyResponse res = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
31
31
  require(res.prevPrevScript == t_genesisScript || res.prevPrevScript == t_selfScript);
32
32
  return true;
33
33
  }
34
- static function verifyChainTxs(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__BacktraceInfo backtraceInfo, bytes t_prevTxInputList) : _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ChainTxVerifyResponse {
35
- require(t_prevTxInputList[backtraceInfo.prevTxInputIndex * 72 : (backtraceInfo.prevTxInputIndex + 1) * 72] == _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.mergeInput(backtraceInfo.prevTxInput));
34
+ static function verifyChainTxs(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__BacktraceInfo backtraceInfo, bytes t_prevTxInputList) : _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ChainTxVerifyResponse {
35
+ require(t_prevTxInputList[backtraceInfo.prevTxInputIndex * 72 : (backtraceInfo.prevTxInputIndex + 1) * 72] == _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.mergeInput(backtraceInfo.prevTxInput));
36
36
  bytes prevPrevTxHash = backtraceInfo.prevTxInput.prevTxHash;
37
- require(prevPrevTxHash == _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimageUtils.getTxHashFromTxHashPreimage(backtraceInfo.prevPrevTxPreimage));
37
+ require(prevPrevTxHash == _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimageUtils.getTxHashFromTxHashPreimage(backtraceInfo.prevPrevTxPreimage));
38
38
  bytes prevPrevScript = backtraceInfo.prevPrevTxPreimage.outputList[backtraceInfo.prevTxInput.prevOutputIndex * 72 + 8 : (backtraceInfo.prevTxInput.prevOutputIndex) * 72 + 8 + 32];
39
- bytes prevPrevOutpoint = prevPrevTxHash + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.uint32ToByteString(backtraceInfo.prevTxInput.prevOutputIndex);
39
+ bytes prevPrevOutpoint = prevPrevTxHash + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.uint32ToByteString(backtraceInfo.prevTxInput.prevOutputIndex);
40
40
  return {prevPrevScript, prevPrevOutpoint};
41
41
  }
42
42
  }
@@ -3,7 +3,7 @@ import "stdUtils.scrypt";
3
3
 
4
4
 
5
5
 
6
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ByteStringReader {
6
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ByteStringReader {
7
7
  bytes buf;
8
8
  int pos;
9
9
  constructor(bytes buf) {
@@ -23,15 +23,15 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ByteStringReader {
23
23
  l = header;
24
24
  ret = buf[this.pos : this.pos + l];
25
25
  } else if(header == 0x4c) {
26
- l = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(buf[this.pos : this.pos + 1]);
26
+ l = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(buf[this.pos : this.pos + 1]);
27
27
  this.pos += 1;
28
28
  ret = this.buf[this.pos : this.pos + l];
29
29
  } else if(header == 0x4d) {
30
- l = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 2]);
30
+ l = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 2]);
31
31
  this.pos += 2;
32
32
  ret = this.buf[this.pos : this.pos + l];
33
33
  } else if(header == 0x4e) {
34
- l = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 4]);
34
+ l = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 4]);
35
35
  this.pos += 4;
36
36
  ret = this.buf[this.pos : this.pos + l];
37
37
  } else {
@@ -61,6 +61,6 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ByteStringReader {
61
61
  } else {
62
62
  ret = header;
63
63
  }
64
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(ret);
64
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(ret);
65
65
  }
66
66
  }
@@ -3,7 +3,7 @@ import "stdUtils.scrypt";
3
3
 
4
4
 
5
5
 
6
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ByteStringWriter {
6
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ByteStringWriter {
7
7
  bytes buf;
8
8
  constructor() {
9
9
  this.buf = b'';
@@ -12,13 +12,13 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ByteStringWriter {
12
12
  int n = len(buf);
13
13
  bytes header = b'';
14
14
  if(n < 0x4c) {
15
- header = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, 1);
15
+ header = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, 1);
16
16
  } else if(n < 0x100) {
17
- header = b'4c' + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, 1);
17
+ header = b'4c' + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, 1);
18
18
  } else if(n < 0x10000) {
19
- header = b'4d' + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, 2);
19
+ header = b'4d' + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, 2);
20
20
  } else if(n < 0x100000000) {
21
- header = b'4e' + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, 4);
21
+ header = b'4e' + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, 4);
22
22
  } else {
23
23
  require(false);
24
24
  }
@@ -44,7 +44,7 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ByteStringWriter {
44
44
  size = 8;
45
45
  this.buf += b'ff';
46
46
  }
47
- this.buf += _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(x, size);
47
+ this.buf += _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(x, size);
48
48
  return true;
49
49
  }
50
50
  }
@@ -5,7 +5,7 @@ import "stdUtils.scrypt";
5
5
 
6
6
 
7
7
 
8
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils {
8
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils {
9
9
  static const PrivKey privKey = PrivKey(0x26f00fe2340a84335ebdf30f57e9bb58487117b29355718f5e46bf5168d7df97);
10
10
  static const PubKey pubKey = PubKey(b'02ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382');
11
11
  static const int invK = 0xc8ffdbaa05d93aa4ede79ec58f06a72562048b775a3507c2bf44bde4f007c40a;
@@ -18,7 +18,7 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils {
18
18
  static function sign(int h, PrivKey privKey, int inverseK, int r, bytes rBigEndian, bytes sigHashType) : Sig {
19
19
  int s = inverseK * (h + r * privKey);
20
20
 
21
- s = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.normalize(s, 115792089237316195423570985008687907852837564279074904382605163141518161494337);
21
+ s = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.normalize(s, 115792089237316195423570985008687907852837564279074904382605163141518161494337);
22
22
  if(s > 115792089237316195423570985008687907852837564279074904382605163141518161494337 / 2) {
23
23
  s = 115792089237316195423570985008687907852837564279074904382605163141518161494337 - s;
24
24
  }
@@ -32,13 +32,13 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils {
32
32
  static function fromBEUnsigned(bytes b) : int {
33
33
  return unpack(reverseBytes(b, 32) + b'00');
34
34
  }
35
- static function checkSHPreimage(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__SHPreimage shPreimage, bytes sigHashType) : Sig {
36
- SigHashPreimage preimage = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.serializeSHPreimage(shPreimage);
35
+ static function checkSHPreimage(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__SHPreimage shPreimage, bytes sigHashType) : Sig {
36
+ SigHashPreimage preimage = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.serializeSHPreimage(shPreimage);
37
37
  bytes h = hash256(preimage);
38
- Sig sig = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.sign(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.fromBEUnsigned(h), _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.privKey, 90914631784428570546048907090666684794265392153046400654824470772421497439242, 7252565254521500021189571868467740368187828957595681190666767817830690399852, _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.rBigEndian, sigHashType);
38
+ Sig sig = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.sign(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.fromBEUnsigned(h), _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.privKey, 90914631784428570546048907090666684794265392153046400654824470772421497439242, 7252565254521500021189571868467740368187828957595681190666767817830690399852, _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.rBigEndian, sigHashType);
39
39
  return sig;
40
40
  }
41
- static function serializeSHPreimage(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__SHPreimage shPreimage) : SigHashPreimage {
41
+ static function serializeSHPreimage(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__SHPreimage shPreimage) : SigHashPreimage {
42
42
  require(len(shPreimage.nVersion) == 4);
43
43
  require(len(shPreimage.hashPrevouts) == 32);
44
44
  require(len(shPreimage.spentScriptHash) == 32);
@@ -53,41 +53,41 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils {
53
53
  require(shPreimage.inputIndex >= 0);
54
54
  require(shPreimage.nLockTime >= 0);
55
55
  require(shPreimage.sigHashType == 1 || shPreimage.sigHashType == 2 || shPreimage.sigHashType == 3 || shPreimage.sigHashType == 0x81 || shPreimage.sigHashType == 0x82 || shPreimage.sigHashType == 0x83);
56
- bytes preimage = shPreimage.nVersion + shPreimage.hashPrevouts + shPreimage.spentScriptHash + shPreimage.spentDataHash + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.satoshisToByteString(shPreimage.value) + shPreimage.nSequence + shPreimage.hashSpentAmounts + shPreimage.hashSpentScriptHashes + shPreimage.hashSpentDataHashes + shPreimage.hashSequences + shPreimage.hashOutputs + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(shPreimage.inputIndex, 4) + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(shPreimage.nLockTime, 4) + num2bin(shPreimage.sigHashType, 4);
56
+ bytes preimage = shPreimage.nVersion + shPreimage.hashPrevouts + shPreimage.spentScriptHash + shPreimage.spentDataHash + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.satoshisToByteString(shPreimage.value) + shPreimage.nSequence + shPreimage.hashSpentAmounts + shPreimage.hashSpentScriptHashes + shPreimage.hashSpentDataHashes + shPreimage.hashSequences + shPreimage.hashOutputs + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(shPreimage.inputIndex, 4) + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(shPreimage.nLockTime, 4) + num2bin(shPreimage.sigHashType, 4);
57
57
  return SigHashPreimage(preimage);
58
58
  }
59
- static function checkPrevouts(bytes prevouts, bytes t_hashPrevouts, int t_inputIndex, int t_inputCount) : _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Outpoint {
59
+ static function checkPrevouts(bytes prevouts, bytes t_hashPrevouts, int t_inputIndex, int t_inputCount) : _opcat_labs_scrypt_ts_opcat_3_4_0__rs__Outpoint {
60
60
  require(hash256(prevouts) == t_hashPrevouts);
61
61
  require(t_inputIndex < t_inputCount);
62
- require(t_inputCount == _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.checkLenDivisibleBy(prevouts, 36));
62
+ require(t_inputCount == _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.checkLenDivisibleBy(prevouts, 36));
63
63
  bytes b = prevouts[t_inputIndex * 36 : (t_inputIndex + 1) * 36];
64
- return {b[0 : 32], _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.byteStringToUInt32(b[32 : 36])};
64
+ return {b[0 : 32], _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.byteStringToUInt32(b[32 : 36])};
65
65
  }
66
66
  static function checkSpentScripts(bytes spentScriptHashes, bytes t_hashSpentScripts, int t_inputCount) : bool {
67
67
  require(hash256(spentScriptHashes) == t_hashSpentScripts);
68
- require(t_inputCount == _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.checkLenDivisibleBy(spentScriptHashes, 32));
68
+ require(t_inputCount == _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.checkLenDivisibleBy(spentScriptHashes, 32));
69
69
  return true;
70
70
  }
71
71
  static function checkSpentAmounts(bytes spentAmounts, bytes hashSpentAmounts) : int {
72
72
  require(hash256(spentAmounts) == hashSpentAmounts);
73
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.checkLenDivisibleBy(spentAmounts, 8);
73
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.checkLenDivisibleBy(spentAmounts, 8);
74
74
  }
75
75
  static function checkSpentDataHashes(bytes spentDataHashes, bytes hashSpentDataHashes, int inputCount) : bool {
76
76
  require(hash256(spentDataHashes) == hashSpentDataHashes);
77
- require(inputCount == _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.checkLenDivisibleBy(spentDataHashes, 32));
77
+ require(inputCount == _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.checkLenDivisibleBy(spentDataHashes, 32));
78
78
  return true;
79
79
  }
80
80
  static function getSpentScriptHash(bytes spentScriptHashes, int inputIndex) : bytes {
81
81
  return spentScriptHashes[inputIndex * 32 : (inputIndex + 1) * 32];
82
82
  }
83
83
  static function getSpentAmount(bytes spentAmounts, int inputIndex) : int {
84
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(spentAmounts[inputIndex * 8 : (inputIndex + 1) * 8]);
84
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(spentAmounts[inputIndex * 8 : (inputIndex + 1) * 8]);
85
85
  }
86
86
  static function getSpentDataHash(bytes spentDataHashes, int inputIndex) : bytes {
87
87
  return spentDataHashes[inputIndex * 32 : (inputIndex + 1) * 32];
88
88
  }
89
- static function checknLockTime(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__SHPreimage shPreimage, int nlockTime) : bool {
90
- int nSequence = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(shPreimage.nSequence);
89
+ static function checknLockTime(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__SHPreimage shPreimage, int nlockTime) : bool {
90
+ int nSequence = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(shPreimage.nSequence);
91
91
  return (nSequence < 4294967295 && (nlockTime < 500000000 ? shPreimage.nLockTime < 500000000 : true) && shPreimage.nLockTime >= nlockTime);
92
92
  }
93
93
  }
@@ -8,15 +8,15 @@ import "contextUtils.scrypt";
8
8
 
9
9
 
10
10
 
11
- contract _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Genesis {
11
+ contract _opcat_labs_scrypt_ts_opcat_3_4_0__rs__Genesis {
12
12
  constructor() {
13
13
  }
14
- public function checkDeploy(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxOut[6] outputs, int outputCount, _opcat_labs_scrypt_ts_opcat_3_2_0__rs__SHPreimage __scrypt_ts_shPreimage, Sig __scrypt_ts_preimageSig, bytes __scrypt_ts_spentAmounts, bytes __scrypt_ts_spentScriptHashes) {
15
- require(checkDataSig(Sig(__scrypt_ts_preimageSig[0 : len(__scrypt_ts_preimageSig) - 1]), sha256(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.serializeSHPreimage(__scrypt_ts_shPreimage)), _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.pubKey) && checkSig(__scrypt_ts_preimageSig, _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.pubKey));
14
+ public function checkDeploy(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxOut[6] outputs, int outputCount, _opcat_labs_scrypt_ts_opcat_3_4_0__rs__SHPreimage __scrypt_ts_shPreimage, Sig __scrypt_ts_preimageSig, bytes __scrypt_ts_spentAmounts, bytes __scrypt_ts_spentScriptHashes) {
15
+ require(checkDataSig(Sig(__scrypt_ts_preimageSig[0 : len(__scrypt_ts_preimageSig) - 1]), sha256(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.serializeSHPreimage(__scrypt_ts_shPreimage)), _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.pubKey) && checkSig(__scrypt_ts_preimageSig, _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.pubKey));
16
16
 
17
- int __scrypt_ts_inputCount = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.checkSpentAmounts(__scrypt_ts_spentAmounts, __scrypt_ts_shPreimage.hashSpentAmounts);
17
+ int __scrypt_ts_inputCount = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.checkSpentAmounts(__scrypt_ts_spentAmounts, __scrypt_ts_shPreimage.hashSpentAmounts);
18
18
 
19
- _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.checkSpentScripts(__scrypt_ts_spentScriptHashes, __scrypt_ts_shPreimage.hashSpentScriptHashes, __scrypt_ts_inputCount);
19
+ _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.checkSpentScripts(__scrypt_ts_spentScriptHashes, __scrypt_ts_shPreimage.hashSpentScriptHashes, __scrypt_ts_inputCount);
20
20
 
21
21
  require(__scrypt_ts_shPreimage.inputIndex == 0);
22
22
  require(__scrypt_ts_inputCount <= (6));
@@ -24,10 +24,10 @@ contract _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Genesis {
24
24
  bytes output0ScriptHash = outputs[0].scriptHash;
25
25
  bytes outputBytes = b'';
26
26
  loop (6) : index {
27
- _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxOut _output = outputs[index];
27
+ _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxOut _output = outputs[index];
28
28
  if(index < outputCount) {
29
29
  require(len(_output.scriptHash) > 0);
30
- outputBytes += _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.buildDataOutput(_output.scriptHash, _output.satoshis, _output.dataHash);
30
+ outputBytes += _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.buildDataOutput(_output.scriptHash, _output.satoshis, _output.dataHash);
31
31
  if(index > 0) {
32
32
  require(output0ScriptHash != _output.scriptHash);
33
33
  }
@@ -35,7 +35,7 @@ contract _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Genesis {
35
35
  }
36
36
  loop (6) : index {
37
37
  if(index < __scrypt_ts_inputCount) {
38
- bytes inputScriptHash = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ContextUtils.getSpentScriptHash(__scrypt_ts_spentScriptHashes, (index));
38
+ bytes inputScriptHash = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ContextUtils.getSpentScriptHash(__scrypt_ts_spentScriptHashes, (index));
39
39
  require(output0ScriptHash != inputScriptHash);
40
40
  }
41
41
  }
@@ -4,7 +4,7 @@ import "contextUtils.scrypt";
4
4
 
5
5
 
6
6
 
7
- contract _opcat_labs_scrypt_ts_opcat_3_2_0__rs__P2PK {
7
+ contract _opcat_labs_scrypt_ts_opcat_3_4_0__rs__P2PK {
8
8
  const PubKey pubKey;
9
9
  public function unlock(Sig sig) {
10
10
  require(checkSig(sig, this.pubKey));
@@ -4,7 +4,7 @@ import "contextUtils.scrypt";
4
4
 
5
5
 
6
6
 
7
- contract _opcat_labs_scrypt_ts_opcat_3_2_0__rs__P2PKH {
7
+ contract _opcat_labs_scrypt_ts_opcat_3_4_0__rs__P2PKH {
8
8
  const Ripemd160 addr;
9
9
  public function unlock(Sig sig, PubKey pubkey) {
10
10
  require(hash160(pubkey) == this.addr);
@@ -1,5 +1,5 @@
1
1
 
2
2
 
3
3
 
4
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StateLib {
4
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StateLib {
5
5
  }
@@ -1,7 +1,7 @@
1
1
 
2
2
 
3
3
 
4
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StateUtils {
4
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StateUtils {
5
5
  static function checkInputState(int t_inputIndex, bytes stateHash, bytes t_spentDataHashes) : bool {
6
6
  require(t_spentDataHashes[t_inputIndex * 32 : (t_inputIndex + 1) * 32] == stateHash);
7
7
  return true;
@@ -1,12 +1,12 @@
1
1
 
2
2
 
3
3
 
4
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ReadVarintResult {
4
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ReadVarintResult {
5
5
  bytes data;
6
6
  int nextPos;
7
7
  }
8
8
 
9
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils {
9
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils {
10
10
  static function checkLenDivisibleBy(bytes b, int n) : int {
11
11
  int l = len(b);
12
12
  require(l % n == 0);
@@ -14,15 +14,15 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils {
14
14
  }
15
15
  static function uint64ToByteString(int n) : bytes {
16
16
  require(n >= 0 && n <= 18446744073709551615);
17
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, 8);
17
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, 8);
18
18
  }
19
19
  static function uint32ToByteString(int n) : bytes {
20
20
  require(n >= 0 && n <= 4294967295);
21
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, 4);
21
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, 4);
22
22
  }
23
23
  static function byteStringToUInt32(bytes b) : int {
24
24
  require(len(b) == 4);
25
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(b);
25
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(b);
26
26
  }
27
27
  static function toLEUnsigned(int n, int l) : bytes {
28
28
  bytes m = num2bin(n, l + 1);
@@ -46,7 +46,7 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils {
46
46
  b = b'ff';
47
47
  size = 8;
48
48
  }
49
- return b + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, size);
49
+ return b + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, size);
50
50
  }
51
51
  static function pushData(bytes buf) : bytes {
52
52
  int n = len(buf);
@@ -67,27 +67,27 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils {
67
67
  } else {
68
68
  require(false);
69
69
  }
70
- return header + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.toLEUnsigned(n, size);
70
+ return header + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.toLEUnsigned(n, size);
71
71
  }
72
- static function readVarint(bytes buf, int pos) : _opcat_labs_scrypt_ts_opcat_3_2_0__rs__ReadVarintResult {
72
+ static function readVarint(bytes buf, int pos) : _opcat_labs_scrypt_ts_opcat_3_4_0__rs__ReadVarintResult {
73
73
  int l = 0;
74
74
  bytes ret = b'';
75
75
  int nextPos = pos;
76
76
  bytes header = buf[pos : pos + 1];
77
77
  if(header == b'fd') {
78
- l = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 3]);
79
- ret = buf[3 : 3 + l];
78
+ l = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 3]);
79
+ ret = buf[pos + 3 : pos + 3 + l];
80
80
  nextPos = pos + 3 + l;
81
81
  } else if(header == b'fe') {
82
- l = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 5]);
82
+ l = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 5]);
83
83
  ret = buf[pos + 5 : pos + 5 + l];
84
84
  nextPos = pos + 5 + l;
85
85
  } else if(header == b'ff') {
86
- l = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 9]);
86
+ l = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(buf[pos + 1 : pos + 9]);
87
87
  ret = buf[pos + 9 : pos + 9 + l];
88
88
  nextPos = pos + 9 + l;
89
89
  } else {
90
- l = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(buf[pos : pos + 1]);
90
+ l = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(buf[pos : pos + 1]);
91
91
  ret = buf[pos + 1 : pos + 1 + l];
92
92
  nextPos = pos + 1 + l;
93
93
  }
@@ -4,17 +4,17 @@ import "stdUtils.scrypt";
4
4
 
5
5
 
6
6
 
7
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimageUtils {
8
- static function getTxHashFromTxHashPreimage(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimage txHashPreimage) : bytes {
7
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimageUtils {
8
+ static function getTxHashFromTxHashPreimage(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimage txHashPreimage) : bytes {
9
9
  require(len(txHashPreimage.version) == 4);
10
- int inputCount = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.checkLenDivisibleBy(txHashPreimage.inputList, 72);
11
- int outputCount = _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.checkLenDivisibleBy(txHashPreimage.outputList, 72);
12
- return hash256(txHashPreimage.version + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.writeVarInt(inputCount) + txHashPreimage.inputList + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.writeVarInt(outputCount) + txHashPreimage.outputList + txHashPreimage.nLockTime);
10
+ int inputCount = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.checkLenDivisibleBy(txHashPreimage.inputList, 72);
11
+ int outputCount = _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.checkLenDivisibleBy(txHashPreimage.outputList, 72);
12
+ return hash256(txHashPreimage.version + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.writeVarInt(inputCount) + txHashPreimage.inputList + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.writeVarInt(outputCount) + txHashPreimage.outputList + txHashPreimage.nLockTime);
13
13
  }
14
- static function getInputByteString(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimage txHashPreimage, int inputIndex) : bytes {
14
+ static function getInputByteString(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimage txHashPreimage, int inputIndex) : bytes {
15
15
  return txHashPreimage.inputList[inputIndex * 72 : (inputIndex + 1) * 72];
16
16
  }
17
- static function getOutputByteString(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimage txHashPreimage, int outputIndex) : bytes {
17
+ static function getOutputByteString(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimage txHashPreimage, int outputIndex) : bytes {
18
18
  return txHashPreimage.outputList[outputIndex * 72 : (outputIndex + 1) * 72];
19
19
  }
20
20
  }
@@ -4,10 +4,10 @@ import "stdUtils.scrypt";
4
4
 
5
5
 
6
6
 
7
- library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils {
7
+ library _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils {
8
8
  static const int ZERO_SATS = 0;
9
9
  static function buildOutput(bytes scriptHash, int satoshis) : bytes {
10
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.buildDataOutput(scriptHash, satoshis, sha256(b''));
10
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.buildDataOutput(scriptHash, satoshis, sha256(b''));
11
11
  }
12
12
  static function buildDataOutput(bytes scriptHash, int satoshis, bytes dataHash) : bytes {
13
13
  int scriptHashLen = len(scriptHash);
@@ -15,34 +15,34 @@ library _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils {
15
15
  require(scriptHashLen == 32);
16
16
  require(dataHashLen == 32);
17
17
  require(satoshis >= 0);
18
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.satoshisToByteString(satoshis) + scriptHash + dataHash;
18
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.satoshisToByteString(satoshis) + scriptHash + dataHash;
19
19
  }
20
- static function buildChangeOutput(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxOut change) : bytes {
21
- return change.satoshis > 0 ? _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.buildDataOutput(change.scriptHash, change.satoshis, change.dataHash) : b'';
20
+ static function buildChangeOutput(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxOut change) : bytes {
21
+ return change.satoshis > 0 ? _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.buildDataOutput(change.scriptHash, change.satoshis, change.dataHash) : b'';
22
22
  }
23
- static function mergeInput(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxIn txInput) : bytes {
23
+ static function mergeInput(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxIn txInput) : bytes {
24
24
  require(len(txInput.prevTxHash) == 32);
25
25
  require(len(txInput.scriptHash) == 32);
26
- return (txInput.prevTxHash + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.uint32ToByteString(txInput.prevOutputIndex) + txInput.scriptHash + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.uint32ToByteString(txInput.sequence));
26
+ return (txInput.prevTxHash + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.uint32ToByteString(txInput.prevOutputIndex) + txInput.scriptHash + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.uint32ToByteString(txInput.sequence));
27
27
  }
28
28
  static function buildOpReturnOutput(bytes data) : bytes {
29
29
  bytes script = b'6a' + pack(len(data)) + data;
30
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.satoshisToByteString(0) + sha256(script) + sha256(b'');
30
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.satoshisToByteString(0) + sha256(script) + sha256(b'');
31
31
  }
32
32
  static function buildP2PKHScript(Ripemd160 addr) : bytes {
33
33
  return (OpCode.OP_DUP + OpCode.OP_HASH160 + pack(20) + addr + OpCode.OP_EQUALVERIFY + OpCode.OP_CHECKSIG);
34
34
  }
35
35
  static function buildP2PKHOutput(int amount, Ripemd160 addr) : bytes {
36
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.buildDataOutput(sha256(_opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxUtils.buildP2PKHScript(addr)), amount, sha256(b''));
36
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.buildDataOutput(sha256(_opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxUtils.buildP2PKHScript(addr)), amount, sha256(b''));
37
37
  }
38
38
  static function buildOpreturnScript(bytes data) : bytes {
39
- return OpCode.OP_FALSE + OpCode.OP_RETURN + _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.pushData(data);
39
+ return OpCode.OP_FALSE + OpCode.OP_RETURN + _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.pushData(data);
40
40
  }
41
41
  static function satoshisToByteString(int n) : bytes {
42
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.uint64ToByteString(n);
42
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.uint64ToByteString(n);
43
43
  }
44
44
  static function byteStringToSatoshis(bytes bs) : int {
45
45
  require(len(bs) == 8);
46
- return _opcat_labs_scrypt_ts_opcat_3_2_0__rs__StdUtils.fromLEUnsigned(bs);
46
+ return _opcat_labs_scrypt_ts_opcat_3_4_0__rs__StdUtils.fromLEUnsigned(bs);
47
47
  }
48
48
  }
@@ -1,33 +1,33 @@
1
1
 
2
2
 
3
3
 
4
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxOut {
4
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxOut {
5
5
  bytes scriptHash;
6
6
  bytes dataHash;
7
7
  int satoshis;
8
8
  }
9
9
 
10
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxIn {
10
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxIn {
11
11
  bytes prevTxHash;
12
12
  int prevOutputIndex;
13
13
  int sequence;
14
14
  bytes scriptHash;
15
15
  }
16
16
 
17
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimage {
17
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimage {
18
18
  bytes version;
19
19
  bytes inputList;
20
20
  bytes outputList;
21
21
  bytes nLockTime;
22
22
  }
23
23
 
24
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__BacktraceInfo {
25
- _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxIn prevTxInput;
24
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__BacktraceInfo {
25
+ _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxIn prevTxInput;
26
26
  int prevTxInputIndex;
27
- _opcat_labs_scrypt_ts_opcat_3_2_0__rs__TxHashPreimage prevPrevTxPreimage;
27
+ _opcat_labs_scrypt_ts_opcat_3_4_0__rs__TxHashPreimage prevPrevTxPreimage;
28
28
  }
29
29
 
30
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__SHPreimage {
30
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__SHPreimage {
31
31
  bytes nVersion;
32
32
  bytes hashPrevouts;
33
33
  bytes spentScriptHash;
@@ -44,7 +44,7 @@ struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__SHPreimage {
44
44
  int sigHashType;
45
45
  }
46
46
 
47
- struct _opcat_labs_scrypt_ts_opcat_3_2_0__rs__Outpoint {
47
+ struct _opcat_labs_scrypt_ts_opcat_3_4_0__rs__Outpoint {
48
48
  bytes txHash;
49
49
  int outputIndex;
50
50
  }
@@ -480,9 +480,10 @@ class ExtPsbt extends psbt_js_1.Psbt {
480
480
  }
481
481
  /**
482
482
  * Gets the change output information from the PSBT transaction.
483
- * @returns {TxOut} An object containing the script hash, satoshis value, and data hash of the change output.
484
- * If no change output exists, returns an empty TxOut with default values (empty script/data hash and 0 satoshis).
483
+ * @returns {ChangeInfo} An object containing the pubkeyhash, satoshis value, and data hash of the change output.
484
+ * If no change output exists, returns an empty ChangeInfo with default values (zero pubkeyhash/data hash and 0 satoshis).
485
485
  * @throws {Error} If the change output index is set but the output is not found at that index.
486
+ * @throws {Error} If the change output script is not a valid P2PKH script.
486
487
  */
487
488
  getChangeInfo() {
488
489
  if (this._changeOutputIndex !== null) {
@@ -490,15 +491,24 @@ class ExtPsbt extends psbt_js_1.Psbt {
490
491
  if (!changeOutput) {
491
492
  throw new Error(`Change output is not found at index ${this._changeOutputIndex}`);
492
493
  }
494
+ // Extract pubkeyhash from P2PKH script (skip 76a914 prefix, take 20 bytes)
495
+ // P2PKH script format: 76a914 + pubkeyhash(20 bytes) + 88ac
496
+ const scriptHex = tools.toHex(changeOutput.script);
497
+ // Validate P2PKH script format: must be exactly 25 bytes (50 hex chars)
498
+ // and have correct prefix (76a914) and suffix (88ac)
499
+ if (scriptHex.length !== 50 || !scriptHex.startsWith('76a914') || !scriptHex.endsWith('88ac')) {
500
+ throw new Error(`Change output script is not a valid P2PKH script: ${scriptHex}`);
501
+ }
502
+ const pubkeyhash = scriptHex.slice(6, 46); // 76a914 = 6 chars, 20 bytes = 40 chars
493
503
  return {
494
- scriptHash: (0, index_js_2.sha256)(tools.toHex(changeOutput.script)),
504
+ pubkeyhash: (0, index_js_1.Ripemd160)(pubkeyhash),
495
505
  satoshis: changeOutput.value,
496
506
  dataHash: (0, index_js_2.sha256)(tools.toHex(changeOutput.data)),
497
507
  };
498
508
  }
499
509
  else {
500
510
  return {
501
- scriptHash: (0, index_js_2.sha256)((0, byteString_js_1.toByteString)('')),
511
+ pubkeyhash: (0, index_js_1.Ripemd160)((0, byteString_js_1.toByteString)('').padEnd(40, '0')), // 20 bytes of zeros
502
512
  satoshis: 0n,
503
513
  dataHash: (0, index_js_2.sha256)((0, byteString_js_1.toByteString)('')),
504
514
  };