@btc-vision/transaction 1.0.2 → 1.0.4

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 (83) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/generators/AddressGenerator.d.ts +7 -0
  3. package/browser/generators/builders/DeploymentGenerator.d.ts +1 -0
  4. package/browser/index.js +2 -2
  5. package/browser/keypair/Wallet.d.ts +1 -0
  6. package/browser/opnet.d.ts +2 -0
  7. package/browser/tests/gen.d.ts +1 -0
  8. package/browser/tests/transfer.d.ts +1 -0
  9. package/browser/transaction/builders/TransactionBuilder.d.ts +2 -2
  10. package/browser/verification/TapscriptVerificator.d.ts +17 -0
  11. package/build/_version.d.ts +1 -1
  12. package/build/_version.js +1 -1
  13. package/build/generators/AddressGenerator.d.ts +7 -0
  14. package/build/generators/AddressGenerator.js +21 -0
  15. package/build/generators/OPNetAddressGenerator.d.ts +0 -0
  16. package/build/generators/OPNetAddressGenerator.js +1 -0
  17. package/build/generators/builders/DeploymentGenerator.d.ts +1 -0
  18. package/build/generators/builders/DeploymentGenerator.js +10 -7
  19. package/build/keypair/Wallet.d.ts +1 -0
  20. package/build/keypair/Wallet.js +6 -0
  21. package/build/opnet.d.ts +2 -0
  22. package/build/opnet.js +2 -0
  23. package/build/tests/gen.d.ts +1 -0
  24. package/build/tests/gen.js +15 -0
  25. package/build/tests/test.js +15 -38
  26. package/build/tests/transfer.d.ts +1 -0
  27. package/build/tests/transfer.js +74 -0
  28. package/build/transaction/builders/TransactionBuilder.d.ts +2 -2
  29. package/build/transaction/builders/TransactionBuilder.js +3 -1
  30. package/build/verification/TapscriptVerificator.d.ts +17 -0
  31. package/build/verification/TapscriptVerificator.js +43 -0
  32. package/docs/assets/navigation.js +1 -1
  33. package/docs/assets/search.js +1 -1
  34. package/docs/classes/AddressGenerator.html +178 -0
  35. package/docs/classes/BitcoinUtils.html +182 -182
  36. package/docs/classes/CalldataGenerator.html +210 -210
  37. package/docs/classes/Compressor.html +184 -184
  38. package/docs/classes/ContractBaseMetadata.html +181 -181
  39. package/docs/classes/DeploymentGenerator.html +200 -199
  40. package/docs/classes/EcKeyPair.html +279 -279
  41. package/docs/classes/FundingTransaction.html +315 -315
  42. package/docs/classes/Generator.html +198 -198
  43. package/docs/classes/InteractionTransaction.html +387 -387
  44. package/docs/classes/TapscriptVerificator.html +180 -0
  45. package/docs/classes/TransactionBuilder.html +325 -325
  46. package/docs/classes/TransactionFactory.html +179 -179
  47. package/docs/classes/TweakedSigner.html +180 -180
  48. package/docs/classes/UTXOManager.html +186 -186
  49. package/docs/classes/Wallet.html +192 -190
  50. package/docs/classes/wBTC.html +188 -188
  51. package/docs/enums/TransactionType.html +178 -178
  52. package/docs/interfaces/ContractAddressVerificationParams.html +179 -0
  53. package/docs/interfaces/FetchUTXOParams.html +177 -177
  54. package/docs/interfaces/IFundingTransactionParameters.html +181 -181
  55. package/docs/interfaces/IInteractionParameters.html +184 -184
  56. package/docs/interfaces/ITransactionDataContractDeployment.html +183 -183
  57. package/docs/interfaces/ITransactionDataContractInteractionWrap.html +185 -185
  58. package/docs/interfaces/ITransactionParameters.html +180 -180
  59. package/docs/interfaces/IWallet.html +180 -180
  60. package/docs/interfaces/NetworkInformation.html +175 -175
  61. package/docs/interfaces/PsbtInputExtended.html +193 -193
  62. package/docs/interfaces/PsbtOutputExtendedAddress.html +182 -182
  63. package/docs/interfaces/PsbtOutputExtendedScript.html +182 -182
  64. package/docs/interfaces/RawUTXOResponse.html +177 -177
  65. package/docs/interfaces/TapLeafScript.html +176 -176
  66. package/docs/interfaces/TweakSettings.html +178 -178
  67. package/docs/interfaces/UTXO.html +177 -177
  68. package/docs/interfaces/UpdateInput.html +174 -174
  69. package/docs/modules.html +5 -2
  70. package/docs/types/PsbtOutputExtended.html +173 -173
  71. package/docs/variables/version.html +173 -173
  72. package/package.json +2 -1
  73. package/src/_version.ts +1 -1
  74. package/src/generators/AddressGenerator.ts +29 -0
  75. package/src/generators/builders/DeploymentGenerator.ts +16 -13
  76. package/src/keypair/Wallet.ts +12 -0
  77. package/src/opnet.ts +4 -0
  78. package/src/tests/gen.ts +24 -0
  79. package/src/tests/test.ts +17 -54
  80. package/src/{scripts/test.ts → tests/transfer.ts} +102 -98
  81. package/src/transaction/builders/TransactionBuilder.ts +610 -606
  82. package/src/verification/TapscriptVerificator.ts +89 -0
  83. package/src/scripts/Regtest.ts +0 -19
