* Fix * -print * Filter null outputs * Rewards cc * Fix * Linker * Fix * Fix * KOMODO_LONGESTCHAIN * Mining_height * Fix dropped assetoshis * Error null CCvin * Test * Test * Test * Fix sell * Fix order book prints * ) * Test * Test * Fix order display * Fix oops * Fix duplicate vin * Remove dust check * Fix silly bug * Test * Test * Fix * Test * Test * Test * Test * Test * Test * Test * Fix compiler error: call of overloaded 'Pair(const char [9], time_t)' is ambiguous * Fix compiler error: call of overloaded 'Pair(const char [9], time_t)' is ambiguous * Correctly parse optional top parameter to getsnapshot * Fix token orders crash * Add SEC to assetchains.json * Split amounts/validation: bid, ask, swap * Fixes * Test * Test * Test * Test * +print * Test * Test * Test * Test * Test * Test * SMALLVAL * Test * Test * Test * Test * Test * Test * Test * Properly handle multiple vins funding fills * Test * Test * Test * Test * Fix ask fill dest * Test * Rewards functions * Fix * Test * Params to rewardscalc * Create funding, addfunding, lock * Test * +print * tokenswapask * Test * Test * Swap functions * ac_cc under 1000 is not fungible * Allow to cancel invalid orders * Prevent negative numbers in assets tx * Uint64 -> int64 * Fix oops * Prevent bid for nonexistent assetid * Error check bidding for assetid that is txid but not asset creation * Fix * Fix * Add pause if scriptcheckqueue isn't idle * Fix * -> -> . * Fix * Test * VOBJ * Tokeninfo rpc * Asset list * Test * strcpy(cp->normaladdr,AssetsNormaladdr); * Fix * Rewardslist rewardsinfo * Fix * Fix * Fix * Vent * fix * Int64 * Int64 * Fix createfunding * Fix false positive error * sbits = stringbits(planstr); * Fix maxmoney * Fix funding name * Test * Print * CCutoxvalue * Fix rewardslock utxo selection * New PoW diff calc * tst * Test * Oldflag for PoW calc * Test * Test * tst * Test * Test * Filter locked utxo * Test * Fix PoW recalc * Test min seconds * int64_t CCduration(uint256 txid) * Test * Test * Test one day * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Prevent inputs of CC inputs * Test * tst * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * Test * New rewards address * Fix mask * Test * Test * Test * Test * Test * Test * Teest * Stricter vin/vout checks for assets * Token swap ready for testing * Fix rewards unlock * Fix * Test * Validate rewards * Test * Trim funding input * Test * Test * Test * Test * Test * Test * Test * Test * Test * Activate CCduration constraint * Parameterize KOMODO_FIRSTFUNGIBLEID to 100 * +print * Test * Test * Test * Test * Fix c script * Test * Initial dice morph from rewards.cpp * Fix * Test * Fix * Test * Diceaddfunds * Fix * Dice list and dice info * dicefund * Dice bet * Test * Test * Put process block's check block call inside lock, revert mining testblockvalidity outside lock * Don't exit fiat-cli on error * Docs for coinsupply RPC and improved error-checking on block height * Version to 0.3.12-beta. * Change version to 0.3.12 for gilab CI. * Put undefines for _cpuid back. * Network decentralizatoin and bug fixes * Remove unnecessary staking delay * Staking and mining timeing improvements * Put staking readout once per staking loop so people know it's staking * Fail on get_chainactive before lock if checks fail * Fix check for stake transaction after Komodo merge * Portable dev (#105) * Force portable code * Switch to old MMX instructions, avoiding SSE & SSE2 instructions. * Less agressive, leave verus code (which checks for it) using advanced instructions. * Compiling only for windows * Update .gitlab-ci.yml * Try -march=native for C++ code generation. * Tweaking machine architecture settings. * Try native alone. * Also get LIBCRYPTOCONDITIONS to -march=native * Switch other lib to native as well. * Try switching back further for CPU architecture. * Even lower end settings. * Turn on symbols. * Use sse2,3 and 4 capable x64. * Once again let verus lib use advances instructioins since it checjs via CPUID at run time. * Modify a few more makefile entries. * Switch to AMD model similar to our test system. * Get snark makefile to k8 too. * Yet another -march to modify to k8, or two of them. * Brute force k8 settings, comment non-portable code out. * Put the condition on cpuid back. * Put non-portable advenced instruction code back * Enable instructions. * Add lib for separate settings. * Update .gitlab-ci.yml * Update .gitlab-ci.yml * Update .gitlab-ci.yml * Update .gitlab-ci.yml * replacing k8-sse3 specific flags to x86-84 * updating versions * updating versions * Get verus-cli verusd updated (#106) * Force portable code * Switch to old MMX instructions, avoiding SSE & SSE2 instructions. * Less agressive, leave verus code (which checks for it) using advanced instructions. * Compiling only for windows * Update .gitlab-ci.yml * Try -march=native for C++ code generation. * Tweaking machine architecture settings. * Try native alone. * Also get LIBCRYPTOCONDITIONS to -march=native * Switch other lib to native as well. * Try switching back further for CPU architecture. * Even lower end settings. * Turn on symbols. * Use sse2,3 and 4 capable x64. * Once again let verus lib use advances instructioins since it checjs via CPUID at run time. * Modify a few more makefile entries. * Switch to AMD model similar to our test system. * Get snark makefile to k8 too. * Yet another -march to modify to k8, or two of them. * Brute force k8 settings, comment non-portable code out. * Put the condition on cpuid back. * Put non-portable advenced instruction code back * Enable instructions. * Add lib for separate settings. * Update .gitlab-ci.yml * Update .gitlab-ci.yml * Update .gitlab-ci.yml * Update .gitlab-ci.yml * replacing k8-sse3 specific flags to x86-84 * updating versions * Propagate verusd changes.
196 lines
9.7 KiB
C++
196 lines
9.7 KiB
C++
/******************************************************************************
|
|
* Copyright © 2014-2018 The SuperNET Developers. *
|
|
* *
|
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
* the top-level directory of this distribution for the individual copyright *
|
|
* holder information and the developer policies on copyright and licensing. *
|
|
* *
|
|
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
* SuperNET software, including this file may be copied, modified, propagated *
|
|
* or distributed except according to the terms contained in the LICENSE file *
|
|
* *
|
|
* Removal or modification of this copyright notice is prohibited. *
|
|
* *
|
|
******************************************************************************/
|
|
|
|
#include "CCinclude.h"
|
|
#include "CCassets.h"
|
|
#include "CCfaucet.h"
|
|
#include "CCrewards.h"
|
|
#include "CCdice.h"
|
|
#include "CCauction.h"
|
|
#include "CClotto.h"
|
|
#include "CCponzi.h"
|
|
|
|
/*
|
|
CCcustom has most of the functions that need to be extended to create a new CC contract.
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
what needs to be done to add a new contract:
|
|
1. add EVAL_CODE to eval.h
|
|
2. initialize the variables in the CCinit function below
|
|
3. write a Validate function to reject any unsanctioned usage of vin/vout
|
|
4. make helper functions to create rawtx for RPC functions
|
|
5. add rpc calls to rpcserver.cpp and rpcserver.h and in one of the rpc.cpp files
|
|
6. add the new .cpp files to src/Makefile.am
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
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.
|
|
*/
|
|
|
|
//BTCD Address: RAssetsAtGnvwgK9gVHBbAU4sVTah1hAm5
|
|
//BTCD Privkey: UvtvQVgVScXEYm4J3r4nE4nbFuGXSVM5pKec8VWXwgG9dmpWBuDh
|
|
//BTCD Address: RSavingsEYcivt2DFsxsKeCjqArV6oVtVZ
|
|
//BTCD Privkey: Ux6XQekTxokko6gZHz24B7PUsmUQtWFzG2W9nUA8jba7UoVbPBF4
|
|
|
|
// Assets, aka Tokens
|
|
#define FUNCNAME IsAssetsInput
|
|
#define EVALCODE EVAL_ASSETS
|
|
const char *AssetsCCaddr = "RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6";
|
|
const char *AssetsNormaladdr = "RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u";
|
|
char AssetsCChexstr[67] = { "02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702" };
|
|
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 };
|
|
|
|
#include "CCcustom.inc"
|
|
#undef FUNCNAME
|
|
#undef EVALCODE
|
|
|
|
// Faucet
|
|
#define FUNCNAME IsFaucetInput
|
|
#define EVALCODE EVAL_FAUCET
|
|
const char *FaucetCCaddr = "R9zHrofhRbub7ER77B7NrVch3A63R39GuC";
|
|
const char *FaucetNormaladdr = "RKQV4oYs4rvxAWx1J43VnT73rSTVtUeckk";
|
|
char FaucetCChexstr[67] = { "03682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe12" };
|
|
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 };
|
|
|
|
#include "CCcustom.inc"
|
|
#undef FUNCNAME
|
|
#undef EVALCODE
|
|
|
|
// Rewards
|
|
#define FUNCNAME IsRewardsInput
|
|
#define EVALCODE EVAL_REWARDS
|
|
const char *RewardsCCaddr = "RTsRBYL1HSvMoE3qtBJkyiswdVaWkm8YTK";
|
|
const char *RewardsNormaladdr = "RMgye9jeczNjQx9Uzq8no8pTLiCSwuHwkz";
|
|
char RewardsCChexstr[67] = { "03da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb9" };
|
|
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 };
|
|
#include "CCcustom.inc"
|
|
#undef FUNCNAME
|
|
#undef EVALCODE
|
|
|
|
// Dice
|
|
#define FUNCNAME IsDiceInput
|
|
#define EVALCODE EVAL_DICE
|
|
const char *DiceCCaddr = "REabWB7KjFN5C3LFMZ5odExHPenYzHLtVw";
|
|
const char *DiceNormaladdr = "RLEe8f7Eg3TDuXii9BmNiiiaVGraHUt25c";
|
|
char DiceCChexstr[67] = { "039d966927cfdadab3ee6c56da63c21f17ea753dde4b3dfd41487103e24b27e94e" };
|
|
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 };
|
|
#include "CCcustom.inc"
|
|
#undef FUNCNAME
|
|
#undef EVALCODE
|
|
|
|
// Lotto
|
|
#define FUNCNAME IsLottoInput
|
|
#define EVALCODE EVAL_LOTTO
|
|
const char *LottoCCaddr = "RNXZxgyWSAE6XS3qGnTaf5dVNCxnYzhPrg";
|
|
const char *LottoNormaladdr = "RLW6hhRqBZZMBndnyPv29Yg3krh6iBYCyg";
|
|
char LottoCChexstr[67] = { "03f72d2c4db440df1e706502b09ca5fec73ffe954ea1883e4049e98da68690d98f" };
|
|
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 };
|
|
#include "CCcustom.inc"
|
|
#undef FUNCNAME
|
|
#undef EVALCODE
|
|
|
|
// Ponzi
|
|
#define FUNCNAME IsPonziInput
|
|
#define EVALCODE EVAL_PONZI
|
|
const char *PonziCCaddr = "RUKTbLBeKgHkm3Ss4hKZP3ikuLW1xx7B2x";
|
|
const char *PonziNormaladdr = "RWSHRbxnJYLvDjpcQ2i8MekgP6h2ctTKaj";
|
|
char PonziCChexstr[67] = { "039b52d294b413b07f3643c1a28c5467901a76562d8b39a785910ae0a0f3043810" };
|
|
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 };
|
|
#include "CCcustom.inc"
|
|
#undef FUNCNAME
|
|
#undef EVALCODE
|
|
|
|
// Auction
|
|
#define FUNCNAME IsAuctionInput
|
|
#define EVALCODE EVAL_AUCTION
|
|
const char *AuctionCCaddr = "RL4YPX7JYG3FnvoPqWF2pn3nQknH5NWEwx";
|
|
const char *AuctionNormaladdr = "RFtVDNmdTZBTNZdmFRbfBgJ6LitgTghikL";
|
|
char AuctionCChexstr[67] = { "037eefe050c14cb60ae65d5b2f69eaa1c9006826d729bc0957bdc3024e3ca1dbe6" };
|
|
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 };
|
|
#include "CCcustom.inc"
|
|
#undef FUNCNAME
|
|
#undef EVALCODE
|
|
|
|
struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode)
|
|
{
|
|
cp->evalcode = evalcode;
|
|
switch ( evalcode )
|
|
{
|
|
case EVAL_ASSETS:
|
|
strcpy(cp->unspendableCCaddr,AssetsCCaddr);
|
|
strcpy(cp->normaladdr,AssetsNormaladdr);
|
|
strcpy(cp->CChexstr,AssetsCChexstr);
|
|
memcpy(cp->CCpriv,AssetsCCpriv,32);
|
|
cp->validate = AssetsValidate;
|
|
cp->ismyvin = IsAssetsInput;
|
|
break;
|
|
case EVAL_FAUCET:
|
|
strcpy(cp->unspendableCCaddr,FaucetCCaddr);
|
|
strcpy(cp->normaladdr,FaucetNormaladdr);
|
|
strcpy(cp->CChexstr,FaucetCChexstr);
|
|
memcpy(cp->CCpriv,FaucetCCpriv,32);
|
|
cp->validate = FaucetValidate;
|
|
cp->ismyvin = IsFaucetInput;
|
|
break;
|
|
case EVAL_REWARDS:
|
|
strcpy(cp->unspendableCCaddr,RewardsCCaddr);
|
|
strcpy(cp->normaladdr,RewardsNormaladdr);
|
|
strcpy(cp->CChexstr,RewardsCChexstr);
|
|
memcpy(cp->CCpriv,RewardsCCpriv,32);
|
|
cp->validate = RewardsValidate;
|
|
cp->ismyvin = IsRewardsInput;
|
|
break;
|
|
case EVAL_DICE:
|
|
strcpy(cp->unspendableCCaddr,DiceCCaddr);
|
|
strcpy(cp->normaladdr,DiceNormaladdr);
|
|
strcpy(cp->CChexstr,DiceCChexstr);
|
|
memcpy(cp->CCpriv,DiceCCpriv,32);
|
|
cp->validate = DiceValidate;
|
|
cp->ismyvin = IsDiceInput;
|
|
break;
|
|
case EVAL_LOTTO:
|
|
strcpy(cp->unspendableCCaddr,LottoCCaddr);
|
|
strcpy(cp->normaladdr,LottoNormaladdr);
|
|
strcpy(cp->CChexstr,LottoCChexstr);
|
|
memcpy(cp->CCpriv,LottoCCpriv,32);
|
|
cp->validate = LottoValidate;
|
|
cp->ismyvin = IsLottoInput;
|
|
break;
|
|
case EVAL_PONZI:
|
|
strcpy(cp->unspendableCCaddr,PonziCCaddr);
|
|
strcpy(cp->normaladdr,PonziNormaladdr);
|
|
strcpy(cp->CChexstr,PonziCChexstr);
|
|
memcpy(cp->CCpriv,PonziCCpriv,32);
|
|
cp->validate = PonziValidate;
|
|
cp->ismyvin = IsPonziInput;
|
|
break;
|
|
case EVAL_AUCTION:
|
|
strcpy(cp->unspendableCCaddr,AuctionCCaddr);
|
|
strcpy(cp->normaladdr,AuctionNormaladdr);
|
|
strcpy(cp->CChexstr,AuctionCChexstr);
|
|
memcpy(cp->CCpriv,AuctionCCpriv,32);
|
|
cp->validate = AuctionValidate;
|
|
cp->ismyvin = IsAuctionInput;
|
|
break;
|
|
}
|
|
return(cp);
|
|
}
|
|
|