1 /******************************************************************************
2 * Copyright © 2014-2018 The SuperNET Developers. *
4 * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
5 * the top-level directory of this distribution for the individual copyright *
6 * holder information and the developer policies on copyright and licensing. *
8 * Unless otherwise agreed in a custom licensing agreement, no part of the *
9 * SuperNET software, including this file may be copied, modified, propagated *
10 * or distributed except according to the terms contained in the LICENSE file *
12 * Removal or modification of this copyright notice is prohibited. *
14 ******************************************************************************/
18 #include "CCinclude.h"
21 #include "CCrewards.h"
23 #include "CCauction.h"
27 #include "CCchannels.h"
28 #include "CCOracles.h"
31 #include "CCTriggers.h"
32 #include "CCPayments.h"
33 #include "CCGateways.h"
34 #include "StakeGuard.h"
35 #include "pbaas/crosschainrpc.h"
36 #include "pbaas/pbaas.h"
37 #include "pbaas/notarization.h"
38 #include "pbaas/identity.h"
41 CCcustom has most of the functions that need to be extended to create a new CC contract.
43 A CC scriptPubKey can only be spent if it is properly signed and validated. By constraining the vins and vouts, it is possible to implement a variety of functionality. CC vouts have an otherwise non-standard form, but it is properly supported by the enhanced bitcoin protocol code as a "cryptoconditions" output and the same pubkey will create a different address.
45 This allows creation of a special address(es) for each contract type, which has the privkey public. That allows anybody to properly sign and spend it, but with the constraints on what is allowed in the validation code, the contract functionality can be implemented.
47 what needs to be done to add a new contract:
48 1. add EVAL_CODE to eval.h
49 2. initialize the variables in the CCinit function below
50 3. write a Validate function to reject any unsanctioned usage of vin/vout
51 4. make helper functions to create rawtx for RPC functions
52 5. add rpc calls to rpcserver.cpp and rpcserver.h and in one of the rpc.cpp files
53 6. add the new .cpp files to src/Makefile.am
55 IMPORTANT: make sure that all CC inputs and CC outputs are properly accounted for and reconcile to the satoshi. The built in utxo management will enforce overall vin/vout constraints but it wont know anything about the CC constraints. That is what your Validate function needs to do.
57 Generally speaking, there will be normal coins that change into CC outputs, CC outputs that go back to being normal coins, CC outputs that are spent to new CC outputs.
59 Make sure both the CC coins and normal coins are preserved and follow the rules that make sense. It is a good idea to define specific roles for specific vins and vouts to reduce the complexity of validation.
62 // to create a new CCaddr, add to rpcwallet the CCaddress and start with -pubkey= with the pubkey of the new address, with its wif already imported. set normaladdr and CChexstr. run CCaddress and it will print the privkey along with autocorrect the CCaddress. which should then update the CCaddr here
64 // StakeGuard - nothing at stake
65 std::string StakeGuardAddr = "RCG8KwJNDVwpUBcdoa6AoHqHVJsA1uMYMR";
66 std::string StakeGuardPubKey = "03166b7813a4855a88e9ef7340a692ef3c2decedfdc2c7563ec79537e89667d935";
67 std::string StakeGuardWIF = "Uw7vRYHGKjyi1FaJ8Lv1USSuj7ntUti8fAhSDiCdbzuV6yDagaTn";
69 // defines the blockchain parameters of a PBaaS blockchain
70 std::string PBaaSDefinitionAddr = "RP7id3CzCnwvzNUZesYJM6ekvsxpEzMqB1";
71 std::string PBaaSDefinitionPubKey = "02a0de91740d3d5a3a4a7990ae22315133d02f33716b339ebce88662d012224ef5";
72 std::string PBaaSDefinitionWIF = "UwhNWARAQTUvYUEqxGbRjM2BFUneGnFzmaMMiSqJQZFQZTku6xTW";
74 // Notary evidence output type
75 std::string NotaryEvidenceAddr = "RQWMeecjGFF3ZAVeSimRbyG9iMDUHPY5Ny";
76 std::string NotaryEvidencePubKey = "03e1894e9d487125be5a8c6657a8ce01bc81ba7816d698dbfcfb0483754eb5a2d9";
77 std::string NotaryEvidenceWIF = "Uw5dNvvgz7eyUJGtfi696hYbF9YPXHPHasgZFeQeDu8j4SapPBzd";
79 // Earned notarization type, created by miners and/or stakers
80 std::string EarnedNotarizationAddr = "RMYbaxFsCT1xfMmwLCCYAVf2DsxcDTtBmx";
81 std::string EarnedNotarizationPubKey = "03fb008879b37d644bef929576dda7f5ee31b352c76fc112b4a89838d5b61f52e2";
82 std::string EarnedNotarizationWIF = "UtzhFWXw24xS2Tf3gCDm9p2Ex7TUnCNt4DFA7r2f5cCKPhPknEqD";
84 // Accepted notarizations are validated notarizations and proofs of an alternate earned notarization -- these are for the Verus chain
85 std::string AcceptedNotarizationAddr = "RDTq9qn1Lthv7fvsdbWz36mGp8HK9XaruZ";
86 std::string AcceptedNotarizationPubKey = "02d85f078815b7a52faa92639c3691d2a640e26c4e06de54dd1490f0e93bcc11c3";
87 std::string AcceptedNotarizationWIF = "UtgbVEYs2PShTMffbkYh8bgo9DYsXr8JuqWVjAYHRt2ebGPeP5Mf";
89 // "Finalization" - output that can be spent when a notarization is effectively considered "final"
90 std::string FinalizeNotarizationAddr = "RRbKYitLH9EhQCvCo4bPZqJx3TWxASadxE";
91 std::string FinalizeNotarizationPubKey = "02e3154f8122ff442fbca3ff8ff4d4fb2d9285fd9f4d841d58fb8d6b7acefed60f";
92 std::string FinalizeNotarizationWIF = "UrN1b1hCQc6cUpcUdQD7DFTn2PJneDpKv5pmURPQzJ2zVp9UVM6E";
94 // Reserve output -- provides flexible Verus reserve currency transaction/utxo support on PBaaS chains only
95 std::string ReserveOutputAddr = "RMXeZGxxRuABFkT4uLSCeuJHLegBNGZq8D";
96 std::string ReserveOutputPubKey = "02d3e0f4c308c6e9786a5280ec96ea6d0e07505bae88d28b4b3156c309e2ae5515";
97 std::string ReserveOutputWIF = "UrCfRxuFKPg3b3HtPFhvL9X8iePfETRZpgymrxzdDZ3vpjSwHrxH";
99 // Reserve exchange -- convert from a fractional reserve into its underlying currency, PBaaS reserve chains only
100 std::string ReserveExchangeAddr = "REuGNkgunnw1J4Zx6Y9UCp8YHVZqYATe9D";
101 std::string ReserveExchangePubKey = "02b68492c495d7d63d908fa641fb6215bc56a7de15fb438c78066ec4c173563527";
102 std::string ReserveExchangeWIF = "Uveq2qCQLjaJxdjXBAtBQQjhRDocomeSCtogifMHxwVsLNRCQgqX";
104 // Reserve transfer -- send reserves from a Verus chain to a PBaaS chain or back with optional conversion, works on Verus or PBaaS chains
105 std::string ReserveTransferAddr = "RTqQe58LSj2yr5CrwYFwcsAQ1edQwmrkUU";
106 std::string ReserveTransferPubKey = "0367add5577ca8f5f680ee0adf4cf802584c56ed14956efedd3e18656874614548";
107 std::string ReserveTransferWIF = "UtbtjjXtNtYroASwDrW63pEK7Fv3ehBRGDc2GRkPPr292DkRTmtB";
109 // Reserve deposit -- these outputs are spent into the cross chain import thread on the Verus chain when import transactions are created
110 std::string ReserveDepositAddr = "RFw9AVfgNKcHe2Vp2eyzHrX65aFD9Ky8df";
111 std::string ReserveDepositPubKey = "03b99d7cb946c5b1f8a54cde49b8d7e0a2a15a22639feb798009f82b519526c050";
112 std::string ReserveDepositWIF = "UtGtjeGBCUtQPGZp99bnDvQuxvURxdjGRFHuJ7oQyQgpNNCEyyqu";
114 // Cross chain export -- this is used on an aggregated cross chain export transaction and one unspent output defines the export thread
115 std::string CrossChainExportAddr = "RGkrs7SndcpsV61oKK2jYdMiU8PgkLU2qP";
116 std::string CrossChainExportPubKey = "02cbfe54fb371cfc89d35b46cafcad6ac3b7dc9b40546b0f30b2b29a4865ed3b4a";
117 std::string CrossChainExportWIF = "Uu9P8fa68e2ECar76z4MsSoKtbRV1Dny3WD6DTmMKmeimooeAyAz";
119 // Cross chain import -- this is used on a cross chain import transaction and one unspent output defines the import thread
120 std::string CrossChainImportAddr = "RKLN7wFhbrJFkPG8XkKteErAe5CjqoddTm";
121 std::string CrossChainImportPubKey = "038d259ec6175e192f8417914293dd09203885bc33039080f2a33f08a3fdddc818";
122 std::string CrossChainImportWIF = "UtAEFiEERMkuZ3cCzbi8DqXRM6fHNAuYcbXU2hy2dc14LgPpkxax";
124 // Currency state - coinbase output -- currently required on PBaaS chains only
125 std::string CurrencyStateAddr = "REU1HKkmdwdxKMpfD3QoxeERYd9tfMN6n9";
126 std::string CurrencyStatePubKey = "0219af977f9a6c3779f1185decee2b77da446040055b912b00e115a52d4786059c";
127 std::string CurrencyStateWIF = "Ur8YQJQ6guqmD6rXtrUtJ7fWxaEB5FaejCr3MxHAgMEwnjJnuGo5";
129 // identity primary output
130 std::string IdentityPrimaryAddr = "RS545EBdK5AzPTaGHNUg78wFuuAzBb74FB";
131 std::string IdentityPrimaryPubKey = "030b2c39fb8357ca54a56ca3b07a74a6b162addb4d31afaefc9c53bfc17aae052c";
132 std::string IdentityPrimaryWIF = "UtPq2QgtE9qcukeMA5grsHhr7eDzLo9BVwoN4QQRiv3coZn2ryXF";
134 // identity revoke output
135 std::string IdentityRevokeAddr = "RG6My2zwh9hBFSgUhZ5UmmUtxBap57aU4N";
136 std::string IdentityRevokePubKey = "03098d3fee3585ff42090c9cee5723a718dd27e7854761db4520eb70ade22a7802";
137 std::string IdentityRevokeWIF = "UuLt6xUQqG74M4Rgm96xEb672DjfkHYEukdUHWfAMBE4Tsc8cBvC";
139 // identity recover output
140 std::string IdentityRecoverAddr = "RRw9rJMPwdNqC1wgXn5vryJwMDyBgpXjYT";
141 std::string IdentityRecoverPubKey = "03a058410b33f893fe182f15336577f3941c28c8cadcfb0395b9c31dd5c07ccd11";
142 std::string IdentityRecoverWIF = "UuGtno91gaoJgy7nRgaBkWj6So3oBZ24fJWzULfU6LrsN4XZJckC";
144 // identity commitment output
145 std::string IdentityCommitmentAddr = "RCySaThHfVBcHZgjJGoBw3un4vcsRJNPYw";
146 std::string IdentityCommitmentPubKey = "03c4eac0982458644a87458eebe2fdc4e754e15c378b66f16fbd913ae2792d2cb0";
147 std::string IdentityCommitmentWIF = "Upfbmz3v16NM3zmQujmLSuaWeJ519fUKMqjusFwSDKgpBGMckWCr";
149 // identity reservation output
150 std::string IdentityReservationAddr = "RDbzJU8rEv4CkMABNUnKQoKDTfnikSm9fM";
151 std::string IdentityReservationPubKey = "03974e76f57409197870d4e5539380b2f8468465c2bd374e3610edf1282cd1a304";
152 std::string IdentityReservationWIF = "UqCXEj8oonBt6p9iDXbsAshCeFX7RsDpL6R62GUhTVRiSKDCQkYi";
155 std::string FinalizeExportAddr = "REL7oLNeaeoQB1XauiHfcvjKMZC52Uj5xF";
156 std::string FinalizeExportPubKey = "0391fa230bd2509cbcc165c636c79ff540a8e3615993b16b8e366770bc4261bf10";
157 std::string FinalizeExportWIF = "UrRwoqyLMNddbASS7XV6rm3Q1JCBmMV9V5oPr92KEFmH5U8Evkf6";
159 // quantum resistant public key output to keep one copy of a public key and refer to it via its hash on the chain
160 std::string QuantumKeyOutAddr = "";
161 std::string QuantumKeyOutPubKey = "";
162 std::string QuantumKeyOutWIF = "";
164 // blockchain fee pool output
165 std::string FeePoolAddr = "RQ55dLQ7uGnLx8scXfkaFV6QS6qVBGyxAG";
166 std::string FeePoolPubKey = "0231dbadc511bcafdb557faf0b49bea1e2a4ccc0259aeae16c618e1cc4d38f2f4d";
167 std::string FeePoolWIF = "Ux4w6K5ptuQG4SUEQd1bRV8X1LwzcLrVirApbXvThKYfm6uXEafJ";
169 // atomic swap condition
170 std::string AtomicSwapConditionAddr = "";
171 std::string AtomicSwapConditionPubKey = "";
172 std::string AtomicSwapConditionWIF = "";
174 // condition to put time limits on a transaction output
175 std::string TimeLimitsAddr = "";
176 std::string TimeLimitsPubKey = "";
177 std::string TimeLimitsWIF = "";
179 // Assets, aka Tokens
180 #define FUNCNAME IsAssetsInput
181 #define EVALCODE EVAL_ASSETS
182 const char *AssetsCCaddr = "RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6";
183 const char *AssetsNormaladdr = "RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u";
184 char AssetsCChexstr[67] = { "02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702" };
185 uint8_t AssetsCCpriv[32] = { 0x9b, 0x17, 0x66, 0xe5, 0x82, 0x66, 0xac, 0xb6, 0xba, 0x43, 0x83, 0x74, 0xf7, 0x63, 0x11, 0x3b, 0xf0, 0xf3, 0x50, 0x6f, 0xd9, 0x6b, 0x67, 0x85, 0xf9, 0x7a, 0xf0, 0x54, 0x4d, 0xb1, 0x30, 0x77 };
187 #include "CCcustom.inc"
192 #define FUNCNAME IsFaucetInput
193 #define EVALCODE EVAL_FAUCET
194 const char *FaucetCCaddr = "R9zHrofhRbub7ER77B7NrVch3A63R39GuC";
195 const char *FaucetNormaladdr = "RKQV4oYs4rvxAWx1J43VnT73rSTVtUeckk";
196 char FaucetCChexstr[67] = { "03682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe12" };
197 uint8_t FaucetCCpriv[32] = { 0xd4, 0x4f, 0xf2, 0x31, 0x71, 0x7d, 0x28, 0x02, 0x4b, 0xc7, 0xdd, 0x71, 0xa0, 0x39, 0xc4, 0xbe, 0x1a, 0xfe, 0xeb, 0xc2, 0x46, 0xda, 0x76, 0xf8, 0x07, 0x53, 0x3d, 0x96, 0xb4, 0xca, 0xa0, 0xe9 };
199 #include "CCcustom.inc"
204 #define FUNCNAME IsRewardsInput
205 #define EVALCODE EVAL_REWARDS
206 const char *RewardsCCaddr = "RTsRBYL1HSvMoE3qtBJkyiswdVaWkm8YTK";
207 const char *RewardsNormaladdr = "RMgye9jeczNjQx9Uzq8no8pTLiCSwuHwkz";
208 char RewardsCChexstr[67] = { "03da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb9" };
209 uint8_t RewardsCCpriv[32] = { 0x82, 0xf5, 0xd2, 0xe7, 0xd6, 0x99, 0x33, 0x77, 0xfb, 0x80, 0x00, 0x97, 0x23, 0x3d, 0x1e, 0x6f, 0x61, 0xa9, 0xb5, 0x2e, 0x5e, 0xb4, 0x96, 0x6f, 0xbc, 0xed, 0x6b, 0xe2, 0xbb, 0x7b, 0x4b, 0xb3 };
210 #include "CCcustom.inc"
215 #define FUNCNAME IsDiceInput
216 #define EVALCODE EVAL_DICE
217 const char *DiceCCaddr = "REabWB7KjFN5C3LFMZ5odExHPenYzHLtVw";
218 const char *DiceNormaladdr = "RLEe8f7Eg3TDuXii9BmNiiiaVGraHUt25c";
219 char DiceCChexstr[67] = { "039d966927cfdadab3ee6c56da63c21f17ea753dde4b3dfd41487103e24b27e94e" };
220 uint8_t DiceCCpriv[32] = { 0x0e, 0xe8, 0xf5, 0xb4, 0x3d, 0x25, 0xcc, 0x35, 0xd1, 0xf1, 0x2f, 0x04, 0x5f, 0x01, 0x26, 0xb8, 0xd1, 0xac, 0x3a, 0x5a, 0xea, 0xe0, 0x25, 0xa2, 0x8f, 0x2a, 0x8e, 0x0e, 0xf9, 0x34, 0xfa, 0x77 };
221 #include "CCcustom.inc"
226 #define FUNCNAME IsLottoInput
227 #define EVALCODE EVAL_LOTTO
228 const char *LottoCCaddr = "RNXZxgyWSAE6XS3qGnTaf5dVNCxnYzhPrg";
229 const char *LottoNormaladdr = "RLW6hhRqBZZMBndnyPv29Yg3krh6iBYCyg";
230 char LottoCChexstr[67] = { "03f72d2c4db440df1e706502b09ca5fec73ffe954ea1883e4049e98da68690d98f" };
231 uint8_t LottoCCpriv[32] = { 0xb4, 0xac, 0xc2, 0xd9, 0x67, 0x34, 0xd7, 0x58, 0x80, 0x4e, 0x25, 0x55, 0xc0, 0x50, 0x66, 0x84, 0xbb, 0xa2, 0xe7, 0xc0, 0x39, 0x17, 0xb4, 0xc5, 0x07, 0xb7, 0x3f, 0xca, 0x07, 0xb0, 0x9a, 0xeb };
232 #include "CCcustom.inc"
236 // Finite State Machine
237 #define FUNCNAME IsFSMInput
238 #define EVALCODE EVAL_FSM
239 const char *FSMCCaddr = "RUKTbLBeKgHkm3Ss4hKZP3ikuLW1xx7B2x";
240 const char *FSMNormaladdr = "RWSHRbxnJYLvDjpcQ2i8MekgP6h2ctTKaj";
241 char FSMCChexstr[67] = { "039b52d294b413b07f3643c1a28c5467901a76562d8b39a785910ae0a0f3043810" };
242 uint8_t FSMCCpriv[32] = { 0x11, 0xe1, 0xea, 0x3e, 0xdb, 0x36, 0xf0, 0xa8, 0xc6, 0x34, 0xe1, 0x21, 0xb8, 0x02, 0xb9, 0x4b, 0x12, 0x37, 0x8f, 0xa0, 0x86, 0x23, 0x50, 0xb2, 0x5f, 0xe4, 0xe7, 0x36, 0x0f, 0xda, 0xae, 0xfc };
243 #include "CCcustom.inc"
248 #define FUNCNAME IsAuctionInput
249 #define EVALCODE EVAL_AUCTION
250 const char *AuctionCCaddr = "RL4YPX7JYG3FnvoPqWF2pn3nQknH5NWEwx";
251 const char *AuctionNormaladdr = "RFtVDNmdTZBTNZdmFRbfBgJ6LitgTghikL";
252 char AuctionCChexstr[67] = { "037eefe050c14cb60ae65d5b2f69eaa1c9006826d729bc0957bdc3024e3ca1dbe6" };
253 uint8_t AuctionCCpriv[32] = { 0x8c, 0x1b, 0xb7, 0x8c, 0x02, 0xa3, 0x9d, 0x21, 0x28, 0x59, 0xf5, 0xea, 0xda, 0xec, 0x0d, 0x11, 0xcd, 0x38, 0x47, 0xac, 0x0b, 0x6f, 0x19, 0xc0, 0x24, 0x36, 0xbf, 0x1c, 0x0a, 0x06, 0x31, 0xfb };
254 #include "CCcustom.inc"
259 #define FUNCNAME IsMofNInput
260 #define EVALCODE EVAL_MOFN
261 const char *MofNCCaddr = "RDVHcSekmXgeYBqRupNTmqo3Rn8QRXNduy";
262 const char *MofNNormaladdr = "RTPwUjKYECcGn6Y4KYChLhgaht1RSU4jwf";
263 char MofNCChexstr[67] = { "03c91bef3d7cc59c3a89286833a3446b29e52a5e773f738a1ad2b09785e5f4179e" };
264 uint8_t MofNCCpriv[32] = { 0x9d, 0xa1, 0xf8, 0xf7, 0xba, 0x0a, 0x91, 0x36, 0x89, 0x9a, 0x86, 0x30, 0x63, 0x20, 0xd7, 0xdf, 0xaa, 0x35, 0xe3, 0x99, 0x32, 0x2b, 0x63, 0xc0, 0x66, 0x9c, 0x93, 0xc4, 0x5e, 0x9d, 0xb9, 0xce };
265 #include "CCcustom.inc"
270 #define FUNCNAME IsChannelsInput
271 #define EVALCODE EVAL_CHANNELS
272 const char *ChannelsCCaddr = "RQy3rwX8sP9oDm3c39vGKA6H315cgtPLfr";
273 const char *ChannelsNormaladdr = "RQUuT8zmkvDfXqECH4m3VD3SsHZAfnoh1v";
274 char ChannelsCChexstr[67] = { "035debdb19b1c98c615259339500511d6216a3ffbeb28ff5655a7ef5790a12ab0b" };
275 uint8_t ChannelsCCpriv[32] = { 0xec, 0x91, 0x36, 0x15, 0x2d, 0xd4, 0x48, 0x73, 0x22, 0x36, 0x4f, 0x6a, 0x34, 0x5c, 0x61, 0x0f, 0x01, 0xb4, 0x79, 0xe8, 0x1c, 0x2f, 0xa1, 0x1d, 0x4a, 0x0a, 0x21, 0x16, 0xea, 0x82, 0x84, 0x60 };
276 #include "CCcustom.inc"
281 #define FUNCNAME IsOraclesInput
282 #define EVALCODE EVAL_ORACLES
283 const char *OraclesCCaddr = "REt2C4ZMnX8YYX1DRpffNA4hECZTFm39e3";
284 const char *OraclesNormaladdr = "RHkFKzn1csxA3fWzAsxsLWohoCgBbirXb5";
285 char OraclesCChexstr[67] = { "038c1d42db6a45a57eccb8981b078fb7857b9b496293fe299d2b8d120ac5b5691a" };
286 uint8_t OraclesCCpriv[32] = { 0xf7, 0x4b, 0x5b, 0xa2, 0x7a, 0x5e, 0x9c, 0xda, 0x89, 0xb1, 0xcb, 0xb9, 0xe6, 0x9c, 0x2c, 0x70, 0x85, 0x37, 0xdd, 0x00, 0x7a, 0x67, 0xff, 0x7c, 0x62, 0x1b, 0xe2, 0xfb, 0x04, 0x8f, 0x85, 0xbf };
287 #include "CCcustom.inc"
292 #define FUNCNAME IsPricesInput
293 #define EVALCODE EVAL_PRICES
294 const char *PricesCCaddr = "RAL5Vh8NXmFqEKJRKrk1KjKaUckK7mM1iS";
295 const char *PricesNormaladdr = "RBunXCsMHk5NPd6q8SQfmpgre3x133rSwZ";
296 char PricesCChexstr[67] = { "039894cb054c0032e99e65e715b03799607aa91212a16648d391b6fa2cc52ed0cf" };
297 uint8_t PricesCCpriv[32] = { 0x0a, 0x3b, 0xe7, 0x5d, 0xce, 0x06, 0xed, 0xb7, 0xc0, 0xb1, 0xbe, 0xe8, 0x7b, 0x5a, 0xd4, 0x99, 0xb8, 0x8d, 0xde, 0xac, 0xb2, 0x7e, 0x7a, 0x52, 0x96, 0x15, 0xd2, 0xa0, 0xc6, 0xb9, 0x89, 0x61 };
298 #include "CCcustom.inc"
303 #define FUNCNAME IsPegsInput
304 #define EVALCODE EVAL_PEGS
305 const char *PegsCCaddr = "RHnkVb7vHuHnjEjhkCF1bS6xxLLNZPv5fd";
306 const char *PegsNormaladdr = "RMcCZtX6dHf1fz3gpLQhUEMQ8cVZ6Rzaro";
307 char PegsCChexstr[67] = { "03c75c1de29a35e41606363b430c08be1c2dd93cf7a468229a082cc79c7b77eece" };
308 uint8_t PegsCCpriv[32] = { 0x52, 0x56, 0x4c, 0x78, 0x87, 0xf7, 0xa2, 0x39, 0xb0, 0x90, 0xb7, 0xb8, 0x62, 0x80, 0x0f, 0x83, 0x18, 0x9d, 0xf4, 0xf4, 0xbd, 0x28, 0x09, 0xa9, 0x9b, 0x85, 0x54, 0x16, 0x0f, 0x3f, 0xfb, 0x65 };
309 #include "CCcustom.inc"
314 #define FUNCNAME IsTriggersInput
315 #define EVALCODE EVAL_TRIGGERS
316 const char *TriggersCCaddr = "RGLSRDnUqTB43bYtRtNVgmwSSd1sun2te8";
317 const char *TriggersNormaladdr = "RMN25Tn8NNzcyQDiQNuMp8UmwLMFd9thYc";
318 char TriggersCChexstr[67] = { "03afc5be570d0ff419425cfcc580cc762ab82baad88c148f5b028d7db7bfeee61d" };
319 uint8_t TriggersCCpriv[32] = { 0x7c, 0x0b, 0x54, 0x9b, 0x65, 0xd4, 0x89, 0x57, 0xdf, 0x05, 0xfe, 0xa2, 0x62, 0x41, 0xa9, 0x09, 0x0f, 0x2a, 0x6b, 0x11, 0x2c, 0xbe, 0xbd, 0x06, 0x31, 0x8d, 0xc0, 0xb9, 0x96, 0x76, 0x3f, 0x24 };
320 #include "CCcustom.inc"
325 #define FUNCNAME IsPaymentsInput
326 #define EVALCODE EVAL_PAYMENTS
327 const char *PaymentsCCaddr = "REpyKi7avsVduqZ3eimncK4uKqSArLTGGK";
328 const char *PaymentsNormaladdr = "RHRX8RTMAh2STWe9DHqsvJbzS7ty6aZy3d";
329 char PaymentsCChexstr[67] = { "0358f1764f82c63abc7c7455555fd1d3184905e30e819e97667e247e5792b46856" };
330 uint8_t PaymentsCCpriv[32] = { 0x03, 0xc9, 0x73, 0xc2, 0xb8, 0x30, 0x3d, 0xbd, 0xc8, 0xd9, 0xbf, 0x02, 0x49, 0xd9, 0x65, 0x61, 0x45, 0xed, 0x9e, 0x93, 0x51, 0xab, 0x8b, 0x2e, 0xe7, 0xc7, 0x40, 0xf1, 0xc4, 0xd2, 0xc0, 0x5b };
331 #include "CCcustom.inc"
336 #define FUNCNAME IsGatewaysInput
337 #define EVALCODE EVAL_GATEWAYS
338 const char *GatewaysCCaddr = "RKWpoK6vTRtq5b9qrRBodLkCzeURHeEk33";
339 const char *GatewaysNormaladdr = "RGJKV97ZN1wBfunuMt1tebiiHENNEq73Yh";
340 char GatewaysCChexstr[67] = { "03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40" };
341 uint8_t GatewaysCCpriv[32] = { 0xf7, 0x4b, 0x5b, 0xa2, 0x7a, 0x5e, 0x9c, 0xda, 0x89, 0xb1, 0xcb, 0xb9, 0xe6, 0x9c, 0x2c, 0x70, 0x85, 0x37, 0xdd, 0x00, 0x7a, 0x67, 0xff, 0x7c, 0x62, 0x1b, 0xe2, 0xfb, 0x04, 0x8f, 0x85, 0xbf };
342 #include "CCcustom.inc"
346 struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode)
348 cp->evalcode = evalcode;
351 case EVAL_STAKEGUARD:
352 strcpy(cp->unspendableCCaddr,StakeGuardAddr.c_str());
353 strcpy(cp->normaladdr,StakeGuardAddr.c_str());
354 strcpy(cp->CChexstr,StakeGuardPubKey.c_str());
355 memcpy(cp->CCpriv,DecodeSecret(StakeGuardWIF).begin(),32);
356 cp->validate = StakeGuardValidate;
357 cp->ismyvin = IsStakeGuardInput; // TODO: these input functions are not useful for new CCs
358 cp->contextualprecheck = PrecheckStakeGuardOutput;
361 case EVAL_CURRENCY_DEFINITION:
362 strcpy(cp->unspendableCCaddr,PBaaSDefinitionAddr.c_str());
363 strcpy(cp->normaladdr,PBaaSDefinitionAddr.c_str());
364 strcpy(cp->CChexstr,PBaaSDefinitionPubKey.c_str());
365 memcpy(cp->CCpriv,DecodeSecret(PBaaSDefinitionWIF).begin(),32);
366 cp->validate = ValidateChainDefinition;
367 cp->ismyvin = IsChainDefinitionInput;
368 cp->contextualprecheck = DefaultCCContextualPreCheck;
371 case EVAL_EARNEDNOTARIZATION:
372 strcpy(cp->unspendableCCaddr,EarnedNotarizationAddr.c_str());
373 strcpy(cp->normaladdr,EarnedNotarizationAddr.c_str());
374 strcpy(cp->CChexstr,EarnedNotarizationPubKey.c_str());
375 memcpy(cp->CCpriv,DecodeSecret(EarnedNotarizationWIF).begin(),32);
376 cp->validate = ValidateEarnedNotarization;
377 cp->ismyvin = IsEarnedNotarizationInput;
378 cp->contextualprecheck = DefaultCCContextualPreCheck;
381 case EVAL_ACCEPTEDNOTARIZATION:
382 strcpy(cp->unspendableCCaddr,AcceptedNotarizationAddr.c_str());
383 strcpy(cp->normaladdr,AcceptedNotarizationAddr.c_str());
384 strcpy(cp->CChexstr,AcceptedNotarizationPubKey.c_str());
385 memcpy(cp->CCpriv,DecodeSecret(AcceptedNotarizationWIF).begin(),32);
386 cp->validate = ValidateAcceptedNotarization;
387 cp->ismyvin = IsAcceptedNotarizationInput;
388 cp->contextualprecheck = DefaultCCContextualPreCheck;
391 case EVAL_FINALIZE_NOTARIZATION:
392 strcpy(cp->unspendableCCaddr,FinalizeNotarizationAddr.c_str());
393 strcpy(cp->normaladdr,FinalizeNotarizationAddr.c_str());
394 strcpy(cp->CChexstr,FinalizeNotarizationPubKey.c_str());
395 memcpy(cp->CCpriv,DecodeSecret(FinalizeNotarizationWIF).begin(),32);
396 cp->validate = ValidateFinalizeNotarization;
397 cp->ismyvin = IsFinalizeNotarizationInput;
398 cp->contextualprecheck = DefaultCCContextualPreCheck;
401 case EVAL_NOTARY_EVIDENCE:
402 strcpy(cp->unspendableCCaddr,NotaryEvidenceAddr.c_str());
403 strcpy(cp->normaladdr,NotaryEvidenceAddr.c_str());
404 strcpy(cp->CChexstr,NotaryEvidencePubKey.c_str());
405 memcpy(cp->CCpriv,DecodeSecret(NotaryEvidenceWIF).begin(),32);
406 cp->validate = ValidateNotaryEvidence;
407 cp->ismyvin = IsNotaryEvidenceInput;
408 cp->contextualprecheck = DefaultCCContextualPreCheck;
411 case EVAL_RESERVE_OUTPUT:
412 strcpy(cp->unspendableCCaddr, ReserveOutputAddr.c_str());
413 strcpy(cp->normaladdr, ReserveOutputAddr.c_str());
414 strcpy(cp->CChexstr, ReserveOutputPubKey.c_str());
415 memcpy(cp->CCpriv,DecodeSecret(ReserveOutputWIF).begin(),32);
416 cp->validate = ValidateReserveOutput;
417 cp->ismyvin = IsReserveOutputInput;
418 cp->contextualprecheck = DefaultCCContextualPreCheck;
421 case EVAL_RESERVE_EXCHANGE:
422 strcpy(cp->unspendableCCaddr, ReserveExchangeAddr.c_str());
423 strcpy(cp->normaladdr, ReserveExchangeAddr.c_str());
424 strcpy(cp->CChexstr, ReserveExchangePubKey.c_str());
425 memcpy(cp->CCpriv,DecodeSecret(ReserveExchangeWIF).begin(),32);
426 cp->validate = ValidateReserveExchange;
427 cp->ismyvin = IsReserveExchangeInput;
428 cp->contextualprecheck = DefaultCCContextualPreCheck;
431 case EVAL_RESERVE_TRANSFER:
432 strcpy(cp->unspendableCCaddr, ReserveTransferAddr.c_str());
433 strcpy(cp->normaladdr, ReserveTransferAddr.c_str());
434 strcpy(cp->CChexstr, ReserveTransferPubKey.c_str());
435 memcpy(cp->CCpriv,DecodeSecret(ReserveTransferWIF).begin(),32);
436 cp->validate = ValidateReserveTransfer;
437 cp->ismyvin = IsReserveTransferInput;
438 cp->contextualprecheck = PrecheckReserveTransfer;
441 case EVAL_RESERVE_DEPOSIT:
442 strcpy(cp->unspendableCCaddr, ReserveDepositAddr.c_str());
443 strcpy(cp->normaladdr, ReserveDepositAddr.c_str());
444 strcpy(cp->CChexstr, ReserveDepositPubKey.c_str());
445 memcpy(cp->CCpriv,DecodeSecret(ReserveDepositWIF).begin(),32);
446 cp->validate = ValidateReserveDeposit;
447 cp->ismyvin = IsReserveDepositInput;
448 cp->contextualprecheck = DefaultCCContextualPreCheck;
451 case EVAL_CROSSCHAIN_IMPORT:
452 strcpy(cp->unspendableCCaddr, CrossChainImportAddr.c_str());
453 strcpy(cp->normaladdr, CrossChainImportAddr.c_str());
454 strcpy(cp->CChexstr, CrossChainImportPubKey.c_str());
455 memcpy(cp->CCpriv,DecodeSecret(CrossChainImportWIF).begin(),32);
456 cp->validate = ValidateCrossChainImport;
457 cp->ismyvin = IsCrossChainImportInput;
458 cp->contextualprecheck = DefaultCCContextualPreCheck;
461 case EVAL_CROSSCHAIN_EXPORT:
462 strcpy(cp->unspendableCCaddr, CrossChainExportAddr.c_str());
463 strcpy(cp->normaladdr, CrossChainExportAddr.c_str());
464 strcpy(cp->CChexstr, CrossChainExportPubKey.c_str());
465 memcpy(cp->CCpriv,DecodeSecret(CrossChainExportWIF).begin(),32);
466 cp->validate = ValidateCrossChainExport;
467 cp->ismyvin = IsCrossChainExportInput;
468 cp->contextualprecheck = DefaultCCContextualPreCheck;
471 case EVAL_CURRENCYSTATE:
472 strcpy(cp->unspendableCCaddr,CurrencyStateAddr.c_str());
473 strcpy(cp->normaladdr,CurrencyStateAddr.c_str());
474 strcpy(cp->CChexstr, CurrencyStatePubKey.c_str());
475 memcpy(cp->CCpriv,DecodeSecret(CurrencyStateWIF).begin(),32);
476 cp->validate = ValidateCurrencyState;
477 cp->ismyvin = IsCurrencyStateInput;
478 cp->contextualprecheck = DefaultCCContextualPreCheck;
481 case EVAL_IDENTITY_PRIMARY:
482 strcpy(cp->unspendableCCaddr, IdentityPrimaryAddr.c_str());
483 strcpy(cp->normaladdr, IdentityPrimaryAddr.c_str());
484 strcpy(cp->CChexstr, IdentityPrimaryPubKey.c_str());
485 memcpy(cp->CCpriv, DecodeSecret(IdentityPrimaryWIF).begin(),32);
486 cp->validate = ValidateIdentityPrimary;
487 cp->ismyvin = IsIdentityInput;
488 cp->contextualprecheck = &PrecheckIdentityPrimary;
491 case EVAL_IDENTITY_REVOKE:
492 strcpy(cp->unspendableCCaddr, IdentityRevokeAddr.c_str());
493 strcpy(cp->normaladdr, IdentityRevokeAddr.c_str());
494 strcpy(cp->CChexstr, IdentityRevokePubKey.c_str());
495 memcpy(cp->CCpriv, DecodeSecret(IdentityRevokeWIF).begin(),32);
496 cp->validate = ValidateIdentityRevoke;
497 cp->ismyvin = IsIdentityInput;
498 cp->contextualprecheck = DefaultCCContextualPreCheck;
501 case EVAL_IDENTITY_RECOVER:
502 strcpy(cp->unspendableCCaddr, IdentityRecoverAddr.c_str());
503 strcpy(cp->normaladdr, IdentityRecoverAddr.c_str());
504 strcpy(cp->CChexstr, IdentityRecoverPubKey.c_str());
505 memcpy(cp->CCpriv, DecodeSecret(IdentityRecoverWIF).begin(),32);
506 cp->validate = ValidateIdentityRecover;
507 cp->ismyvin = IsIdentityInput;
508 cp->contextualprecheck = DefaultCCContextualPreCheck;
511 case EVAL_IDENTITY_COMMITMENT:
512 strcpy(cp->unspendableCCaddr, IdentityCommitmentAddr.c_str());
513 strcpy(cp->normaladdr, IdentityCommitmentAddr.c_str());
514 strcpy(cp->CChexstr, IdentityCommitmentPubKey.c_str());
515 memcpy(cp->CCpriv, DecodeSecret(IdentityCommitmentWIF).begin(),32);
516 cp->validate = ValidateIdentityCommitment;
517 cp->ismyvin = IsIdentityInput;
518 cp->contextualprecheck = DefaultCCContextualPreCheck;
521 case EVAL_IDENTITY_RESERVATION:
522 strcpy(cp->unspendableCCaddr, IdentityReservationAddr.c_str());
523 strcpy(cp->normaladdr, IdentityReservationAddr.c_str());
524 strcpy(cp->CChexstr, IdentityReservationPubKey.c_str());
525 memcpy(cp->CCpriv, DecodeSecret(IdentityReservationWIF).begin(),32);
526 cp->validate = ValidateIdentityReservation;
527 cp->ismyvin = IsIdentityInput;
528 cp->contextualprecheck = PrecheckIdentityReservation;
531 case EVAL_FINALIZE_EXPORT:
532 strcpy(cp->unspendableCCaddr,FinalizeExportAddr.c_str());
533 strcpy(cp->normaladdr,FinalizeExportAddr.c_str());
534 strcpy(cp->CChexstr,FinalizeExportPubKey.c_str());
535 memcpy(cp->CCpriv,DecodeSecret(FinalizeExportWIF).begin(),32);
536 cp->validate = ValidateFinalizeExport;
537 cp->ismyvin = IsFinalizeExportInput; // TODO: these input functions are not useful for new CCs
538 cp->contextualprecheck = FinalizeExportContextualPreCheck;
542 strcpy(cp->unspendableCCaddr, FeePoolAddr.c_str());
543 strcpy(cp->normaladdr, FeePoolAddr.c_str());
544 strcpy(cp->CChexstr, FeePoolPubKey.c_str());
545 memcpy(cp->CCpriv, DecodeSecret(FeePoolWIF).begin(),32);
546 cp->validate = ValidateFeePool;
547 cp->ismyvin = IsFeePoolInput;
548 cp->contextualprecheck = PrecheckFeePool;
551 case EVAL_QUANTUM_KEY:
552 strcpy(cp->unspendableCCaddr, QuantumKeyOutAddr.c_str());
553 strcpy(cp->normaladdr, QuantumKeyOutAddr.c_str());
554 strcpy(cp->CChexstr, QuantumKeyOutPubKey.c_str()); // ironically, this does not need to be a quantum secure public key, since privkey is public
555 memcpy(cp->CCpriv, DecodeSecret(QuantumKeyOutWIF).begin(),32);
556 cp->validate = ValidateQuantumKeyOut;
557 cp->ismyvin = IsQuantumKeyOutInput;
558 cp->contextualprecheck = PrecheckQuantumKeyOut;
561 // these are currently not used and should be triple checked if reenabled
563 strcpy(cp->unspendableCCaddr,AssetsCCaddr);
564 strcpy(cp->normaladdr,AssetsNormaladdr);
565 strcpy(cp->CChexstr,AssetsCChexstr);
566 memcpy(cp->CCpriv,AssetsCCpriv,32);
567 cp->validate = AssetsValidate;
568 cp->ismyvin = IsAssetsInput;
571 strcpy(cp->unspendableCCaddr,FaucetCCaddr);
572 strcpy(cp->normaladdr,FaucetNormaladdr);
573 strcpy(cp->CChexstr,FaucetCChexstr);
574 memcpy(cp->CCpriv,FaucetCCpriv,32);
575 cp->validate = FaucetValidate;
576 cp->ismyvin = IsFaucetInput;
579 strcpy(cp->unspendableCCaddr,RewardsCCaddr);
580 strcpy(cp->normaladdr,RewardsNormaladdr);
581 strcpy(cp->CChexstr,RewardsCChexstr);
582 memcpy(cp->CCpriv,RewardsCCpriv,32);
583 cp->validate = RewardsValidate;
584 cp->ismyvin = IsRewardsInput;
587 strcpy(cp->unspendableCCaddr,DiceCCaddr);
588 strcpy(cp->normaladdr,DiceNormaladdr);
589 strcpy(cp->CChexstr,DiceCChexstr);
590 memcpy(cp->CCpriv,DiceCCpriv,32);
591 cp->validate = DiceValidate;
592 cp->ismyvin = IsDiceInput;
595 strcpy(cp->unspendableCCaddr,LottoCCaddr);
596 strcpy(cp->normaladdr,LottoNormaladdr);
597 strcpy(cp->CChexstr,LottoCChexstr);
598 memcpy(cp->CCpriv,LottoCCpriv,32);
599 cp->validate = LottoValidate;
600 cp->ismyvin = IsLottoInput;
603 strcpy(cp->unspendableCCaddr,FSMCCaddr);
604 strcpy(cp->normaladdr,FSMNormaladdr);
605 strcpy(cp->CChexstr,FSMCChexstr);
606 memcpy(cp->CCpriv,FSMCCpriv,32);
607 cp->validate = FSMValidate;
608 cp->ismyvin = IsFSMInput;
611 strcpy(cp->unspendableCCaddr,AuctionCCaddr);
612 strcpy(cp->normaladdr,AuctionNormaladdr);
613 strcpy(cp->CChexstr,AuctionCChexstr);
614 memcpy(cp->CCpriv,AuctionCCpriv,32);
615 cp->validate = AuctionValidate;
616 cp->ismyvin = IsAuctionInput;
619 strcpy(cp->unspendableCCaddr,MofNCCaddr);
620 strcpy(cp->normaladdr,MofNNormaladdr);
621 strcpy(cp->CChexstr,MofNCChexstr);
622 memcpy(cp->CCpriv,MofNCCpriv,32);
623 cp->validate = MofNValidate;
624 cp->ismyvin = IsMofNInput;
627 strcpy(cp->unspendableCCaddr,ChannelsCCaddr);
628 strcpy(cp->normaladdr,ChannelsNormaladdr);
629 strcpy(cp->CChexstr,ChannelsCChexstr);
630 memcpy(cp->CCpriv,ChannelsCCpriv,32);
631 cp->validate = ChannelsValidate;
632 cp->ismyvin = IsChannelsInput;
635 strcpy(cp->unspendableCCaddr,OraclesCCaddr);
636 strcpy(cp->normaladdr,OraclesNormaladdr);
637 strcpy(cp->CChexstr,OraclesCChexstr);
638 memcpy(cp->CCpriv,OraclesCCpriv,32);
639 cp->validate = OraclesValidate;
640 cp->ismyvin = IsOraclesInput;
643 strcpy(cp->unspendableCCaddr,PricesCCaddr);
644 strcpy(cp->normaladdr,PricesNormaladdr);
645 strcpy(cp->CChexstr,PricesCChexstr);
646 memcpy(cp->CCpriv,PricesCCpriv,32);
647 cp->validate = PricesValidate;
648 cp->ismyvin = IsPricesInput;
651 strcpy(cp->unspendableCCaddr,PegsCCaddr);
652 strcpy(cp->normaladdr,PegsNormaladdr);
653 strcpy(cp->CChexstr,PegsCChexstr);
654 memcpy(cp->CCpriv,PegsCCpriv,32);
655 cp->validate = PegsValidate;
656 cp->ismyvin = IsPegsInput;
659 strcpy(cp->unspendableCCaddr,TriggersCCaddr);
660 strcpy(cp->normaladdr,TriggersNormaladdr);
661 strcpy(cp->CChexstr,TriggersCChexstr);
662 memcpy(cp->CCpriv,TriggersCCpriv,32);
663 cp->validate = TriggersValidate;
664 cp->ismyvin = IsTriggersInput;
667 strcpy(cp->unspendableCCaddr,PaymentsCCaddr);
668 strcpy(cp->normaladdr,PaymentsNormaladdr);
669 strcpy(cp->CChexstr,PaymentsCChexstr);
670 memcpy(cp->CCpriv,PaymentsCCpriv,32);
671 cp->validate = PaymentsValidate;
672 cp->ismyvin = IsPaymentsInput;
675 strcpy(cp->unspendableCCaddr,GatewaysCCaddr);
676 strcpy(cp->normaladdr,GatewaysNormaladdr);
677 strcpy(cp->CChexstr,GatewaysCChexstr);
678 memcpy(cp->CCpriv,GatewaysCCpriv,32);
679 cp->validate = GatewaysValidate;
680 cp->ismyvin = IsGatewaysInput;