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 ******************************************************************************/
16 #include "CCinclude.h"
19 #include "CCrewards.h"
21 #include "CCauction.h"
26 CCcustom has most of the functions that need to be extended to create a new CC contract.
28 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.
30 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.
32 what needs to be done to add a new contract:
33 1. add EVAL_CODE to eval.h
34 2. initialize the variables in the CCinit function below
35 3. write a Validate function to reject any unsanctioned usage of vin/vout
36 4. make helper functions to create rawtx for RPC functions
37 5. add rpc calls to rpcserver.cpp and rpcserver.h and in one of the rpc.cpp files
38 6. add the new .cpp files to src/Makefile.am
41 //BTCD Address: RAssetsAtGnvwgK9gVHBbAU4sVTah1hAm5
42 //BTCD Privkey: UvtvQVgVScXEYm4J3r4nE4nbFuGXSVM5pKec8VWXwgG9dmpWBuDh
43 //BTCD Address: RSavingsEYcivt2DFsxsKeCjqArV6oVtVZ
44 //BTCD Privkey: Ux6XQekTxokko6gZHz24B7PUsmUQtWFzG2W9nUA8jba7UoVbPBF4
47 #define FUNCNAME IsAssetsInput
48 #define EVALCODE EVAL_ASSETS
49 const char *AssetsCCaddr = "RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6"; //"RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u";
50 char AssetsCChexstr[67] = { "02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702" };
51 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 };
53 #include "CCcustom.inc"
58 #define FUNCNAME IsFaucetInput
59 #define EVALCODE EVAL_FAUCET
60 const char *FaucetCCaddr = "R9zHrofhRbub7ER77B7NrVch3A63R39GuC"; //"RKQV4oYs4rvxAWx1J43VnT73rSTVtUeckk";
61 char FaucetCChexstr[67] = { "03682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe12" };
62 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 };
64 #include "CCcustom.inc"
69 #define FUNCNAME IsRewardsInput
70 #define EVALCODE EVAL_REWARDS
71 const char *RewardsCCaddr = "RJCqA4jQTFEZ841dZgxko8aYgUU3FRNGNm"; //"RYRJGMAYEfLCZ6ZddbpxPiUZ1sens8vPYK";
72 char RewardsCChexstr[67] = { "026f00fdc2f1ed0006d66e2ca1787633590581c2fc90e7cb7b01a6c1131b40e94d" };
73 uint8_t RewardsCCpriv[32] = { 0x9f, 0x0c, 0x57, 0xdc, 0x6f, 0x78, 0xae, 0xb0, 0xc7, 0x62, 0x9e, 0x7d, 0x2b, 0x90, 0x6b, 0xbd, 0x40, 0x78, 0x19, 0x5b, 0x3c, 0xb8, 0x82, 0x2d, 0x29, 0x84, 0x72, 0x7a, 0x59, 0x5a, 0x4b, 0x69 };
74 #include "CCcustom.inc"
79 #define FUNCNAME IsDiceInput
80 #define EVALCODE EVAL_DICE
81 const char *DiceCCaddr = "REabWB7KjFN5C3LFMZ5odExHPenYzHLtVw"; //"RLEe8f7Eg3TDuXii9BmNiiiaVGraHUt25c";
82 char DiceCChexstr[67] = { "039d966927cfdadab3ee6c56da63c21f17ea753dde4b3dfd41487103e24b27e94e" };
83 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 };
84 #include "CCcustom.inc"
89 #define FUNCNAME IsLottoInput
90 #define EVALCODE EVAL_LOTTO
91 const char *LottoCCaddr = "RNXZxgyWSAE6XS3qGnTaf5dVNCxnYzhPrg"; //"RLW6hhRqBZZMBndnyPv29Yg3krh6iBYCyg";
92 char LottoCChexstr[67] = { "03f72d2c4db440df1e706502b09ca5fec73ffe954ea1883e4049e98da68690d98f" };
93 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 };
94 #include "CCcustom.inc"
99 #define FUNCNAME IsPonziInput
100 #define EVALCODE EVAL_PONZI
101 const char *PonziCCaddr = "RUKTbLBeKgHkm3Ss4hKZP3ikuLW1xx7B2x"; //"RWSHRbxnJYLvDjpcQ2i8MekgP6h2ctTKaj";
102 char PonziCChexstr[67] = { "039b52d294b413b07f3643c1a28c5467901a76562d8b39a785910ae0a0f3043810" };
103 uint8_t PonziCCpriv[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 };
104 #include "CCcustom.inc"
109 #define FUNCNAME IsAuctionInput
110 #define EVALCODE EVAL_AUCTION
111 const char *AuctionCCaddr = "RL4YPX7JYG3FnvoPqWF2pn3nQknH5NWEwx"; //"RFtVDNmdTZBTNZdmFRbfBgJ6LitgTghikL";
112 char AuctionCChexstr[67] = { "037eefe050c14cb60ae65d5b2f69eaa1c9006826d729bc0957bdc3024e3ca1dbe6" };
113 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 };
114 #include "CCcustom.inc"
118 struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode)
120 cp->evalcode = evalcode;
124 strcpy(cp->unspendableCCaddr,AssetsCCaddr);
125 strcpy(cp->CChexstr,AssetsCChexstr);
126 memcpy(cp->CCpriv,AssetsCCpriv,32);
127 cp->validate = AssetsValidate;
128 cp->ismyvin = IsAssetsInput;
131 strcpy(cp->unspendableCCaddr,FaucetCCaddr);
132 strcpy(cp->CChexstr,FaucetCChexstr);
133 memcpy(cp->CCpriv,FaucetCCpriv,32);
134 cp->validate = FaucetValidate;
135 cp->ismyvin = IsFaucetInput;
138 strcpy(cp->unspendableCCaddr,RewardsCCaddr);
139 strcpy(cp->CChexstr,RewardsCChexstr);
140 memcpy(cp->CCpriv,RewardsCCpriv,32);
141 cp->validate = RewardsValidate;
142 cp->ismyvin = IsRewardsInput;
145 strcpy(cp->unspendableCCaddr,DiceCCaddr);
146 strcpy(cp->CChexstr,DiceCChexstr);
147 memcpy(cp->CCpriv,DiceCCpriv,32);
148 cp->validate = DiceValidate;
149 cp->ismyvin = IsDiceInput;
152 strcpy(cp->unspendableCCaddr,LottoCCaddr);
153 strcpy(cp->CChexstr,LottoCChexstr);
154 memcpy(cp->CCpriv,LottoCCpriv,32);
155 cp->validate = LottoValidate;
156 cp->ismyvin = IsLottoInput;
159 strcpy(cp->unspendableCCaddr,PonziCCaddr);
160 strcpy(cp->CChexstr,PonziCChexstr);
161 memcpy(cp->CCpriv,PonziCCpriv,32);
162 cp->validate = PonziValidate;
163 cp->ismyvin = IsPonziInput;
166 strcpy(cp->unspendableCCaddr,AuctionCCaddr);
167 strcpy(cp->CChexstr,AuctionCChexstr);
168 memcpy(cp->CCpriv,AuctionCCpriv,32);
169 cp->validate = AuctionValidate;
170 cp->ismyvin = IsAuctionInput;