@@ -1,174 +1,174 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | OPNet</title><meta name="description" content="Documentation for OPNet"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><style>
2
- @media (prefers-color-scheme: dark) {
3
- :root {
4
- --md-sys-color-primary: #f6be46;
5
- --md-sys-color-on-primary: #412d00;
6
- --md-sys-color-primary-container: #5d4200;
7
- --md-sys-color-on-primary-container: #ffdea3;
8
- --md-sys-color-secondary: #d9c4a0;
9
- --md-sys-color-on-secondary: #3b2f15;
10
- --md-sys-color-secondary-container: #53452a;
11
- --md-sys-color-on-secondary-container: #f6e0bb;
12
- --md-sys-color-tertiary: #b2cfa8;
13
- --md-sys-color-on-tertiary: #1e361a;
14
- --md-sys-color-tertiary-container: #344d2f;
15
- --md-sys-color-on-tertiary-container: #cdebc2;
16
- --md-sys-color-error: #ffb4ab;
17
- --md-sys-color-on-error: #690005;
18
- --md-sys-color-error-container: #93000a;
19
- --md-sys-color-on-error-container: #ffb4ab;
20
- --md-sys-color-background: #1e1b16;
21
- --md-sys-color-on-background: #e9e1d9;
22
- --md-sys-color-surface: #1e1b16;
23
- --md-sys-color-on-surface: #e9e1d9;
24
- --md-sys-color-surface-variant: #4e4639;
25
- --md-sys-color-on-surface-variant: #d1c5b4;
26
- --md-sys-color-outline: #9a8f80;
27
- --md-sys-color-outline-variant: #4e4639;
28
- --md-sys-color-shadow: #000000;
29
- --md-sys-color-scrim: #000000;
30
- --md-sys-color-inverse-surface: #e9e1d9;
31
- --md-sys-color-inverse-on-surface: #34302a;
32
- --md-sys-color-inverse-primary: #7a5900;
33
- --md-sys-color-surface-dim: #16130e;
34
- --md-sys-color-surface-bright: #3d3933;
35
- --md-sys-color-surface-container-lowest: #110e09;
36
- --md-sys-color-surface-container-low: #1e1b16;
37
- --md-sys-color-surface-container: #221f1a;
38
- --md-sys-color-surface-container-high: #2d2924;
39
- --md-sys-color-surface-container-highest: #38342e
40
- }
41
- }
42
- :root[data-theme="dark"] {
43
- --md-sys-color-primary: #f6be46;
44
- --md-sys-color-on-primary: #412d00;
45
- --md-sys-color-primary-container: #5d4200;
46
- --md-sys-color-on-primary-container: #ffdea3;
47
- --md-sys-color-secondary: #d9c4a0;
48
- --md-sys-color-on-secondary: #3b2f15;
49
- --md-sys-color-secondary-container: #53452a;
50
- --md-sys-color-on-secondary-container: #f6e0bb;
51
- --md-sys-color-tertiary: #b2cfa8;
52
- --md-sys-color-on-tertiary: #1e361a;
53
- --md-sys-color-tertiary-container: #344d2f;
54
- --md-sys-color-on-tertiary-container: #cdebc2;
55
- --md-sys-color-error: #ffb4ab;
56
- --md-sys-color-on-error: #690005;
57
- --md-sys-color-error-container: #93000a;
58
- --md-sys-color-on-error-container: #ffb4ab;
59
- --md-sys-color-background: #1e1b16;
60
- --md-sys-color-on-background: #e9e1d9;
61
- --md-sys-color-surface: #1e1b16;
62
- --md-sys-color-on-surface: #e9e1d9;
63
- --md-sys-color-surface-variant: #4e4639;
64
- --md-sys-color-on-surface-variant: #d1c5b4;
65
- --md-sys-color-outline: #9a8f80;
66
- --md-sys-color-outline-variant: #4e4639;
67
- --md-sys-color-shadow: #000000;
68
- --md-sys-color-scrim: #000000;
69
- --md-sys-color-inverse-surface: #e9e1d9;
70
- --md-sys-color-inverse-on-surface: #34302a;
71
- --md-sys-color-inverse-primary: #7a5900;
72
- --md-sys-color-surface-dim: #16130e;
73
- --md-sys-color-surface-bright: #3d3933;
74
- --md-sys-color-surface-container-lowest: #110e09;
75
- --md-sys-color-surface-container-low: #1e1b16;
76
- --md-sys-color-surface-container: #221f1a;
77
- --md-sys-color-surface-container-high: #2d2924;
78
- --md-sys-color-surface-container-highest: #38342e
79
- }
80
-
81
- @media (prefers-color-scheme: light) {
82
- :root {
83
- --md-sys-color-primary: #7a5900;
84
- --md-sys-color-on-primary: #ffffff;
85
- --md-sys-color-primary-container: #ffdea3;
86
- --md-sys-color-on-primary-container: #261900;
87
- --md-sys-color-secondary: #6c5c3f;
88
- --md-sys-color-on-secondary: #ffffff;
89
- --md-sys-color-secondary-container: #f6e0bb;
90
- --md-sys-color-on-secondary-container: #251a04;
91
- --md-sys-color-tertiary: #4b6545;
92
- --md-sys-color-on-tertiary: #ffffff;
93
- --md-sys-color-tertiary-container: #cdebc2;
94
- --md-sys-color-on-tertiary-container: #092007;
95
- --md-sys-color-error: #ba1a1a;
96
- --md-sys-color-on-error: #ffffff;
97
- --md-sys-color-error-container: #ffdad6;
98
- --md-sys-color-on-error-container: #410002;
99
- --md-sys-color-background: #fffbff;
100
- --md-sys-color-on-background: #1e1b16;
101
- --md-sys-color-surface: #fffbff;
102
- --md-sys-color-on-surface: #1e1b16;
103
- --md-sys-color-surface-variant: #ede1cf;
104
- --md-sys-color-on-surface-variant: #4e4639;
105
- --md-sys-color-outline: #7f7667;
106
- --md-sys-color-outline-variant: #d1c5b4;
107
- --md-sys-color-shadow: #000000;
108
- --md-sys-color-scrim: #000000;
109
- --md-sys-color-inverse-surface: #34302a;
110
- --md-sys-color-inverse-on-surface: #f8efe7;
111
- --md-sys-color-inverse-primary: #f6be46;
112
- --md-sys-color-surface-dim: #e1d9d0;
113
- --md-sys-color-surface-bright: #fff8f2;
114
- --md-sys-color-surface-container-lowest: #ffffff;
115
- --md-sys-color-surface-container-low: #fbf2e9;
116
- --md-sys-color-surface-container: #f5ede4;
117
- --md-sys-color-surface-container-high: #efe7de;
118
- --md-sys-color-surface-container-highest: #e9e1d9
119
- }
120
- }
121
- :root[data-theme="light"] {
122
- --md-sys-color-primary: #7a5900;
123
- --md-sys-color-on-primary: #ffffff;
124
- --md-sys-color-primary-container: #ffdea3;
125
- --md-sys-color-on-primary-container: #261900;
126
- --md-sys-color-secondary: #6c5c3f;
127
- --md-sys-color-on-secondary: #ffffff;
128
- --md-sys-color-secondary-container: #f6e0bb;
129
- --md-sys-color-on-secondary-container: #251a04;
130
- --md-sys-color-tertiary: #4b6545;
131
- --md-sys-color-on-tertiary: #ffffff;
132
- --md-sys-color-tertiary-container: #cdebc2;
133
- --md-sys-color-on-tertiary-container: #092007;
134
- --md-sys-color-error: #ba1a1a;
135
- --md-sys-color-on-error: #ffffff;
136
- --md-sys-color-error-container: #ffdad6;
137
- --md-sys-color-on-error-container: #410002;
138
- --md-sys-color-background: #fffbff;
139
- --md-sys-color-on-background: #1e1b16;
140
- --md-sys-color-surface: #fffbff;
141
- --md-sys-color-on-surface: #1e1b16;
142
- --md-sys-color-surface-variant: #ede1cf;
143
- --md-sys-color-on-surface-variant: #4e4639;
144
- --md-sys-color-outline: #7f7667;
145
- --md-sys-color-outline-variant: #d1c5b4;
146
- --md-sys-color-shadow: #000000;
147
- --md-sys-color-scrim: #000000;
148
- --md-sys-color-inverse-surface: #34302a;
149
- --md-sys-color-inverse-on-surface: #f8efe7;
150
- --md-sys-color-inverse-primary: #f6be46;
151
- --md-sys-color-surface-dim: #e1d9d0;
152
- --md-sys-color-surface-bright: #fff8f2;
153
- --md-sys-color-surface-container-lowest: #ffffff;
154
- --md-sys-color-surface-container-low: #fbf2e9;
155
- --md-sys-color-surface-container: #f5ede4;
156
- --md-sys-color-surface-container-high: #efe7de;
157
- --md-sys-color-surface-container-highest: #e9e1d9
158
- }
159
- </style><link rel="stylesheet" href="../assets/material-style.css"/></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">OPNet</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">OPNet</a></li><li><a href="version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag ts-flagConst">Const</code> </h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;1.0.2&quot;</span><span class="tsd-signature-symbol"> = &#39;1.0.2&#39;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/btc-vision/transaction/blob/f011dd0deb54f4443a605e608559283edd672d6a/src/_version.ts#L1">src/_version.ts:1</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>OPNet</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div><script>
160
- try {
161
- const generateLinkElement = document.querySelector(".tsd-generator a");
162
- const link = document.createElement("a");
163
- Object.assign(link, {
164
- href: "https://github.com/dmnsgn/typedoc-material-theme",
165
- target: "_blank",
166
- rel: "noreferrer",
167
- innerText: "typedoc-material-theme."
168
- });
169
- generateLinkElement.insertAdjacentElement("afterend", link);
170
- generateLinkElement.insertAdjacentText("afterend", " with ");
171
- } catch (error) {
172
-
173
- }
1
+ <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | OPNet</title><meta name="description" content="Documentation for OPNet"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><style>
2
+ @media (prefers-color-scheme: dark) {
3
+ :root {
4
+ --md-sys-color-primary: #f6be46;
5
+ --md-sys-color-on-primary: #412d00;
6
+ --md-sys-color-primary-container: #5d4200;
7
+ --md-sys-color-on-primary-container: #ffdea3;
8
+ --md-sys-color-secondary: #d9c4a0;
9
+ --md-sys-color-on-secondary: #3b2f15;
10
+ --md-sys-color-secondary-container: #53452a;
11
+ --md-sys-color-on-secondary-container: #f6e0bb;
12
+ --md-sys-color-tertiary: #b2cfa8;
13
+ --md-sys-color-on-tertiary: #1e361a;
14
+ --md-sys-color-tertiary-container: #344d2f;
15
+ --md-sys-color-on-tertiary-container: #cdebc2;
16
+ --md-sys-color-error: #ffb4ab;
17
+ --md-sys-color-on-error: #690005;
18
+ --md-sys-color-error-container: #93000a;
19
+ --md-sys-color-on-error-container: #ffb4ab;
20
+ --md-sys-color-background: #1e1b16;
21
+ --md-sys-color-on-background: #e9e1d9;
22
+ --md-sys-color-surface: #1e1b16;
23
+ --md-sys-color-on-surface: #e9e1d9;
24
+ --md-sys-color-surface-variant: #4e4639;
25
+ --md-sys-color-on-surface-variant: #d1c5b4;
26
+ --md-sys-color-outline: #9a8f80;
27
+ --md-sys-color-outline-variant: #4e4639;
28
+ --md-sys-color-shadow: #000000;
29
+ --md-sys-color-scrim: #000000;
30
+ --md-sys-color-inverse-surface: #e9e1d9;
31
+ --md-sys-color-inverse-on-surface: #34302a;
32
+ --md-sys-color-inverse-primary: #7a5900;
33
+ --md-sys-color-surface-dim: #16130e;
34
+ --md-sys-color-surface-bright: #3d3933;
35
+ --md-sys-color-surface-container-lowest: #110e09;
36
+ --md-sys-color-surface-container-low: #1e1b16;
37
+ --md-sys-color-surface-container: #221f1a;
38
+ --md-sys-color-surface-container-high: #2d2924;
39
+ --md-sys-color-surface-container-highest: #38342e
40
+ }
41
+ }
42
+ :root[data-theme="dark"] {
43
+ --md-sys-color-primary: #f6be46;
44
+ --md-sys-color-on-primary: #412d00;
45
+ --md-sys-color-primary-container: #5d4200;
46
+ --md-sys-color-on-primary-container: #ffdea3;
47
+ --md-sys-color-secondary: #d9c4a0;
48
+ --md-sys-color-on-secondary: #3b2f15;
49
+ --md-sys-color-secondary-container: #53452a;
50
+ --md-sys-color-on-secondary-container: #f6e0bb;
51
+ --md-sys-color-tertiary: #b2cfa8;
52
+ --md-sys-color-on-tertiary: #1e361a;
53
+ --md-sys-color-tertiary-container: #344d2f;
54
+ --md-sys-color-on-tertiary-container: #cdebc2;
55
+ --md-sys-color-error: #ffb4ab;
56
+ --md-sys-color-on-error: #690005;
57
+ --md-sys-color-error-container: #93000a;
58
+ --md-sys-color-on-error-container: #ffb4ab;
59
+ --md-sys-color-background: #1e1b16;
60
+ --md-sys-color-on-background: #e9e1d9;
61
+ --md-sys-color-surface: #1e1b16;
62
+ --md-sys-color-on-surface: #e9e1d9;
63
+ --md-sys-color-surface-variant: #4e4639;
64
+ --md-sys-color-on-surface-variant: #d1c5b4;
65
+ --md-sys-color-outline: #9a8f80;
66
+ --md-sys-color-outline-variant: #4e4639;
67
+ --md-sys-color-shadow: #000000;
68
+ --md-sys-color-scrim: #000000;
69
+ --md-sys-color-inverse-surface: #e9e1d9;
70
+ --md-sys-color-inverse-on-surface: #34302a;
71
+ --md-sys-color-inverse-primary: #7a5900;
72
+ --md-sys-color-surface-dim: #16130e;
73
+ --md-sys-color-surface-bright: #3d3933;
74
+ --md-sys-color-surface-container-lowest: #110e09;
75
+ --md-sys-color-surface-container-low: #1e1b16;
76
+ --md-sys-color-surface-container: #221f1a;
77
+ --md-sys-color-surface-container-high: #2d2924;
78
+ --md-sys-color-surface-container-highest: #38342e
79
+ }
80
+
81
+ @media (prefers-color-scheme: light) {
82
+ :root {
83
+ --md-sys-color-primary: #7a5900;
84
+ --md-sys-color-on-primary: #ffffff;
85
+ --md-sys-color-primary-container: #ffdea3;
86
+ --md-sys-color-on-primary-container: #261900;
87
+ --md-sys-color-secondary: #6c5c3f;
88
+ --md-sys-color-on-secondary: #ffffff;
89
+ --md-sys-color-secondary-container: #f6e0bb;
90
+ --md-sys-color-on-secondary-container: #251a04;
91
+ --md-sys-color-tertiary: #4b6545;
92
+ --md-sys-color-on-tertiary: #ffffff;
93
+ --md-sys-color-tertiary-container: #cdebc2;
94
+ --md-sys-color-on-tertiary-container: #092007;
95
+ --md-sys-color-error: #ba1a1a;
96
+ --md-sys-color-on-error: #ffffff;
97
+ --md-sys-color-error-container: #ffdad6;
98
+ --md-sys-color-on-error-container: #410002;
99
+ --md-sys-color-background: #fffbff;
100
+ --md-sys-color-on-background: #1e1b16;
101
+ --md-sys-color-surface: #fffbff;
102
+ --md-sys-color-on-surface: #1e1b16;
103
+ --md-sys-color-surface-variant: #ede1cf;
104
+ --md-sys-color-on-surface-variant: #4e4639;
105
+ --md-sys-color-outline: #7f7667;
106
+ --md-sys-color-outline-variant: #d1c5b4;
107
+ --md-sys-color-shadow: #000000;
108
+ --md-sys-color-scrim: #000000;
109
+ --md-sys-color-inverse-surface: #34302a;
110
+ --md-sys-color-inverse-on-surface: #f8efe7;
111
+ --md-sys-color-inverse-primary: #f6be46;
112
+ --md-sys-color-surface-dim: #e1d9d0;
113
+ --md-sys-color-surface-bright: #fff8f2;
114
+ --md-sys-color-surface-container-lowest: #ffffff;
115
+ --md-sys-color-surface-container-low: #fbf2e9;
116
+ --md-sys-color-surface-container: #f5ede4;
117
+ --md-sys-color-surface-container-high: #efe7de;
118
+ --md-sys-color-surface-container-highest: #e9e1d9
119
+ }
120
+ }
121
+ :root[data-theme="light"] {
122
+ --md-sys-color-primary: #7a5900;
123
+ --md-sys-color-on-primary: #ffffff;
124
+ --md-sys-color-primary-container: #ffdea3;
125
+ --md-sys-color-on-primary-container: #261900;
126
+ --md-sys-color-secondary: #6c5c3f;
127
+ --md-sys-color-on-secondary: #ffffff;
128
+ --md-sys-color-secondary-container: #f6e0bb;
129
+ --md-sys-color-on-secondary-container: #251a04;
130
+ --md-sys-color-tertiary: #4b6545;
131
+ --md-sys-color-on-tertiary: #ffffff;
132
+ --md-sys-color-tertiary-container: #cdebc2;
133
+ --md-sys-color-on-tertiary-container: #092007;
134
+ --md-sys-color-error: #ba1a1a;
135
+ --md-sys-color-on-error: #ffffff;
136
+ --md-sys-color-error-container: #ffdad6;
137
+ --md-sys-color-on-error-container: #410002;
138
+ --md-sys-color-background: #fffbff;
139
+ --md-sys-color-on-background: #1e1b16;
140
+ --md-sys-color-surface: #fffbff;
141
+ --md-sys-color-on-surface: #1e1b16;
142
+ --md-sys-color-surface-variant: #ede1cf;
143
+ --md-sys-color-on-surface-variant: #4e4639;
144
+ --md-sys-color-outline: #7f7667;
145
+ --md-sys-color-outline-variant: #d1c5b4;
146
+ --md-sys-color-shadow: #000000;
147
+ --md-sys-color-scrim: #000000;
148
+ --md-sys-color-inverse-surface: #34302a;
149
+ --md-sys-color-inverse-on-surface: #f8efe7;
150
+ --md-sys-color-inverse-primary: #f6be46;
151
+ --md-sys-color-surface-dim: #e1d9d0;
152
+ --md-sys-color-surface-bright: #fff8f2;
153
+ --md-sys-color-surface-container-lowest: #ffffff;
154
+ --md-sys-color-surface-container-low: #fbf2e9;
155
+ --md-sys-color-surface-container: #f5ede4;
156
+ --md-sys-color-surface-container-high: #efe7de;
157
+ --md-sys-color-surface-container-highest: #e9e1d9
158
+ }
159
+ </style><link rel="stylesheet" href="../assets/material-style.css"/></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">OPNet</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">OPNet</a></li><li><a href="version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag ts-flagConst">Const</code> </h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;1.0.3&quot;</span><span class="tsd-signature-symbol"> = &#39;1.0.3&#39;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/btc-vision/transaction/blob/5743de7784c0b32e4f1ec1ef492bbef406a8a017/src/_version.ts#L1">src/_version.ts:1</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>OPNet</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div><script>
160
+ try {
161
+ const generateLinkElement = document.querySelector(".tsd-generator a");
162
+ const link = document.createElement("a");
163
+ Object.assign(link, {
164
+ href: "https://github.com/dmnsgn/typedoc-material-theme",
165
+ target: "_blank",
166
+ rel: "noreferrer",
167
+ innerText: "typedoc-material-theme."
168
+ });
169
+ generateLinkElement.insertAdjacentElement("afterend", link);
170
+ generateLinkElement.insertAdjacentText("afterend", " with ");
171
+ } catch (error) {
172
+
173
+ }
174
174
  </script></body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "author": "BlobMaster41",
