Bitcoin ABC 0.33.10
P2P Digital Currency
proof_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2020 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <avalanche/proof.h>
6
10#include <coins.h>
11#include <script/standard.h>
12#include <util/strencodings.h>
13#include <util/translation.h>
14#include <validation.h>
15
16#include <test/util/random.h>
17#include <test/util/setup_common.h>
18
19#include <boost/test/unit_test.hpp>
20
21#include <limits>
22
23using namespace avalanche;
24
25BOOST_FIXTURE_TEST_SUITE(proof_tests, TestChain100Setup)
26
27BOOST_AUTO_TEST_CASE(proof_random) {
28 Chainstate &active_chainstate = Assert(m_node.chainman)->ActiveChainstate();
29 const uint32_t maxScore = Proof::amountToScore(MAX_MONEY);
30
31 for (int i = 0; i < 1000; i++) {
32 // The randrage upper bound is exclusive, so we add 1 to include the
33 // maximum score.
34 const uint32_t score = m_rng.randrange(maxScore + 1);
35 auto p = buildRandomProof(active_chainstate, score);
36 BOOST_CHECK_EQUAL(p->getScore(), score);
37
38 ProofValidationResult expected_state =
39 hasDustStake(p) ? ProofValidationResult::DUST_THRESHOLD
41
43 const bool ret = p->verify(PROOF_DUST_THRESHOLD, state);
46 BOOST_CHECK(state.GetResult() == expected_state);
47 }
48}
49
50BOOST_AUTO_TEST_CASE(proofbuilder) {
51 // Master key.
52 auto key = CKey::MakeCompressedKey();
53 const CPubKey master = key.GetPubKey();
54
55 const uint64_t sequence = m_rng.randbits(64);
56 const int64_t expiration = m_rng.randbits(64);
57
58 ProofBuilder pb(sequence, expiration, key, UNSPENDABLE_ECREG_PAYOUT_SCRIPT);
59
60 for (int i = 0; i < 3; i++) {
61 key.MakeNewKey(true);
62 BOOST_CHECK(pb.addUTXO(COutPoint(TxId(GetRandHash()), m_rng.rand32()),
63 int64_t(m_rng.rand32()) * COIN / 100,
64 m_rng.rand32(), m_rng.randbool(), key));
65 }
66
67 ProofRef p = pb.build();
68
71
72 BOOST_CHECK_EQUAL(p->getSequence(), sequence);
73 BOOST_CHECK_EQUAL(p->getExpirationTime(), expiration);
74 BOOST_CHECK(p->getMaster() == master);
75
77}
78
79struct TestVector {
80 std::string name;
81 std::string hex;
83 uint32_t score;
85};
86
87BOOST_AUTO_TEST_CASE(deserialization) {
88 // Proof master key:
89 // privkey L4J6gEE4wL9ji2EQbzS5dPMTTsw8LRvcMst1Utij4e3X5ccUSdqW
90 const std::vector<TestVector> testCases{
91 // Using P2PK payout to
92 // 023beefdde700a6bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3
93 {"No utxo staked",
94 "96527eae083f1f24625f049d9e54bb9a21023beefdde700a6bc02036335b4df141c8b"
95 "c67bb05a971f5ac2745fd683797dde3002321023beefdde700a6bc02036335b4df141"
96 "c8bc67bb05a971f5ac2745fd683797dde3ac135da984db510334abe41134e3d4ef09a"
97 "d006b1152be8bc413182bf6f947eac1f8580fe265a382195aa2d73935cabf86d90a8f"
98 "666d0a62385ae24732eca51575",
99 ProofId::fromHex("979dbc3b1351ee12f91f537e04e61fdf93a73d5ebfc317bccd12"
100 "643b8be87b02"),
101 0, ProofValidationResult::NO_STAKE},
102 {"1 utxo staked",
103 "a6d66db9fe9378fdd37a0ad2c01c2acd21023beefdde700a6bc02036335b4df141c8b"
104 "c67bb05a971f5ac2745fd683797dde30145a4d07798547464daa53acefb7c97c0c415"
105 "ed8e81e549ff56a0ef6f847fcc9ca855b36200fe38dce5060000e707d7274104fb662"
106 "6e21dbd1cc9feeecdefc9213fdce2b51ac4bb44e1f8dc6f14c2052f5dd7bfaeb2267a"
107 "97ca2bec6e0dd4acf50a66204bde1ebb5d6c551684cff2f939920f7fbb2efd860d6d5"
108 "926bf425eb47b78bf6979cdcd67eb705e2c9a4d45a0930ba25463178a3fb99cb28c8b"
109 "77d8fcf68c54ebfadf08b9a446c251a0088301c50d532321023beefdde700a6bc0203"
110 "6335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac845148594a3067f06bc2cf"
111 "495a1191c00e012dd3d0e4b0c393b3e46c2adcebc3df50f1a203f02e445a0101f4675"
112 "26becb0aa4c64400a10bbde83b3f0290bdeaa",
113 ProofId::fromHex("e01bac293ed39e8d5e06214e7fe0bceb9646ef253ce501dcd7a4"
114 "75f802ab07f1"),
115 7584312, ProofValidationResult::INVALID_STAKE_SIGNATURE},
116 {"2 utxo staked",
117 "872379ab64f55b4166ca0e79639999ec21023beefdde700a6bc02036335b4df141c8b"
118 "c67bb05a971f5ac2745fd683797dde302fabf3ad5b875840e7813a66d5ea8a1288a49"
119 "b6222b59fcbe6249f94e5927f9f4b884b0b040a534b3ba040000d045d5d021036830e"
120 "697b0ee89866da798a8945bd85b352545ec1bcace7e04909ea54c134f16d5fe4e972b"
121 "7acd29ebfc2b7b11c26974b84e5f21a45bbe8372472f59e5dfdea7e9e5857c6aebe5d"
122 "bc5e646dfbf4e7cee380afaddb15d06153bf1755b9ef00a616d4c8c3c3a662b5eddc1"
123 "926564a488e3e68e334291078001480f7fa5144ef3a606a41e85c0218dd377090000e"
124 "41099912102ebfcea8e1864c1273c41e0d7c1e9097be5c491bbbf5fe31161d8e5589b"
125 "9d6b5b12f3b963c7fc7614d56d83af907e5cb18ac2f4c3e70a8c4253995f6bc002ec5"
126 "e350491c965cba4dbc11c210979217f1ac3ece7a748f5b2fcf5cced40a5d4c40e2321"
127 "023beefdde700a6bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ace"
128 "a8c988e488eaeef3dc441eb8ede93d2e249ecac3a4277d0347bb1abfdb79b7ebc507e"
129 "5447309db034983b38bd663242834b89026424472e192220863274b266",
130 ProofId::fromHex("ebf52f8d3c845761e55ef145a37537162e5fbbcc87c58a5b0040"
131 "d0a9c89003c4"),
132 15610172, ProofValidationResult::INVALID_STAKE_SIGNATURE},
133 {"3 utxo staked",
134 "525e2aa04af0e2457c66ac9e7f66257f21023beefdde700a6bc02036335b4df141c8b"
135 "c67bb05a971f5ac2745fd683797dde3039ce8d3b77938e49ce3bc9824e90b72c65542"
136 "2fb502f137e03a4499e5223d10096fe541eb80316ce3c80800000285f59341044fd7e"
137 "95de7c7bb30e7f60434a3e1a414a9e5d9c383c7b27396b1b84355a32e2996ecb98dc2"
138 "0143089932fa1b905a60fc3cfefeea193c91d1405f7c03de494fa4de065c067d64606"
139 "0e9270281c316d5c4c01d7e43d009151a72bf647794ce1727cbefaeb19719f916cd4d"
140 "d176c376a4da72431b61736d4a3e01c25ba057eac0af8f2988b78d1b75e02281fac56"
141 "2357a06353bf7f214c883e65add05b3a616300cb99cc963c0f4ded8c00e0000b03aab"
142 "f82103172b4f1890594508ab1e0cc5e9728b8a249660da4df724762a8fd888e8ece1b"
143 "d6fe923ed17ad0fd77a90d31e3877de1a8cdb4e95bcf2cdd6fb9768f86789f253b432"
144 "f3b5058b2d1892e90882529055fdedf8ae5d3280b2404a65321cf7f7229202db300ff"
145 "2897e33259a81dfc4bf296c3a156dc8dbfa074c602dd2250cc531b346fc28bb80ddf2"
146 "9ddc020000a713a5bb21035615635d449988a4eea03fd317e44481bde2e34a2489f3f"
147 "b24f0b0ea1cbfc4030bec095a8d3e9c2a233778535dc1fcc07755149b23ea8c17931a"
148 "37e9377eaa2f45bafb8d0bb9ba1700aab88fd6a53ea3e83d95ad2d84e7abe828f5570"
149 "91b185e2321023beefdde700a6bc02036335b4df141c8bc67bb05a971f5ac2745fd68"
150 "3797dde3acf3c32376092a751c432eb727544e6e5caab7e9be1c947ece79995ddc883"
151 "e6e1d48c6865554267cd8f388af277e4fa7a4ad6801f17db36074985ac477e250702"
152 "b",
153 ProofId::fromHex("8542635d83f8020bc781d9e8a3de53c23f5e3f77c21588719b58"
154 "b6618ee1782b"),
155 29026903, ProofValidationResult::INVALID_STAKE_SIGNATURE},
156 {"4 utxo staked",
157 "eef33172651f752ac255c85a4e13749921023beefdde700a6bc02036335b4df141c8b"
158 "c67bb05a971f5ac2745fd683797dde304295de5ebf9fbbbb65fc1d9a71587c5284cff"
159 "b2e834addefe090b8200435668c8f02c0b0100689a117e0e000007d801582102a682d"
160 "9d12d53b0eb37a3af2838510f079041905a75f82b6a3fb5558728d781fbf868d1d968"
161 "27b273f5a79f84ebe23add967a98f472fb80323439d0a65d546fc3745806f6d7f3381"
162 "24a7a2573864e97a26246644a7d7b05d97943dfcdb4b694df631e6dc5f87e28c1fe3e"
163 "5ba021f38c471638769041db81ffcf8c9887d078419f97fe2a2c408fee822c0600001"
164 "689b9cd2102e38d0adddcd7c88e3c87b8babcae10647e2862fb719839fc8890e42aeb"
165 "929b85e1a3f14e2cdc65e2b1396f2dae41b047958cdc7e4d2f6fa051065829e26797c"
166 "5b882e45bb9fea32c0b0e0ad90f8ac1e5d8d0b16a9b74d77614b7fd99e56b6091aca3"
167 "67f8f7a68d1b654e51dd00733bd191dc9bea2ba750e063b05d962aaf9c4d2088ce4f0"
168 "03e73e253040000a5eebe222103a20dd85b66b44b22fdd17a93762194c9bedb442c7f"
169 "fd7f08a9f82c42a8c1d9a0443f700cb8a40c8cf7f840b5137b6d019efed961771d095"
170 "88b0eb3c5e1672bb95b06ca7e2068e564001aa75b8c37bb6601117c286b6b0c9728d1"
171 "e928ab02e3b67e9422b484ef2624ce5de974b5bd616874ec39d03d32ed0bf114759b7"
172 "0bf5dcef51534b100515301140f0000950121754104d66dba1569164a134111961133"
173 "4bad5e2d398823f1454ceecb9c4266fd3ba4b969ac4d4f6c4b3975d19c2f7dcbbca09"
174 "6af5395780a2d3c42505146c095bc861fab15238fb8aa1fb82c7ad28b0ee5d1335348"
175 "76dc7887490c7c6e61103b2cd221f1991826a73fecf08e0b5a0a7d357a5431eee032d"
176 "14a348c80ca1833d68b3d7b2321023beefdde700a6bc02036335b4df141c8bc67bb05"
177 "a971f5ac2745fd683797dde3ac157f7621dd2ce427c07dc0da1fc46412edd5c78b10c"
178 "e70e7e6010c65d22de2f434e4f08c158af3c9f5a2411677bd69adbaec068cbb04e79f"
179 "90dbdcb6be2b437f",
180 ProofId::fromHex("6ba2a3ff986d5bc4457da693096bab408cfd8cf4e988e5ac013f"
181 "e48a4e2961c9"),
182 44059793, ProofValidationResult::INVALID_STAKE_SIGNATURE},
183 {"Properly signed 1 UTXO proof",
184 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
185 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
186 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
187 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
188 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
189 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
190 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
191 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9ac05a9ea3a5333926249331f"
192 "34a41a3519bab179ce9228dc940019ee80f754da0499379229f9b49f1bccc6566a734"
193 "7227299f775939444505952f920ccea8b9f18",
194 ProofId::fromHex("cdcdd71605139f49d4884b0c3d9a6be309f07b008a760bb3b25f"
195 "cfcb7a3ffc46"),
196 444638638, ProofValidationResult::NONE},
197 {"Duplicated UTXO",
198 "c964aa6fde575e4ce8404581c7be874e21023beefdde700a6bc02036335b4df141c8b"
199 "c67bb05a971f5ac2745fd683797dde302d1e26c2287948bc6ab2b55945c591b8ba3ff"
200 "a237f5d9164d30a4f10145a61f788e639b1480731e2aead30500bf8462872102449fb"
201 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6806b8111af77"
202 "e1076caba7cb76de29abae963b7f6a1879318e8e37ff488d5843b783215fe9561431a"
203 "c55ecef78ce214869aac0c271d35bee7fdb0858a7ddffe3b0d1e26c2287948bc6ab2b"
204 "55945c591b8ba3ffa237f5d9164d30a4f10145a61f788e639b1480731e2aead30500b"
205 "f8462872102449fb5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8"
206 "bce6802f5c4b2a2ab7fb315d3b9e0318e4e90faa997f28ea6fb31c3487332718079c1"
207 "0131da1acd028a093be651330679bb02bd471053e18a590e373a08c2e60ca15f92321"
208 "038439233261789dd340bdc1450172d9c671b72ee8c0b2736ed2a3a250760897fdac3"
209 "dfb66133d94674a3a6565d8f84e1a31e2f79a4bb399c04adc802abcf8b395f62315d3"
210 "ad8450ba57e11dfb61b1f5a7325094d5ffda1f5830e0990dcc2ebb9be8",
211 ProofId::fromHex("5d4919b43a1afb6acdeddaf1678397eaa10562125db6b911ec4e"
212 "35fd8598ad73"),
213 // Stake amounts sum above MAX_MONEY (3280755132); score is saturated.
214 Proof::amountToScore(MAX_MONEY),
215 ProofValidationResult::DUPLICATE_STAKE},
216 {"Properly signed 3 UTXO proof",
217 "c964aa6fde575e4ce8404581c7be874e21023beefdde700a6bc02036335b4df141c8b"
218 "c67bb05a971f5ac2745fd683797dde3030b1e5f35704cb63360aa3d5f444ee35eea4c"
219 "154c1af6d4e7595b409ada4b42377764698aaa9da7a9070000000f28db322102449fb"
220 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680bff436d745"
221 "ad2517f048748d49425db654ad2db24a89cbf91221f3d2e8833cbc63395b0b6f25e54"
222 "3bc4c081e57dd7c29e271d0245230077eddfa991e418a9cceac098c86414715db364a"
223 "4e32216084c561acdd79e0860b1fdf7497b159cb132304512002dcdf1b4c090000009"
224 "f2bc7392102449fb5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8"
225 "bce680cbfabd2e54169fa88efc205505dca2bd65baf893eb38dfa2bc5a691569ed660"
226 "6873d8abc9b68951f8a76db379fb1244d0a1e005d310774f3dbd7863c5f6b060ce4ed"
227 "76e1f19b2c2a0fcc069b4ace4a078cb5cc31e9e19b266d0af41ea8bb0c30c8b47c959"
228 "0627dac060000007dfdd89a2102449fb5237efe8f647d32e8b64f06c22d1d40368eac"
229 "a2a71ffc6a13ecc8bce6800d930fdf810c20955b67deb1b7db92a1e4f835da7b48495"
230 "4ab1c0b982b3821d627a99fc244c9f9556a3b2b2db0098b5c4ef4578de2df3df6b744"
231 "249d456987881976a914f8172c51efbf34413a308a030fd4b164c5bfcd8f88ac87b98"
232 "97ce7b037539f910559fc8ddf69edd509484119f39a344cad40b4b7655438dabf7142"
233 "7a37b92e0e6e29226b6474022ea16be6108ab0f9075f0cd391e746",
234 ProofId::fromHex("526e0e5aef9d857d8c4c15208cc30b5a00818627eebe06098055"
235 "a88d57d461b0"),
237 {"Changing sequence affect ProofId but not the stake signature",
238 "d87587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
239 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
240 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
241 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
242 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
243 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
244 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
245 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9ac80bdeb2ada22b35856fa25"
246 "d2fe7a145b4ce09c6332b72925dbf2b09140d6163863437a8076f7836fcbb7154b831"
247 "65a65910d1b2a8c3655d111f008a57315f5a0",
248 ProofId::fromHex("8b0640e7bf81f487d90d6b5c3ead4bc41eae418da4e6874618b2"
249 "89124e52ba1e"),
250 444638638, ProofValidationResult::NONE},
251 {"Changing expiration affect ProofId",
252 "d97587e6c882615797011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
253 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
254 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
255 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
256 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
257 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
258 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
259 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9ac5995555107107e656abd8e"
260 "2852f311ff0f5c4f606695b63ec44e04303e3378a2e21e16bf05727240ebee1334d2f"
261 "858c6c2e3bdd8d289400b99d7f70b35f9d2fa",
262 ProofId::fromHex("26ce40e7b5dfc8d3d48d743ed23fa6ff32ca269a59c4fb101b3b"
263 "48e5d8450465"),
264 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
265 {"Changing the TxId affect the ProofId",
266 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
267 "c67bb05a971f5ac2745fd683797dde30179a79ff23e1d58c64afad42ad81cffe53967"
268 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
269 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
270 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
271 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
272 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
273 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9acaefee33b8b7a0ce4d5d1ab"
274 "92ea8d08dd2538102a4dde790f6317558ceb68e5d2267aac97a0f313dccec827d0401"
275 "a3095b4e862068077ce942380b474c30b64e0",
276 ProofId::fromHex("4b57e163adc5174820ce21eb0e0e9d6565bc00d51bf9f86c58c5"
277 "6947428c2d84"),
278 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
279 {"Changing the outpoint index change the ProofId",
280 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
281 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
282 "e16beb692fc5776bb442c79c5d91df00cf21804712806594010038e168a32102449fb"
283 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
284 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
285 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
286 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
287 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9acecc6e78166848efad9772b"
288 "a11ed0a8b1e9e844cbc2727c69c5e1898430548c9062a52ca9dc1dbe614213d9f7d54"
289 "65dc297d0dc1880adb7daf088f6927a4d6a51",
290 ProofId::fromHex("b569969b77b683904a89c3364c667ac434602936548c80352a85"
291 "ffed4c934cbc"),
292 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
293 {"Changing the amount changes the ProofId",
294 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
295 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
296 "e16beb692fc5776bb442c79c5d91de00cf21814712806594010038e168a32102449fb"
297 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
298 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
299 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
300 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
301 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9acefbdde03c4cc7065075d06"
302 "6c693086c0df0b6b349ec9300ff1333cca65d076364560fb2cbb1365240cdd6c9c323"
303 "d73fc17576da71a5c336a170f76a1b52ffc89",
304 ProofId::fromHex("6989ce300064196c177eae6fd73cf3f89719ddedf068e757eb39"
305 "eb2030baa846"),
306 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
307 {"Changing the height changes the ProofId",
308 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
309 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
310 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010028e168a32102449fb"
311 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
312 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
313 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
314 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
315 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9ac4fc8c51b5a993c0a8f3a53"
316 "c88fb49f228305da66d20b8c73e7e9de55300ac1de52c898fa73e8c5f54a727edc4a6"
317 "76a66dc8bb89bd6c54d41053edceaead6d7b1",
318 ProofId::fromHex("81d217bbfa019439ab6dfbe02b8b703b93eb26e6047a7ee3cc4a"
319 "ba1366286d8d"),
320 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
321 {"Changing the pubkey changes the ProofId",
322 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
323 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
324 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102459fb"
325 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
326 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
327 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fc43410469ab5a892ffa4b"
328 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
329 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9ac893ad17cf6a17016f35337"
330 "f6a10f85357689be2760734137c51225cbe0eca4fa00b671f50deacfb86afd61d9cdf"
331 "ae24aa1e9ced62954c4f8eb8114bb4fb852fe",
332 ProofId::fromHex("e33e02f3d608b4a6447c3b3ee283763718716fff02f3a79e3251"
333 "417bd03b9834"),
334 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
335 {"Changing the signature does NOT change the ProofId",
336 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
337 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
338 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
339 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68099f1e258ab"
340 "54f960102c8b480e1dd5795422791bb8a7a19e5542fe8b6a76df7fa09a3fd4be62db7"
341 "50131f1fbea6f7bb978288f7fe941c39ef625aa80576e19fd43410469ab5a892ffa4b"
342 "b104a3d5760dd893a5502512eea4ba32a6d6672767be4959c0f70489b803a47a3abf8"
343 "3f30e8d9da978de4027c70ce7e0d3b0ad62eb08edd8f9ac3359ba425e0084157ca510"
344 "e30865693578e3f5eb426d97597ccbd7766db411abaf653aea59c34861cbafeaee076"
345 "8ae58fa2b68a7bfdcdbdc041c50ea59cf1b22",
346 ProofId::fromHex("cdcdd71605139f49d4884b0c3d9a6be309f07b008a760bb3b25f"
347 "cfcb7a3ffc46"),
348 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
349 {"1 utxo staked but zero coins",
350 "a6d6852ffa70b172d37a0ad2c01c2acd21023beefdde700a6bc02036335b4df141c8b"
351 "c67bb05a971f5ac2745fd683797dde30145a4d07798547464daa53acefb7c97c0c415"
352 "ed8e81e549ff56a0ef6f847fcc9ca855b3620000000000000000e707d7272102449fb"
353 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680061c669954"
354 "f964a68b43b1b354b65b651f349a3ff310a1dcb862aa285f26fc7f6fd0b9cb766f1e1"
355 "f90fc63ce03c956b3dac9a4ac2fff963f643ae1326b08d33c2321023beefdde700a6b"
356 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac6ad76de70caa0fb07"
357 "12a44e24f791244f733017920ef42c876220a9c50f0239d97414829fe9103741aba28"
358 "7579d8ea26ca28162e3091d53cc51fd58be9b18d22",
359 ProofId::fromHex("c95e3c6417a799dd3085af689ea12fb3d2e1130870fef9f0bdc6"
360 "d10a27df746a"),
361 0, ProofValidationResult::DUST_THRESHOLD},
362 {"Properly signed 1 UTXO proof, P2PK payout script",
363 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
364 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
365 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
366 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6804534ca1f5e"
367 "22670be3df5cbd5957d8dd83d05c8f17eae391f0e7ffdce4fb3defadb7c079473ebec"
368 "cf88c1f8ce87c61e451447b89c445967335ffd1aadef429982321023beefdde700a6b"
369 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
370 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
371 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
372 ProofId::fromHex("455f34eb8a00b0799630071c0728481bdb1653035b1484ac33e9"
373 "74aa4ae7db6d"),
374 444638638, ProofValidationResult::NONE},
375 {"Properly signed 1 UTXO proof, P2PKH payout script",
376 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
377 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
378 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
379 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6804848a02e2b"
380 "1c8aa1d21c31b056ab6a63f08e07bb0b56258d1c58b87f3ff472b7b5b9a5907142a04"
381 "041e95e6874ae0874d0f7bbe266f7c4606af315711d0f49341976a914f8172c51efbf"
382 "34413a308a030fd4b164c5bfcd8f88ac2d805b078f5efe022304f8c6ccd0ef5255d80"
383 "6a473fc85a5ad1caf1aa94a4e49ef7625b9dc85d263b2829d5822af62226bc50a4a83"
384 "76a3a6e1cd0a37ea2fbbf9",
385 ProofId::fromHex("8a2fcc5700a89f37a3726cdf3202353bf61f280815a9df744e3c"
386 "9de6215a745a"),
387 444638638, ProofValidationResult::NONE},
388 {"Properly signed 1 UTXO proof, P2SH payout script",
389 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
390 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
391 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
392 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680575db01b67"
393 "5b042bf1ab89aa6ad3842804bb57bf87ebf2bfbcb169debdbf9c51e5d2638eb981bfd"
394 "0e7465a5f3edd152d52b2f6d0108fcd277168be362e849e1f17a914da1745e9b549bd"
395 "0bfa1a569971c77eba30cd5a4b87fea0a245528a4aadfc1dd5731c0cfe738e276c938"
396 "15c69789fe97b15a5fb5b4f75b598ed94096205561e8d16203b8ef21763891d8e79a5"
397 "9862bccbbd5bdf3a58",
398 ProofId::fromHex("c61ee0416eb9549ea0e09dfd2c6062a11aa5d3ab0adcdf59abcc"
399 "02dd0de401fc"),
400 444638638, ProofValidationResult::NONE},
401 {"Properly signed 1 UTXO proof, 1-of-1 multisig payout script",
402 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
403 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
404 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
405 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680ea4c55850f"
406 "587c7839fe254880547049a8be7c27cf511e440fa46237db32dced28e0c10edcf5ddb"
407 "31e2f61e5c749e7324e7edf9aa09547810d64a12fb960a206255121023beefdde700a"
408 "6bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde351ae29eaecb058c9b"
409 "b74eef68dbeaa5da8b96aacc00bc89c911095ad016cfbdc53b1eeb10a9f29d6c48a5f"
410 "b3a1e6e30d332a05bdc67062f94acffbe6d6c909bb5643",
411 ProofId::fromHex("29deedc94713bbc4d4f88fe96fae6801b91c5ae50601f158fa76"
412 "a036e18ea468"),
413 444638638, ProofValidationResult::NONE},
414 {"Properly signed 1 UTXO proof, 2-of-3 multisig payout script",
415 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
416 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
417 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
418 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680edf24d6c6e"
419 "1ed44a0e0d651d5d2611f80e5c921778c3cbc2923fade878d7d9c69e5f4f7ff0c8dd9"
420 "985ff427011c5cf0cac854c607e1d788d140f8b6d6010aad8695221023beefdde700a"
421 "6bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde321023beefdde700a6"
422 "bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde321023beefdde700a6b"
423 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde353ae34814734c1bd2c4"
424 "76fdae6fb1145530c3244878f3c2e0c2e5c05da14f17456aedee6beb80f68f42248fd"
425 "89042346be54beaef7da8e549d7d5ff07f9a2cc63c83",
426 ProofId::fromHex("c24dc13d98d0e0a80c19346b9590368557a66f0f65c0088c179d"
427 "89eca25107c8"),
428 444638638, ProofValidationResult::NONE},
429 {"Properly signed 1 UTXO proof, OP_RETURN payout script",
430 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
431 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
432 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
433 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680b746fe5c9d"
434 "10002880169f03c69456f57d60589cd451c2fa078fc0241a022f2c6f1736b4bb49ea0"
435 "d7b878e581de9625f301c68defeda9d506f9b128dbccb08481b6a19492077616e7420"
436 "746f206275726e206d792072657761726473f42ae2e5fa253a700e5dcb3970a894db4"
437 "48b61960b45c84723bf769d4dab0370994d0163e235b688da2fabc8e5b57e24805dce"
438 "3baa62e064c32266a723c6adb6",
439 ProofId::fromHex("bfc250ca1986177acc779f26eaff80aa8916d23cb3e7e0ce6d35"
440 "89c4f5ea364c"),
441 444638638, ProofValidationResult::NONE},
442 {"Invalid payout script (OP_FALSE)",
443 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
444 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
445 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
446 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce68082a5aec394"
447 "b2a25fedc70a81f93bb08b46a51bd1259f3f10fa421a4989039d74d30cf449de3b8b4"
448 "6551b8ec927a83d16caaf8fc32636110407cfc9effbaf8c210100b71f0e77b4ad5d73"
449 "d5a872ab43699309b5c194f72be5ee0812236c1a46a5b2c22ddd71d909cf52143f487"
450 "54a61dfe0c6566342fa50b7d62c40fb44d1ff5abed3",
451 ProofId::fromHex("046e75fa2d7f0868dcfa683bbdf657fc6a49b8f8b0d5c2dfdf90"
452 "736ded26b076"),
453 444638638, ProofValidationResult::INVALID_PAYOUT_SCRIPT},
454 {"Invalid payout script (1-of-5 multisig)",
455 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
456 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
457 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
458 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6804d972714d8"
459 "bcdeb680cd736ee6252c92453d7de362b97007c77abe1d76c80c41b502aa331a94d50"
460 "fb2d709b66a679e2b4b2385dd2f4fad13c85015fc4c6ae7e4ad5121023beefdde700a"
461 "6bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde321023beefdde700a6"
462 "bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde321023beefdde700a6b"
463 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde321023beefdde700a6bc"
464 "02036335b4df141c8bc67bb05a971f5ac2745fd683797dde321023beefdde700a6bc0"
465 "2036335b4df141c8bc67bb05a971f5ac2745fd683797dde355ae005dfe80b01bc99f9"
466 "3ae1d1c2d7176f7ea54a7f7c76b6eabb1aec5d31de170b0690282f624d01070fb2700"
467 "18694aea6a73ac5b7a96e30ed69df9b7684298b986",
468 ProofId::fromHex("e66b0ab11de5e2f358d2e1f65b1ebe608e4a1f10a9f5d42f1173"
469 "b262e1a218a6"),
470 444638638, ProofValidationResult::INVALID_PAYOUT_SCRIPT},
471 {"Changing the payout address changes the proof signature (P2PK) but "
472 "not the stake signature",
473 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
474 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
475 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
476 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6804534ca1f5e"
477 "22670be3df5cbd5957d8dd83d05c8f17eae391f0e7ffdce4fb3defadb7c079473ebec"
478 "cf88c1f8ce87c61e451447b89c445967335ffd1aadef429982321023beefdde700a6b"
479 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde4ac7b0b7865200f63052"
480 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
481 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
482 ProofId::fromHex("ce2812a1decdef0267e0266c68ab53c5ecad292f7b7d0fbd3db9"
483 "285a08ccd2a1"),
484 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
485 // The following tests are based on the valid 1 UTXO proof (P2PK script)
486 {"Changing the sequence changes the proof signature",
487 "da7587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
488 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
489 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
490 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6808ef3a5bb64"
491 "dc73a757aba041f348e7bc93c9c96f53a3d48a9a9df6f505f37283834788bad9370e9"
492 "e6e702f8ba5323d38cb3b720adfefee6af4187ee6d9bed2482321023beefdde700a6b"
493 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
494 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
495 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
496 ProofId::fromHex("37a08e004f35d6410b24a5724b8351b41d4e3ac04f285cd76d73"
497 "a023b2ae5519"),
498 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
499 {"Changing the expiration time changes the proof signature",
500 "d97587e6c882615797011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
501 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
502 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
503 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680e475b4323a"
504 "a8775b6b0ab82985f515bd95fb1cc18389d40c7a59a49df1ffa788ae68cfcc21e60c0"
505 "e39806e935ce19b71f1182f4ca83f51d654a95b2e9b021ea12321023beefdde700a6b"
506 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
507 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
508 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
509 ProofId::fromHex("1312eff53594f63e61f044c36b2cf2d3e7e44c706f17bfabcf49"
510 "954741380bbc"),
511 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
512 {"Changing the master pubkey does NOT change the proof signature (but "
513 "signature verification obviously fails)",
514 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
515 "c67bb05a971f5ac2745fd683797dde40169a79ff23e1d58c64afad42ad81cffe53967"
516 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
517 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680306b113bd2"
518 "fc0e5c4f0cc46aed8a6c8efb0b5bcdc214ad78a29e00b1174c67d1c4576f4d815ba74"
519 "ef6bdd0d8243402f6c4c8dcf71a4eb24d97f6d6b1d4a65b912321023beefdde700a6b"
520 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
521 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
522 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
523 ProofId::fromHex("de837b44ae2df5408f89dc42039ae53a61ea508a15e214e69a50"
524 "d940b72e7713"),
525 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
526 {"Changing the TxId changes the proof signature",
527 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
528 "c67bb05a971f5ac2745fd683797dde3016aa79ff23e1d58c64afad42ad81cffe53967"
529 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
530 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680e0d7f1933e"
531 "b1e4f9011b9cf363f198f764ff5d65f471f4e4568beeed834d15f6917378fc9f84a3a"
532 "5c3e445329dbfed556d82ba43e74619e32baad4b3437e2f482321023beefdde700a6b"
533 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
534 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
535 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
536 ProofId::fromHex("2c90b8359740d675952b570cca76ffb7c1a225984b8c7f47bc27"
537 "607c58a613b5"),
538 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
539 {"Changing the outpoint index changes the proof signature",
540 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
541 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
542 "e16beb692fc5776bb442c79c5d91df00cf21804712806594010038e168a32102449fb"
543 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6803671ac4cd4"
544 "928d9db4be75e0213709e903855369c90f2bd8459ad24ad936a09c550b87d2ab7c7c0"
545 "f1e7b18c484c65aa175e3fc10088b198334d9b2846d7c19272321023beefdde700a6b"
546 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
547 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
548 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
549 ProofId::fromHex("289c082f835c2edd24b95e1aee7dbb353dff30cdcaab02d5dc2a"
550 "c44c57181468"),
551 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
552 {"Changing the amount changes the proof signature",
553 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
554 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
555 "e16beb692fc5776bb442c79c5d91de00cf21814712806594010038e168a32102449fb"
556 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680c4a8d2cbb3"
557 "ef086b41da91cbf99404c4970fee9cd8dff8c82d4169751e1049fb2506a194e14ef96"
558 "4f308f1afdbb3853df59f58fa88cedcf71722f8130f89e6ef2321023beefdde700a6b"
559 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
560 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
561 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
562 ProofId::fromHex("8d97d3ed1884462122976da4706778593fc4b5eaafb859bec0b4"
563 "5f590219f5ba"),
564 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
565 {"Changing the height changes the proof signature",
566 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
567 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
568 "e16beb692fc5776bb442c79c5d91de00cf2180471280659401003ae168a32102449fb"
569 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6804fb8adfb4e"
570 "08ad2e6284042968f65dfe365b975492fdac597c75ae91edcb3b0d7ad9352d0cff1b2"
571 "7577eb5fc4646f0106d57d214f71ce21272eb31af09482f2b2321023beefdde700a6b"
572 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
573 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
574 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
575 ProofId::fromHex("690cb3d74b5add1cfb7d4cf186426d41117586c57d59da330cc9"
576 "50e2d18d613c"),
577 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
578 {"Changing the coinbase flag changes the proof signature",
579 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
580 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
581 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010039e168a32102449fb"
582 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6807b0eeab05c"
583 "31d69c288fab140311274530dea518a7b62846c33e6a087b489210fed85b8a18017d4"
584 "30751e81e276aecdb565a3cd5c58b5a0f81cbf5af33196dfd2321023beefdde700a6b"
585 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
586 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
587 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
588 ProofId::fromHex("f713dec5d2f798360748914face171d5a45706b9c5f0bc4d561f"
589 "6e80e098beef"),
590 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
591 {"Changing the stake pubkey changes the proof signature",
592 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
593 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
594 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
595 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6814534ca1f5e"
596 "22670be3df5cbd5957d8dd83d05c8f17eae391f0e7ffdce4fb3defadb7c079473ebec"
597 "cf88c1f8ce87c61e451447b89c445967335ffd1aadef429982321023beefdde700a6b"
598 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
599 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
600 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
601 ProofId::fromHex("df84548b3a085e29d58ba5e83ad2fd1c9ecbe8595d4240f3f588"
602 "e52af84cc65b"),
603 444638638, ProofValidationResult::INVALID_PROOF_SIGNATURE},
604 {"Changing the stake signature does NOT change the proof signature",
605 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
606 "c67bb05a971f5ac2745fd683797dde30169a79ff23e1d58c64afad42ad81cffe53967"
607 "e16beb692fc5776bb442c79c5d91de00cf21804712806594010038e168a32102449fb"
608 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce6804534ca1f5e"
609 "22670be3df5cbd5957d8dd83d05c8f17eae391f0e7ffdce4fb3defadb7c079473ebec"
610 "cf88c1f8ce87c61e451447b89c445967335ffd1aadef429992321023beefdde700a6b"
611 "c02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac7b0b7865200f63052"
612 "ff980b93f965f398dda04917d411dd46e3c009a5fef35661fac28779b6a22760c0000"
613 "4f5ddf7d9865c7fead7e4a840b947939590261640f",
614 ProofId::fromHex("455f34eb8a00b0799630071c0728481bdb1653035b1484ac33e9"
615 "74aa4ae7db6d"),
616 444638638, ProofValidationResult::INVALID_STAKE_SIGNATURE},
617 {"Adding a stake changes the proof signature but does not involve "
618 "changing the previous stake signature",
619 "d97587e6c882615796011ec8f9a7b1c621023beefdde700a6bc02036335b4df141c8b"
620 "c67bb05a971f5ac2745fd683797dde3026aa79ff23e1d58c64afad42ad81cffe53967"
621 "e16beb692fc5776bb442c79c5d91df00cf2180471280659401003be168a32102449fb"
622 "5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8bce680f2adfb4bcb"
623 "14bf1f6aa38a44994419bd34e9da07d972d3f092cd3ef037fe7bcd92e3d7073faa7e6"
624 "e0697b9fab8670417959ab0b0958fdc576a11dffe599e851269a79ff23e1d58c64afa"
625 "d42ad81cffe53967e16beb692fc5776bb442c79c5d91de00cf2180471280659401003"
626 "8e168a32102449fb5237efe8f647d32e8b64f06c22d1d40368eaca2a71ffc6a13ecc8"
627 "bce6804534ca1f5e22670be3df5cbd5957d8dd83d05c8f17eae391f0e7ffdce4fb3de"
628 "fadb7c079473ebeccf88c1f8ce87c61e451447b89c445967335ffd1aadef429982321"
629 "023beefdde700a6bc02036335b4df141c8bc67bb05a971f5ac2745fd683797dde3ac9"
630 "32ce54c4d405de52399cf48b4b10038d1bbbd65206f0934b2bdfc7b6a4a2e1cff1803"
631 "a69bd03dd3897d4cfde46c2ee2cf17895880770c8b49089a26b6b5ff1e",
632 ProofId::fromHex("96bd9fee759d81f9bc30e26015d979df3f6046c7a8764582d1a2"
633 "c5c3d61c2f44"),
634 2 * 444638638, ProofValidationResult::NONE},
635 };
636
637 for (const auto &c : testCases) {
638 Proof p;
639 bilingual_str error;
640 BOOST_CHECK(Proof::FromHex(p, c.hex, error));
641 BOOST_CHECK_EQUAL(p.getId(), c.proofid);
642 BOOST_CHECK_EQUAL(p.getScore(), c.score);
643
646 c.result == ProofValidationResult::NONE);
647 BOOST_CHECK(state.GetResult() == c.result);
648 BOOST_TEST_MESSAGE(c.proofid);
649 }
650}
651
653 gArgs.ForceSetArg("-avaproofstakeutxoconfirmations", "1");
654
655 auto key = CKey::MakeCompressedKey();
656 const CPubKey pubkey = key.GetPubKey();
657
658 const Amount value = 2 * PROOF_DUST_THRESHOLD;
659 const uint32_t height = 10;
660
661 ChainstateManager &chainman = *Assert(m_node.chainman);
662 LOCK(cs_main);
663 CCoinsViewCache &coins = chainman.ActiveChainstate().CoinsTip();
664
665 COutPoint pkh_outpoint(TxId(m_rng.rand256()), m_rng.rand32());
666 CTxOut pkh_output(value, GetScriptForRawPubKey(pubkey));
667 coins.AddCoin(pkh_outpoint, Coin(pkh_output, height, false), false);
668
669 COutPoint nonstd_outpoint(TxId(m_rng.rand256()), m_rng.rand32());
670 CTxOut nonstd_output(value, CScript() << OP_TRUE);
671 coins.AddCoin(nonstd_outpoint, Coin(nonstd_output, height, false), false);
672
673 COutPoint p2sh_outpoint(TxId(m_rng.rand256()), m_rng.rand32());
674 CTxOut p2sh_output(value,
675 GetScriptForDestination(ScriptHash(m_rng.rand160())));
676 coins.AddCoin(p2sh_outpoint, Coin(p2sh_output, height, false), false);
677
678 const auto runCheck = [&](const ProofValidationResult result,
679 const COutPoint &o, const Amount v,
680 const uint32_t h, const bool is_coinbase,
681 const CKey &k, int64_t expirationTime = 0) {
682 // Generate a proof that match the UTXO.
683 ProofBuilder pb(0, expirationTime, key,
685 BOOST_CHECK(pb.addUTXO(o, v, h, is_coinbase, k));
686 ProofRef p = pb.build();
687
690 LOCK(cs_main);
691 BOOST_CHECK(p->verify(PROOF_DUST_THRESHOLD, chainman, state) ==
692 (result == ProofValidationResult::NONE));
693 BOOST_CHECK(state.GetResult() == result);
694 };
695
696 const int64_t currentTipMTP = chainman.ActiveTip()->GetMedianTimePast();
697
698 // Valid proof
699 runCheck(ProofValidationResult::NONE, pkh_outpoint, value, height, false,
700 key);
701
702 // Expiration checks
703
704 // Negative or zero expiration times means no expiration
705 runCheck(ProofValidationResult::NONE, pkh_outpoint, value, height, false,
706 key, -1);
707 runCheck(ProofValidationResult::NONE, pkh_outpoint, value, height, false,
708 key, 0);
709 runCheck(ProofValidationResult::NONE, pkh_outpoint, value, height, false,
710 key, std::numeric_limits<int64_t>::min());
711
712 // The future
713 runCheck(ProofValidationResult::NONE, pkh_outpoint, value, height, false,
714 key, std::numeric_limits<int64_t>::max());
715 runCheck(ProofValidationResult::NONE, pkh_outpoint, value, height, false,
716 key, currentTipMTP + 1);
717
718 // Expired proofs
719 runCheck(ProofValidationResult::EXPIRED, pkh_outpoint, value, height, false,
720 key, 1);
721 runCheck(ProofValidationResult::EXPIRED, pkh_outpoint, value, height, false,
722 key, currentTipMTP - 1);
723 runCheck(ProofValidationResult::EXPIRED, pkh_outpoint, value, height, false,
724 key, currentTipMTP);
725
726 // Coinbase mismatch
727 runCheck(ProofValidationResult::COINBASE_MISMATCH, pkh_outpoint, value,
728 height, true, key);
729
730 // Height mismatch
731 runCheck(ProofValidationResult::HEIGHT_MISMATCH, pkh_outpoint, value,
732 height + 1, false, key);
733
734 // Amount mismatch
735 runCheck(ProofValidationResult::AMOUNT_MISMATCH, pkh_outpoint,
736 value + 1 * SATOSHI, height, false, key);
737
738 // Invalid outpoints
739 runCheck(ProofValidationResult::MISSING_UTXO,
740 COutPoint(pkh_outpoint.GetTxId(), pkh_outpoint.GetN() + 1), value,
741 height, false, key);
742 runCheck(ProofValidationResult::MISSING_UTXO,
743 COutPoint(TxId(m_rng.rand256()), pkh_outpoint.GetN()), value,
744 height, false, key);
745
746 // Non standard script
747 runCheck(ProofValidationResult::NON_STANDARD_DESTINATION, nonstd_outpoint,
748 value, height, false, key);
749
750 // Non PKHhash destination
751 runCheck(ProofValidationResult::DESTINATION_NOT_SUPPORTED, p2sh_outpoint,
752 value, height, false, key);
753
754 // Mismatching key
755 {
756 runCheck(ProofValidationResult::DESTINATION_MISMATCH, pkh_outpoint,
757 value, height, false, CKey::MakeCompressedKey());
758 }
759
760 // No stake
761 {
762 ProofRef p =
764
766 BOOST_CHECK(!p->verify(PROOF_DUST_THRESHOLD, chainman, state));
767 BOOST_CHECK(state.GetResult() == ProofValidationResult::NO_STAKE);
768 }
769
770 // Dust thresold
771 {
772 // tuple<utxo value, dust threshold, result>
773 const std::vector<std::tuple<Amount, Amount, ProofValidationResult>>
774 testCases = {
775 // Defaults
777 ProofValidationResult::DUST_THRESHOLD},
779 ProofValidationResult::DUST_THRESHOLD},
781 // Modified threshold
782 {Amount::zero(), value, ProofValidationResult::DUST_THRESHOLD},
783 {value - 1 * SATOSHI, value,
784 ProofValidationResult::DUST_THRESHOLD},
785 {value, value, ProofValidationResult::NONE},
786 };
787
788 for (const auto &[utxoValue, dustThreshold, expectedResult] :
789 testCases) {
792 pb.addUTXO(pkh_outpoint, utxoValue, height, false, key));
793 ProofRef p = pb.build();
794
796 BOOST_CHECK(p->verify(dustThreshold, chainman, state) ==
797 (expectedResult == ProofValidationResult::NONE));
798 BOOST_CHECK(state.GetResult() == expectedResult);
799 }
800 }
801
802 // Duplicated input
803 {
805 BOOST_CHECK(pb.addUTXO(pkh_outpoint, value, height, false, key));
806 ProofRef p = TestProofBuilder::buildDuplicatedStakes(pb);
807
809 BOOST_CHECK(!p->verify(PROOF_DUST_THRESHOLD, chainman, state));
810 BOOST_CHECK(state.GetResult() ==
811 ProofValidationResult::DUPLICATE_STAKE);
812 }
813
814 // Wrong stake ordering
815 {
816 COutPoint other_pkh_outpoint(TxId(m_rng.rand256()), m_rng.rand32());
817 CTxOut other_pkh_output(value, GetScriptForRawPubKey(pubkey));
818 coins.AddCoin(other_pkh_outpoint, Coin(other_pkh_output, height, false),
819 false);
820
822 BOOST_CHECK(pb.addUTXO(pkh_outpoint, value, height, false, key));
823 BOOST_CHECK(pb.addUTXO(other_pkh_outpoint, value, height, false, key));
824 ProofRef p = TestProofBuilder::buildWithReversedOrderStakes(pb);
825
827 BOOST_CHECK(!p->verify(PROOF_DUST_THRESHOLD, chainman, state));
828 BOOST_CHECK(state.GetResult() ==
829 ProofValidationResult::WRONG_STAKE_ORDERING);
830 }
831
832 // Immature stake
833 {
834 uint32_t chaintipHeight = chainman.ActiveHeight();
835
836 // A proof where the UTXO is both missing and immature gives
837 // MISSING_UTXO
838 {
839 gArgs.ForceSetArg("-avaproofstakeutxoconfirmations", "11");
840 for (auto h = chaintipHeight; h > chaintipHeight - 10; h--) {
841 COutPoint outpoint(TxId(m_rng.rand256()), m_rng.rand32());
842 CTxOut output(value, GetScriptForRawPubKey(pubkey));
843 runCheck(ProofValidationResult::MISSING_UTXO, outpoint, value,
844 h, false, key);
845
846 // Add the coin to the UTXO set to verify it's immature
847 coins.AddCoin(outpoint, Coin(output, h, false), false);
848 runCheck(ProofValidationResult::IMMATURE_UTXO, outpoint, value,
849 h, false, key);
850 }
851 }
852
853 // tuple<stake utxo confs, avaproofstakeutxoconfirmations, result>
854 const std::vector<
855 std::tuple<uint32_t, std::string, ProofValidationResult>>
856 testCases = {
857 // Require less or equal the number of confirmations the stake
858 // has
859 {chaintipHeight, "1", ProofValidationResult::NONE},
861 {50, "50", ProofValidationResult::NONE},
862 {50, "51", ProofValidationResult::NONE},
863 // Require more than the number of confirmations the stake has
864 {chaintipHeight, "2", ProofValidationResult::IMMATURE_UTXO},
865 {50, "52", ProofValidationResult::IMMATURE_UTXO},
866 {50, "100", ProofValidationResult::IMMATURE_UTXO},
867 };
868
869 for (const auto &[stakeConfs, configuredStakeConfs, expectedResult] :
870 testCases) {
871 COutPoint outpoint(TxId(m_rng.rand256()), m_rng.rand32());
872 CTxOut output(value, GetScriptForRawPubKey(pubkey));
873 coins.AddCoin(outpoint, Coin(output, stakeConfs, false), false);
874
875 gArgs.ForceSetArg("-avaproofstakeutxoconfirmations",
876 configuredStakeConfs);
877 runCheck(expectedResult, outpoint, value, stakeConfs, false, key);
878 }
879 gArgs.ClearForcedArg("-avaproofstakeutxoconfirmations");
880 }
881}
882
883BOOST_AUTO_TEST_CASE(deterministic_proofid) {
884 auto key = CKey::MakeCompressedKey();
885
886 const Amount value = 12345 * COIN;
887 const uint32_t height = 10;
888
889 std::vector<COutPoint> outpoints(10);
890 for (size_t i = 0; i < 10; i++) {
891 outpoints[i] = COutPoint(TxId(m_rng.rand256()), m_rng.rand32());
892 }
893
894 auto computeProofId = [&]() {
896 for (const COutPoint &outpoint : outpoints) {
897 BOOST_CHECK(pb.addUTXO(outpoint, value, height, false, key));
898 }
899 ProofRef p = pb.build();
900
901 return p->getId();
902 };
903
904 const ProofId proofid = computeProofId();
905 Shuffle(outpoints.begin(), outpoints.end(), FastRandomContext());
906 BOOST_CHECK_EQUAL(proofid, computeProofId());
907}
908
909BOOST_AUTO_TEST_CASE(get_staked_amount) {
910 auto key = CKey::MakeCompressedKey();
912
913 {
914 ProofRef p = pb.build();
916 }
917
918 for (int i = 1; i <= 10; i++) {
919 BOOST_CHECK(pb.addUTXO(COutPoint(TxId(GetRandHash()), 0), i * COIN, 42,
920 false, key));
921 }
922
923 {
924 ProofRef p = pb.build();
926 }
927}
928
929BOOST_AUTO_TEST_CASE(amount_to_score) {
930 BOOST_CHECK_EQUAL(Proof::amountToScore(Amount::zero()), 0);
931 BOOST_CHECK_EQUAL(Proof::amountToScore(-SATOSHI), 0);
932 BOOST_CHECK_EQUAL(Proof::amountToScore(PROOF_DUST_THRESHOLD),
934 BOOST_CHECK_EQUAL(Proof::amountToScore(MAX_MONEY),
935 uint32_t((100 * MAX_MONEY) / COIN));
936 BOOST_CHECK_EQUAL(Proof::amountToScore(MAX_MONEY + SATOSHI),
937 Proof::amountToScore(MAX_MONEY));
938}
939
940BOOST_AUTO_TEST_CASE(stake_amount_overflow) {
941 const CKey key = CKey::MakeCompressedKey();
942 const CPubKey pubkey = key.GetPubKey();
943 const SchnorrSig dummySig{};
944
945 auto makeProof = [&](std::vector<SignedStake> stakes) {
946 return Proof(0, 0, pubkey, std::move(stakes),
948 };
949
950 // Two stakes large enough that their sum overflows int64.
951 const Amount huge = (std::numeric_limits<int64_t>::max() / 2 + 1) * SATOSHI;
952 {
953 Proof proof = makeProof({
955 Stake(COutPoint(TxId(uint256::ONE), 0), huge, 1, false, pubkey),
956 dummySig),
958 Stake(COutPoint(TxId(uint256(2)), 0), huge, 1, false, pubkey),
959 dummySig),
960 });
962 BOOST_CHECK_EQUAL(proof.getScore(), Proof::amountToScore(MAX_MONEY));
963 }
964
965 // Negative stake amounts are clamped to zero.
966 {
967 Proof proof = makeProof({
968 SignedStake(Stake(COutPoint(TxId(uint256::ONE), 0), -COIN, 1, false,
969 pubkey),
970 dummySig),
971 SignedStake(Stake(COutPoint(TxId(uint256(2)), 0), -SATOSHI, 1,
972 false, pubkey),
973 dummySig),
974 });
976 BOOST_CHECK_EQUAL(proof.getScore(), 0);
977 }
978}
979
980BOOST_AUTO_TEST_SUITE_END()
static constexpr Amount SATOSHI
Definition: amount.h:149
static constexpr Amount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition: amount.h:171
static constexpr Amount COIN
Definition: amount.h:150
ArgsManager gArgs
Definition: args.cpp:39
#define Assert(val)
Identity function.
Definition: check.h:87
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: args.cpp:565
void ClearForcedArg(const std::string &strArg)
Remove a forced arg setting, used only in testing.
Definition: args.cpp:616
int64_t GetMedianTimePast() const
Definition: blockindex.h:172
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:358
void AddCoin(const COutPoint &outpoint, Coin coin, bool possible_overwrite)
Add a coin.
Definition: coins.cpp:98
An encapsulated secp256k1 private key.
Definition: key.h:28
static CKey MakeCompressedKey()
Produce a valid compressed key.
Definition: key.cpp:465
CPubKey GetPubKey() const
Compute the public key from a private key.
Definition: key.cpp:209
An encapsulated public key.
Definition: pubkey.h:31
An output of a transaction.
Definition: transaction.h:128
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:721
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:1170
SnapshotCompletionResult MaybeCompleteSnapshotValidation() EXCLUSIVE_LOCKS_REQUIRED(const CBlockIndex *GetSnapshotBaseBlock() const EXCLUSIVE_LOCKS_REQUIRED(Chainstate ActiveChainstate)() const
Once the background validation chainstate has reached the height which is the base of the UTXO snapsh...
Definition: validation.h:1424
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1431
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1428
A UTXO entry.
Definition: coins.h:31
Fast randomness source.
Definition: random.h:411
Result GetResult() const
Definition: validation.h:122
bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, bool is_coinbase, CKey key)
int64_t getExpirationTime() const
Definition: proof.h:161
bool verify(const Amount &stakeUtxoDustThreshold, ProofValidationState &state) const
Definition: proof.cpp:127
Amount getStakedAmount() const
Definition: proof.cpp:108
const CPubKey & getMaster() const
Definition: proof.h:162
uint64_t getSequence() const
Definition: proof.h:160
uint32_t getScore() const
Definition: proof.h:172
const ProofId & getId() const
Definition: proof.h:167
256-bit opaque blob.
Definition: uint256.h:129
static const uint256 ONE
Definition: uint256.h:135
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:7
std::array< uint8_t, CPubKey::SCHNORR_SIZE > SchnorrSig
a Schnorr signature
Definition: key.h:25
@ NONE
Definition: logging.h:68
static constexpr Amount PROOF_DUST_THRESHOLD
Minimum amount per utxo.
Definition: proof.h:38
ProofValidationResult
Definition: validation.h:12
const CScript UNSPENDABLE_ECREG_PAYOUT_SCRIPT
Definition: util.h:22
ProofRef buildRandomProof(Chainstate &active_chainstate, uint32_t score, int height, const CKey &masterKey)
Definition: util.cpp:20
constexpr uint32_t MIN_VALID_PROOF_SCORE
Definition: util.h:20
bool hasDustStake(const ProofRef &proof)
Definition: util.cpp:41
NodeContext & m_node
Definition: interfaces.cpp:820
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
#define BOOST_CHECK(expr)
Definition: object.cpp:17
BOOST_AUTO_TEST_CASE(proof_random)
Definition: proof_tests.cpp:27
void Shuffle(I first, I last, R &&rng)
More efficient than using std::shuffle on a FastRandomContext.
Definition: random.h:512
uint256 GetRandHash() noexcept
========== CONVENIENCE FUNCTIONS FOR COMMONLY USED RANDOMNESS ==========
Definition: random.h:494
@ OP_TRUE
Definition: script.h:61
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
Definition: standard.cpp:244
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:240
Definition: amount.h:22
static constexpr Amount zero() noexcept
Definition: amount.h:35
std::string name
std::string hex
ProofId proofid
Definition: proof_tests.cpp:82
ProofValidationResult result
Definition: proof_tests.cpp:84
uint32_t score
Definition: proof_tests.cpp:83
A TxId is the identifier of a transaction.
Definition: txid.h:14
Bilingual messages:
Definition: translation.h:17
#define LOCK(cs)
Definition: sync.h:306