5
5
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
6
6
  "engines": {
@@ -100,6 +100,7 @@
100
100
  "babel-plugin-transform-import-meta": "^2.2.1",
101
101
  "babel-preset-react": "^6.24.1",
102
102
  "babelify": "^10.0.0",
103
+ "bech32": "^2.0.0",
103
104
  "bip32": "^4.0.0",
104
105
  "bitcoinjs-lib": "github:btc-vision/bitcoinjs-lib",
105
106
  "browserify-zlib": "^0.2.0",
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.0.2';
1
+ export const version = '1.0.4';
@@ -0,0 +1,29 @@
1
+ import { createHash } from 'crypto';
2
+ import { bech32 } from 'bech32';
3
+ import { initEccLib, Network } from 'bitcoinjs-lib';
4
+ import * as ecc from 'tiny-secp256k1';
5
+
6
+ initEccLib(ecc);
7
+
8
+ export class AddressGenerator {
9
+ // Generate a valid SegWit address from random bytes
10
+ public static generatePKSH(sha256Hash: Buffer, network: Network): string {
11
+ if (sha256Hash.length !== 32) throw new Error('Invalid hash length');
12
+
13
+ const pkh = this.ripemd160(sha256Hash);
14
+ return this.toSegwitAddress(pkh, network);
15
+ }
16
+
17
+ // Compute the RIPEMD-160 hash of a buffer
18
+ private static ripemd160(data: Buffer): Buffer {
19
+ return createHash('ripemd160').update(data).digest();
20
+ }
21
+
22
+ // Convert a hash to a SegWit address
23
+ private static toSegwitAddress(pkh: Buffer, network: Network): string {
24
+ const words = bech32.toWords(pkh);
25
+ words.unshift(0x00); // Add the witness version byte (0x00 for P2WPKH)
26
+
27
+ return bech32.encode(network.bech32, words);
28
+ }
29
+ }
@@ -17,9 +17,24 @@ export class DeploymentGenerator extends Generator {
17
17
  * @returns {Buffer} - The compiled script
18
18
  */
19
19
  public compile(contractBytecode: Buffer, contractSalt: Buffer): Buffer {
20
+ const asm = this.getAsm(contractBytecode, contractSalt);
21
+ const compiled = script.compile(asm);
22
+
23
+ /**
24
+ * Verify that the script can be decompiled
25
+ */
26
+ const decompiled = script.decompile(compiled);
27
+ if (!decompiled) {
28
+ throw new Error('Failed to decompile script??');
29
+ }
30
+
31
+ return compiled;
32
+ }
33
+
34
+ private getAsm(contractBytecode: Buffer, contractSalt: Buffer): (number | Buffer)[] {
20
35
  const dataChunks = this.splitBufferIntoChunks(contractBytecode);
21
36
 
22
- const asm = [
37
+ return [
23
38
  this.senderPubKey,
24
39
  opcodes.OP_CHECKSIGVERIFY,
25
40
 
@@ -47,17 +62,5 @@ export class DeploymentGenerator extends Generator {
47
62
  opcodes.OP_1,
48
63
  opcodes.OP_ENDIF,
49
64
  ].flat();
50
-
51
- const compiled = script.compile(asm);
52
-
53
- /**
54
- * Verify that the script can be decompiled
55
- */
56
- const decompiled = script.decompile(compiled);
57
- if (!decompiled) {
58
- throw new Error('Failed to decompile script??');
59
- }
60
-
61
- return compiled;
62
65
  }
63
66
  }
@@ -3,6 +3,7 @@ import { ECPairInterface } from 'ecpair';
3
3
  import { EcKeyPair } from './EcKeyPair.js';
4
4
  import { Network, networks } from 'bitcoinjs-lib';
5
5
  import { Address } from '@btc-vision/bsi-binary';
6
+ import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
6
7
 
7
8
  /**
8
9
  * Wallet class
@@ -72,4 +73,15 @@ export class Wallet {
72
73
 
73
74
  return this.keypair.publicKey;
74
75
  }
76
+
77
+ /**
78
+ * Get the x-only public key for the wallet
79
+ * @public
80
+ * @returns {Buffer}
81
+ */
82
+ public get xOnly(): Buffer {
83
+ if (!this.keypair) throw new Error('Keypair not set');
84
+
85
+ return toXOnly(this.keypair.publicKey);
86
+ }
75
87
  }
package/src/opnet.ts CHANGED
@@ -8,6 +8,10 @@ export * from './generators/Generator.js';
8
8
  export * from './generators/builders/CalldataGenerator.js';
9
9
  export * from './generators/builders/DeploymentGenerator.js';
10
10
 
11
+ /** Address */
12
+ export * from './generators/AddressGenerator.js';
13
+ export * from './verification/TapscriptVerificator.js';
14
+
11
15
  /** Key Pair */
12
16
  export * from './keypair/EcKeyPair.js';
13
17
  export * from './keypair/Wallet.js';
@@ -0,0 +1,24 @@
1
+ import { TapscriptVerificator } from '../verification/TapscriptVerificator.js';
2
+ import { networks } from 'bitcoinjs-lib';
3
+ import { Regtest } from './Regtest.js';
4
+ import { Wallet } from '../keypair/Wallet.js';
5
+
6
+ const wallet = new Wallet(Regtest.wallet, networks.regtest);
7
+
8
+ const params = {
9
+ bytecode: Buffer.from('deadbeef', 'hex'),
10
+ contractSaltPubKey: Buffer.from('deadbeef', 'hex'),
11
+ deployerPubKeyXOnly: wallet.xOnly,
12
+ originalSalt: Buffer.from('deadbeef', 'hex'),
13
+ network: networks.regtest,
14
+ };
15
+
16
+ const contractAddress = TapscriptVerificator.getContractAddress(params);
17
+ const virtualAddress: string = TapscriptVerificator.generateContractVirtualAddress(
18
+ params.deployerPubKeyXOnly,
19
+ params.bytecode,
20
+ params.originalSalt,
21
+ networks.regtest,
22
+ );
23
+
24
+ console.log('contract sewgit address', virtualAddress, '\ncontract p2tr address', contractAddress);
package/src/tests/test.ts CHANGED
@@ -1,35 +1,18 @@
1
- import { wBTC } from '../metadata/contracts/wBTC.js';
2
1
  import { Wallet } from '../keypair/Wallet.js';
3
- import { Testnet } from './Regtest.js';
2
+ import { Regtest } from './Regtest.js';
4
3
  import { UTXOManager } from '../utxo/UTXOManager.js';
5
4
  import { FetchUTXOParams, UTXO } from '../utxo/interfaces/IUTXO.js';
6
- import { IInteractionParameters } from '../transaction/interfaces/ITransactionParameters.js';
5
+ import { IFundingTransactionParameters } from '../transaction/interfaces/ITransactionParameters.js';
7
6
  import { networks } from 'bitcoinjs-lib';
8
- import { TransactionFactory } from '../transaction/TransactionFactory.js';
9
7
  import { BitcoinRPC } from '@btc-vision/bsi-bitcoin-rpc';
10
- import { ABICoder, BinaryWriter } from '@btc-vision/bsi-binary';
8
+ import { FundingTransaction } from '../transaction/builders/FundingTransaction.js';
11
9
 
12
- const network: networks.Network = networks.testnet;
10
+ const network: networks.Network = networks.regtest;
13
11
  const rpc: BitcoinRPC = new BitcoinRPC();
14
- const wBtc: wBTC = new wBTC(network);
15
- const wallet: Wallet = new Wallet(Testnet.wallet, network);
12
+ const wallet: Wallet = new Wallet(Regtest.wallet, network);
16
13
 
17
- const utxoManager: UTXOManager = new UTXOManager('https://testnet.opnet.org');
18
- const factory: TransactionFactory = new TransactionFactory();
19
-
20
- const abiCoder: ABICoder = new ABICoder();
21
- const transferSelector = Number(`0x` + abiCoder.encodeSelector('transfer'));
22
-
23
- function getTransferToCalldata(to: string, amount: bigint): Buffer {
24
- const addCalldata: BinaryWriter = new BinaryWriter();
25
- addCalldata.writeSelector(transferSelector);
26
- addCalldata.writeAddress(to);
27
- addCalldata.writeU256(amount);
28
-
29
- return Buffer.from(addCalldata.getBuffer());
30
- }
31
-
32
- const shouldMineBlock: boolean = false;
14
+ const utxoManager: UTXOManager = new UTXOManager('http://localhost:9001');
15
+ const shouldMineBlock: boolean = true;
33
16
 
34
17
  async function mineBlock(): Promise<boolean> {
35
18
  // lets mine 1 block.
@@ -39,12 +22,11 @@ async function mineBlock(): Promise<boolean> {
39
22
  }
40
23
 
41
24
  console.log(`Mined block`, ok);
42
-
43
25
  return !!ok.length;
44
26
  }
45
27
 
46
28
  (async () => {
47
- await rpc.init(Testnet.config);
29
+ await rpc.init(Regtest.config);
48
30
 
49
31
  const utxoSetting: FetchUTXOParams = {
50
32
  address: wallet.p2wpkh,
@@ -53,48 +35,29 @@ async function mineBlock(): Promise<boolean> {
53
35
  };
54
36
 
55
37
  const utxos: UTXO[] = await utxoManager.fetchUTXO(utxoSetting);
56
- console.log(`UTXOs:`, utxos);
57
-
58
38
  if (!utxos) {
59
39
  throw new Error('No UTXOs found');
60
40
  }
61
41
 
62
- const calldata: Buffer = getTransferToCalldata(
63
- 'tb1pt3ncc5ktfzpry2uvnag06v3jkv4quvmdydf09q8fx6rkgd7f5s8q3aenuk',
64
- 5000000n,
65
- );
66
-
67
- const interactionParameters: IInteractionParameters = {
42
+ const interactionParameters: IFundingTransactionParameters = {
68
43
  from: wallet.p2wpkh,
69
- to: wBtc.getAddress(),
44
+ to: 'bcrt1qqvf4gprr05z248ph6gvx54rpg08p8ngq3zh8uh',
70
45
  utxos: utxos,
71
46
  signer: wallet.keypair,
72
47
  network: network,
73
48
  feeRate: 150,
74
- priorityFee: 50000n,
75
- calldata: calldata,
49
+ priorityFee: 1000n,
50
+ childTransactionRequiredFees: 0n,
76
51
  };
77
52
 
78
- const finalTx = factory.signInteraction(interactionParameters);
79
- const firstTxBroadcast = await rpc.sendRawTransaction({
80
- hexstring: finalTx[0],
81
- });
82
-
83
- console.log(`First transaction broadcasted: ${firstTxBroadcast}`);
84
-
85
- if (!firstTxBroadcast) {
86
- throw new Error('Could not broadcast first transaction');
87
- }
53
+ const fundingTransaction = new FundingTransaction(interactionParameters);
54
+ const fundingTx = fundingTransaction.signTransaction();
55
+ console.log(fundingTx.toHex());
88
56
 
89
57
  const secondTxBroadcast = await rpc.sendRawTransaction({
90
- hexstring: finalTx[1],
58
+ hexstring: fundingTx.toHex(),
91
59
  });
92
-
93
- console.log(`Second transaction broadcasted: ${secondTxBroadcast}`);
94
-
95
- if (!secondTxBroadcast) {
96
- throw new Error('Could not broadcast second transaction');
97
- }
60
+ console.log(`Transaction broadcasted: ${secondTxBroadcast}`);
98
61
 
99
62
  if (shouldMineBlock) {
100
63
  await mineBlock();