From d81e8c0a3f90c93ea10102822116256d60c9481b Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 10 Feb 2024 18:56:37 -0500 Subject: [PATCH 01/21] Delete more CCs #381 --- src/cc/CCcustom.cpp | 389 -------------------------------------------- src/cc/CCcustom.inc | 17 -- 2 files changed, 406 deletions(-) delete mode 100644 src/cc/CCcustom.inc diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 1e9653609..f526cd2fe 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -28,402 +28,13 @@ #include "CCPegs.h" #include "CCtokens.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. - */ - -// 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 - -// 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 - -// Finite State Machine -#define FUNCNAME IsFSMInput -#define EVALCODE EVAL_FSM -const char *FSMCCaddr = "RUKTbLBeKgHkm3Ss4hKZP3ikuLW1xx7B2x"; -const char *FSMNormaladdr = "RWSHRbxnJYLvDjpcQ2i8MekgP6h2ctTKaj"; -char FSMCChexstr[67] = { "039b52d294b413b07f3643c1a28c5467901a76562d8b39a785910ae0a0f3043810" }; -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 }; -#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 - -// Heir -#define FUNCNAME IsHeirInput -#define EVALCODE EVAL_HEIR -const char *HeirCCaddr = "RDVHcSekmXgeYBqRupNTmqo3Rn8QRXNduy"; -const char *HeirNormaladdr = "RTPwUjKYECcGn6Y4KYChLhgaht1RSU4jwf"; -char HeirCChexstr[67] = { "03c91bef3d7cc59c3a89286833a3446b29e52a5e773f738a1ad2b09785e5f4179e" }; -uint8_t HeirCCpriv[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 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// Channels -#define FUNCNAME IsChannelsInput -#define EVALCODE EVAL_CHANNELS -const char *ChannelsCCaddr = "RQy3rwX8sP9oDm3c39vGKA6H315cgtPLfr"; -const char *ChannelsNormaladdr = "RQUuT8zmkvDfXqECH4m3VD3SsHZAfnoh1v"; -char ChannelsCChexstr[67] = { "035debdb19b1c98c615259339500511d6216a3ffbeb28ff5655a7ef5790a12ab0b" }; -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 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// Oracles -#define FUNCNAME IsOraclesInput -#define EVALCODE EVAL_ORACLES -const char *OraclesCCaddr = "REt2C4ZMnX8YYX1DRpffNA4hECZTFm39e3"; -const char *OraclesNormaladdr = "RHkFKzn1csxA3fWzAsxsLWohoCgBbirXb5"; -char OraclesCChexstr[67] = { "038c1d42db6a45a57eccb8981b078fb7857b9b496293fe299d2b8d120ac5b5691a" }; -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 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// Prices -#define FUNCNAME IsPricesInput -#define EVALCODE EVAL_PRICES -const char *PricesCCaddr = "RAL5Vh8NXmFqEKJRKrk1KjKaUckK7mM1iS"; -const char *PricesNormaladdr = "RBunXCsMHk5NPd6q8SQfmpgre3x133rSwZ"; -char PricesCChexstr[67] = { "039894cb054c0032e99e65e715b03799607aa91212a16648d391b6fa2cc52ed0cf" }; -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 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// Pegs -#define FUNCNAME IsPegsInput -#define EVALCODE EVAL_PEGS -const char *PegsCCaddr = "RHnkVb7vHuHnjEjhkCF1bS6xxLLNZPv5fd"; -const char *PegsNormaladdr = "RMcCZtX6dHf1fz3gpLQhUEMQ8cVZ6Rzaro"; -char PegsCChexstr[67] = { "03c75c1de29a35e41606363b430c08be1c2dd93cf7a468229a082cc79c7b77eece" }; -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 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// Payments -#define FUNCNAME IsPaymentsInput -#define EVALCODE EVAL_PAYMENTS -const char *PaymentsCCaddr = "REpyKi7avsVduqZ3eimncK4uKqSArLTGGK"; -const char *PaymentsNormaladdr = "RHRX8RTMAh2STWe9DHqsvJbzS7ty6aZy3d"; -char PaymentsCChexstr[67] = { "0358f1764f82c63abc7c7455555fd1d3184905e30e819e97667e247e5792b46856" }; -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 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// Gateways -#define FUNCNAME IsGatewaysInput -#define EVALCODE EVAL_GATEWAYS -const char *GatewaysCCaddr = "RKWpoK6vTRtq5b9qrRBodLkCzeURHeEk33"; -const char *GatewaysNormaladdr = "RGJKV97ZN1wBfunuMt1tebiiHENNEq73Yh"; // wif UxJFYqEvLAjWPPRvn8NN1fRWscBxQZXZB5BBgc3HiapKVQBYNcmo -char GatewaysCChexstr[67] = { "03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40" }; -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 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// Tokens -#define FUNCNAME IsTokensInput -#define EVALCODE EVAL_TOKENS -const char *TokensCCaddr = "RAMvUfoyURBRxAdVeTMHxn3giJZCFWeha2"; -const char *TokensNormaladdr = "RCNgAngYAdrfzujYyPgfbjCGNVQZzCgTad"; -char TokensCChexstr[67] = { "03e6191c70c9c9a28f9fd87089b9488d0e6c02fb629df64979c9cdb6b2b4a68d95" }; -uint8_t TokensCCpriv[32] = { 0x1d, 0x0d, 0x0d, 0xce, 0x2d, 0xd2, 0xe1, 0x9d, 0xf5, 0xb6, 0x26, 0xd5, 0xad, 0xa0, 0xf0, 0x0a, 0xdd, 0x7a, 0x72, 0x7d, 0x17, 0x35, 0xb5, 0xe3, 0x2c, 0x6c, 0xa9, 0xa2, 0x03, 0x16, 0x4b, 0xcf }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -#define FUNCNAME IsCClibInput -#define EVALCODE EVAL_FIRSTUSER -const char *CClibNormaladdr = "RVVeUg43rNcq3mZFnvZ8yqagyzqFgUnq4u"; -char CClibCChexstr[67] = { "032447d97655da079729dc024c61088ea415b22f4c15d4810ddaf2069ac6468d2f" }; -uint8_t CClibCCpriv[32] = { 0x57, 0xcf, 0x49, 0x71, 0x7d, 0xb4, 0x15, 0x1b, 0x4f, 0x98, 0xc5, 0x45, 0x8d, 0x26, 0x52, 0x4b, 0x7b, 0xe9, 0xbd, 0x55, 0xd8, 0x20, 0xd6, 0xc4, 0x82, 0x0f, 0xf5, 0xec, 0x6c, 0x1c, 0xa0, 0xc0 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - -// ImportGateway -#define FUNCNAME IsImportGatewayInput -#define EVALCODE EVAL_IMPORTGATEWAY -const char *ImportGatewayCCaddr = "RXJT6CRAXHFuQ2UjqdxMj7EfrayF6UJpzZ"; -const char *ImportGatewayNormaladdr = "RNFRho63Ddz1Rh2eGPETykrU4fA8r67S4Y"; -char ImportGatewayCChexstr[67] = { "0397231cfe04ea32d5fafb2206773ec9fba6e15c5a4e86064468bca195f7542714" }; -uint8_t ImportGatewayCCpriv[32] = { 0x65, 0xef, 0x27, 0xeb, 0x3d, 0xb0, 0xb4, 0xae, 0x0f, 0xbc, 0x77, 0xdb, 0xf8, 0x40, 0x48, 0x90, 0x52, 0x20, 0x9e, 0x45, 0x3b, 0x49, 0xd8, 0x97, 0x60, 0x8c, 0x27, 0x4c, 0x59, 0x46, 0xe1, 0xdf }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) { - CPubKey pk; int32_t i; uint8_t pub33[33],check33[33],hash[32]; char CCaddr[64],checkaddr[64],str[67]; - cp->evalcode = evalcode; - cp->ismyvin = IsCClibInput; - memcpy(cp->CCpriv,CClibCCpriv,32); - if ( evalcode == EVAL_FIRSTUSER ) // eventually make a hashchain for each evalcode - { - strcpy(cp->CChexstr,CClibCChexstr); - decode_hex(pub33,33,cp->CChexstr); - pk = buf2pk(pub33); - Getscriptaddress(cp->normaladdr,CScript() << ParseHex(HexStr(pk)) << OP_CHECKSIG); - if ( strcmp(cp->normaladdr,CClibNormaladdr) != 0 ) - fprintf(stderr,"CClib_initcp addr mismatch %s vs %s\n",cp->normaladdr,CClibNormaladdr); - GetCCaddress(cp,cp->unspendableCCaddr,pk); - if ( priv2addr(checkaddr,check33,cp->CCpriv) != 0 ) - { - if ( buf2pk(check33) == pk && strcmp(checkaddr,cp->normaladdr) == 0 ) - { - //fprintf(stderr,"verified evalcode.%d %s %s\n",cp->evalcode,checkaddr,pubkey33_str(str,pub33)); - return(0); - } else fprintf(stderr,"CClib_initcp mismatched privkey -> addr %s vs %s\n",checkaddr,cp->normaladdr); - } - } - else - { - for (i=EVAL_FIRSTUSER; iCCpriv,32); - memcpy(cp->CCpriv,hash,32); - } - if ( priv2addr(cp->normaladdr,pub33,cp->CCpriv) != 0 ) - { - pk = buf2pk(pub33); - for (i=0; i<33; i++) - sprintf(&cp->CChexstr[i*2],"%02x",pub33[i]); - cp->CChexstr[i*2] = 0; - GetCCaddress(cp,cp->unspendableCCaddr,pk); - //printf("evalcode.%d initialized\n",evalcode); - return(0); - } - } return(-1); } struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) { - // important to clear because not all members are always initialized! - memset(cp, '\0', sizeof(*cp)); - - 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_FSM: - strcpy(cp->unspendableCCaddr,FSMCCaddr); - strcpy(cp->normaladdr,FSMNormaladdr); - strcpy(cp->CChexstr,FSMCChexstr); - memcpy(cp->CCpriv,FSMCCpriv,32); - //cp->validate = FSMValidate; - //cp->ismyvin = IsFSMInput; - 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; - case EVAL_HEIR: - strcpy(cp->unspendableCCaddr,HeirCCaddr); - strcpy(cp->normaladdr,HeirNormaladdr); - strcpy(cp->CChexstr,HeirCChexstr); - memcpy(cp->CCpriv,HeirCCpriv,32); - //cp->validate = HeirValidate; - //cp->ismyvin = IsHeirInput; - break; - case EVAL_CHANNELS: - strcpy(cp->unspendableCCaddr,ChannelsCCaddr); - strcpy(cp->normaladdr,ChannelsNormaladdr); - strcpy(cp->CChexstr,ChannelsCChexstr); - memcpy(cp->CCpriv,ChannelsCCpriv,32); - //cp->validate = ChannelsValidate; - //cp->ismyvin = IsChannelsInput; - break; - case EVAL_ORACLES: - strcpy(cp->unspendableCCaddr,OraclesCCaddr); - strcpy(cp->normaladdr,OraclesNormaladdr); - strcpy(cp->CChexstr,OraclesCChexstr); - memcpy(cp->CCpriv,OraclesCCpriv,32); - //cp->validate = OraclesValidate; - //cp->ismyvin = IsOraclesInput; - break; - case EVAL_PRICES: - strcpy(cp->unspendableCCaddr,PricesCCaddr); - strcpy(cp->normaladdr,PricesNormaladdr); - strcpy(cp->CChexstr,PricesCChexstr); - memcpy(cp->CCpriv,PricesCCpriv,32); - //cp->validate = PricesValidate; - //cp->ismyvin = IsPricesInput; - break; - case EVAL_PEGS: - strcpy(cp->unspendableCCaddr,PegsCCaddr); - strcpy(cp->normaladdr,PegsNormaladdr); - strcpy(cp->CChexstr,PegsCChexstr); - memcpy(cp->CCpriv,PegsCCpriv,32); - //cp->validate = PegsValidate; - //cp->ismyvin = IsPegsInput; - break; - case EVAL_PAYMENTS: - strcpy(cp->unspendableCCaddr,PaymentsCCaddr); - strcpy(cp->normaladdr,PaymentsNormaladdr); - strcpy(cp->CChexstr,PaymentsCChexstr); - memcpy(cp->CCpriv,PaymentsCCpriv,32); - //cp->validate = PaymentsValidate; - //cp->ismyvin = IsPaymentsInput; - break; - case EVAL_GATEWAYS: - strcpy(cp->unspendableCCaddr,GatewaysCCaddr); - strcpy(cp->normaladdr,GatewaysNormaladdr); - strcpy(cp->CChexstr,GatewaysCChexstr); - memcpy(cp->CCpriv,GatewaysCCpriv,32); - //cp->validate = GatewaysValidate; - //cp->ismyvin = IsGatewaysInput; - break; - - case EVAL_TOKENS: - strcpy(cp->unspendableCCaddr, TokensCCaddr); - strcpy(cp->normaladdr, TokensNormaladdr); - strcpy(cp->CChexstr, TokensCChexstr); - memcpy(cp->CCpriv, TokensCCpriv, 32); - //cp->validate = TokensValidate; - //cp->ismyvin = IsTokensInput; - break; - case EVAL_IMPORTGATEWAY: - strcpy(cp->unspendableCCaddr, ImportGatewayCCaddr); - strcpy(cp->normaladdr, ImportGatewayNormaladdr); - strcpy(cp->CChexstr, ImportGatewayCChexstr); - memcpy(cp->CCpriv, ImportGatewayCCpriv, 32); - //cp->validate = ImportGatewayValidate; - //cp->ismyvin = IsImportGatewayInput; - break; - default: - if ( CClib_initcp(cp,evalcode) < 0 ) - return(0); - break; - } return(cp); } diff --git a/src/cc/CCcustom.inc b/src/cc/CCcustom.inc deleted file mode 100644 index c33ca4f5b..000000000 --- a/src/cc/CCcustom.inc +++ /dev/null @@ -1,17 +0,0 @@ - -bool FUNCNAME(CScript const& scriptSig) -{ - CC *cond; - if (!(cond = GetCryptoCondition(scriptSig))) - return false; - // Recurse the CC tree to find asset condition - auto findEval = [] (CC *cond, struct CCVisitor _) { - bool r = cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == EVALCODE; - // false for a match, true for continue - return r ? 0 : 1; - }; - CCVisitor visitor = {findEval, (uint8_t*)"", 0, NULL}; - bool out =! cc_visit(cond, visitor); - cc_free(cond); - return out; -} From 5fa46e1d8dff4892b64145d896916ab194e0fd3d Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 10 Feb 2024 21:46:36 -0500 Subject: [PATCH 02/21] Delete more CCs #381 --- src/cc/CCHeir.h | 39 ------------------------- src/cc/CCOracles.h | 37 ----------------------- src/cc/CCPegs.h | 18 ------------ src/cc/CCPrices.h | 66 ------------------------------------------ src/cc/CCassets.h | 50 -------------------------------- src/cc/CCauction.h | 33 --------------------- src/cc/CCcustom.cpp | 9 ------ src/cc/CCfaucet.h | 31 -------------------- src/cc/CCfsm.h | 33 --------------------- src/rpc/blockchain.cpp | 1 - 10 files changed, 317 deletions(-) delete mode 100644 src/cc/CCHeir.h delete mode 100644 src/cc/CCOracles.h delete mode 100644 src/cc/CCPegs.h delete mode 100644 src/cc/CCPrices.h delete mode 100644 src/cc/CCassets.h delete mode 100644 src/cc/CCauction.h delete mode 100644 src/cc/CCfaucet.h delete mode 100644 src/cc/CCfsm.h diff --git a/src/cc/CCHeir.h b/src/cc/CCHeir.h deleted file mode 100644 index 2701251b3..000000000 --- a/src/cc/CCHeir.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - -#ifndef CC_HEIR_H -#define CC_HEIR_H - -#include "CCinclude.h" -#include "CCtokens.h" - -//#define EVAL_HEIR 0xea - -bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); - -class CoinHelper; -class TokenHelper; - -UniValue HeirFundCoinCaller(int64_t txfee, int64_t coins, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo); -UniValue HeirFundTokenCaller(int64_t txfee, int64_t satoshis, std::string heirName, CPubKey heirPubkey, int64_t inactivityTimeSec, std::string memo, uint256 tokenid); -UniValue HeirClaimCaller(uint256 fundingtxid, int64_t txfee, std::string amount); -UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string amount); -UniValue HeirInfo(uint256 fundingtxid); -UniValue HeirList(); - -#endif diff --git a/src/cc/CCOracles.h b/src/cc/CCOracles.h deleted file mode 100644 index 9ab6082a4..000000000 --- a/src/cc/CCOracles.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - - -#ifndef CC_ORACLES_H -#define CC_ORACLES_H - -#include "CCinclude.h" - -bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); -UniValue OracleCreate(const CPubKey& pk, int64_t txfee,std::string name,std::string description,std::string format); -UniValue OracleFund(const CPubKey& pk, int64_t txfee,uint256 oracletxid); -UniValue OracleRegister(const CPubKey& pk, int64_t txfee,uint256 oracletxid,int64_t datafee); -UniValue OracleSubscribe(const CPubKey& pk, int64_t txfee,uint256 oracletxid,CPubKey publisher,int64_t amount); -UniValue OracleData(const CPubKey& pk, int64_t txfee,uint256 oracletxid,std::vector data); -// CCcustom -UniValue OracleDataSample(uint256 reforacletxid,uint256 txid); -UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num); -UniValue OracleInfo(uint256 origtxid); -UniValue OraclesList(); - -#endif diff --git a/src/cc/CCPegs.h b/src/cc/CCPegs.h deleted file mode 100644 index 5cc2ce473..000000000 --- a/src/cc/CCPegs.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h deleted file mode 100644 index 592a63136..000000000 --- a/src/cc/CCPrices.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - - -#ifndef CC_PRICES_H -#define CC_PRICES_H - -#include "hush_defs.h" -#include "CCinclude.h" - -int32_t hush_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); -extern void GetHushEarlytxidScriptPub(); -extern CScript HUSH_EARLYTXID_SCRIPTPUB; - -// #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) // defined in hush_defs.h -#define PRICES_TXFEE 10000 -#define PRICES_MAXLEVERAGE 777 -#define PRICES_SMOOTHWIDTH 1 -#define HUSH_MAXPRICES 2048 // must be power of 2 and less than 8192 -#define HUSH_PRICEMASK (~(HUSH_MAXPRICES - 1)) // actually 1111 1000 0000 0000 -#define PRICES_WEIGHT (HUSH_MAXPRICES * 1) // 0000 1000 0000 0000 -#define PRICES_MULT (HUSH_MAXPRICES * 2) // 0001 0000 0000 0000 -#define PRICES_DIV (HUSH_MAXPRICES * 3) // 0001 1000 0000 0000 -#define PRICES_INV (HUSH_MAXPRICES * 4) // 0010 0000 0000 0000 -#define PRICES_MDD (HUSH_MAXPRICES * 5) // 0010 1000 0000 0000 -#define PRICES_MMD (HUSH_MAXPRICES * 6) // 0011 0000 0000 0000 -#define PRICES_MMM (HUSH_MAXPRICES * 7) // 0011 1000 0000 0000 -#define PRICES_DDD (HUSH_MAXPRICES * 8) // 0100 0000 0000 0000 - -//#define PRICES_NORMFACTOR (int64_t)(SATOSHIDEN) -//#define PRICES_POINTFACTOR (int64_t)10000 - -#define PRICES_REVSHAREDUST 10000 -#define PRICES_SUBREVSHAREFEE(amount) ((amount) * 199 / 200) // revshare fee percentage == 0.005 -#define PRICES_MINAVAILFUNDFRACTION 0.1 // leveraged bet limit < fund fraction - -bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); - -// CCcustom -UniValue PricesBet(int64_t txfee,int64_t amount,int16_t leverage,std::vector synthetic); -UniValue PricesAddFunding(int64_t txfee,uint256 bettxid,int64_t amount); -UniValue PricesSetcostbasis(int64_t txfee,uint256 bettxid); -UniValue PricesRekt(int64_t txfee,uint256 bettxid,int32_t rektheight); -UniValue PricesCashout(int64_t txfee,uint256 bettxid); -UniValue PricesInfo(uint256 bettxid,int32_t refheight); -UniValue PricesList(uint32_t filter, CPubKey mypk); -UniValue PricesGetOrderbook(); -UniValue PricesRefillFund(int64_t amount); - - -#endif diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h deleted file mode 100644 index 3b03570f8..000000000 --- a/src/cc/CCassets.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - - -/* - CCassetstx has the functions that create the EVAL_ASSETS transactions. It is expected that rpc calls would call these functions. For EVAL_ASSETS, the rpc functions are in rpcwallet.cpp - - CCassetsCore has functions that are used in two contexts, both during rpc transaction create time and also during the blockchain validation. Using the identical functions is a good way to prevent them from being mismatched. The must match or the transaction will get rejected. - */ - -#ifndef CC_ASSETS_H -#define CC_ASSETS_H - -#include "CCinclude.h" - -// CCcustom -bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); - -// CCassetsCore -vscript_t EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector origpubkey); -uint8_t DecodeAssetTokenOpRet(const CScript &scriptPubKey, uint8_t &assetsEvalCode, uint256 &tokenid, uint256 &assetid2, int64_t &price, std::vector &origpubkey); -bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); -int64_t IsAssetvout(struct CCcontract_info *cp, int64_t &price, std::vector &origpubkey, const CTransaction& tx, int32_t v, uint256 refassetid); -bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); -bool ValidateAskRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); -bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); -bool SetBidFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); -int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); -int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); -bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid); - - -#endif diff --git a/src/cc/CCauction.h b/src/cc/CCauction.h deleted file mode 100644 index becbb86ff..000000000 --- a/src/cc/CCauction.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - - -#ifndef CC_AUCTION_H -#define CC_AUCTION_H - -#include "CCinclude.h" - -#define EVAL_AUCTION 0xe8 - -bool AuctionValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); - -std::string AuctionPost(uint64_t txfee,uint256 itemhash,int64_t minbid,char *title,char *description); -std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount); -std::string AuctionDeliver(uint64_t txfee,uint256 itemhash,uint256 bidtxid); - -#endif diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index f526cd2fe..a0a6039e1 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -18,15 +18,6 @@ #include "key_io.h" #include "CCinclude.h" -#include "CCassets.h" -#include "CCfaucet.h" -#include "CCauction.h" -#include "CCfsm.h" -#include "CCHeir.h" -#include "CCOracles.h" -#include "CCPrices.h" -#include "CCPegs.h" -#include "CCtokens.h" int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) { diff --git a/src/cc/CCfaucet.h b/src/cc/CCfaucet.h deleted file mode 100644 index 4e3c40c1d..000000000 --- a/src/cc/CCfaucet.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ -#ifndef CC_FAUCET_H -#define CC_FAUCET_H -#include "CCinclude.h" -#define EVAL_FAUCET 0xe4 -#define FAUCETSIZE (COIN / 10) - -bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); - -// CCcustom -UniValue FaucetFund(const CPubKey& mypk,uint64_t txfee,int64_t funds); -UniValue FaucetGet(const CPubKey& mypk,uint64_t txfee); -UniValue FaucetInfo(); - -#endif diff --git a/src/cc/CCfsm.h b/src/cc/CCfsm.h deleted file mode 100644 index 8c6f487f2..000000000 --- a/src/cc/CCfsm.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - - -#ifndef CC_FSM_H -#define CC_FSM_H - -#include "CCinclude.h" - -#define EVAL_FSM 0xe7 - -bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); - -std::string FSMList(); -std::string FSMInfo(uint256 fsmtxid); -std::string FSMCreate(uint64_t txfee,std::string name,std::string states); - -#endif diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 793dff4ab..b27e01db3 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -40,7 +40,6 @@ #include #include #include "cc/CCinclude.h" -#include "cc/CCPrices.h" using namespace std; From c6aa5e939d27892dd40fe4b526cc7ee39a1ea243 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 10 Feb 2024 21:54:36 -0500 Subject: [PATCH 03/21] Delete more CCs #381 --- src/cc/betprotocol.h | 78 ---------- src/cc/dilithium.h | 346 ------------------------------------------- 2 files changed, 424 deletions(-) delete mode 100644 src/cc/betprotocol.h delete mode 100644 src/cc/dilithium.h diff --git a/src/cc/betprotocol.h b/src/cc/betprotocol.h deleted file mode 100644 index b8c4cf49e..000000000 --- a/src/cc/betprotocol.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** - * Copyright © 2014-2019 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. * - * * - ******************************************************************************/ - -#ifndef BETPROTOCOL_H -#define BETPROTOCOL_H - -#include "cc/eval.h" -#include "pubkey.h" -#include "primitives/transaction.h" -#include "cryptoconditions/include/cryptoconditions.h" - - -class MoMProof -{ -public: - MerkleBranch branch; - uint256 notarizationHash; - ADD_SERIALIZE_METHODS; - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(branch); - READWRITE(notarizationHash); - } -}; - - - -class BetProtocol -{ -protected: - std::vector playerConditions(); -public: - EvalCode disputeCode; - std::vector players; - std::vector vmParams; - uint32_t waitBlocks; - - // Utility - BetProtocol(EvalCode dc, std::vector ps, uint32_t wb, std::vector vmp) - : disputeCode(dc), waitBlocks(wb), vmParams(vmp), players(ps) {} - std::vector PlayerConditions(); - - // on PANGEA - CC* MakeDisputeCond(); - CMutableTransaction MakeSessionTx(CAmount spendFee); - CMutableTransaction MakeDisputeTx(uint256 signedSessionTxHash, uint256 vmResultHash); - CMutableTransaction MakePostEvidenceTx(uint256 signedSessionTxHash, - int playerIndex, std::vector state); - - // on HUSH - CC* MakePayoutCond(uint256 signedSessionTxHash); - CMutableTransaction MakeStakeTx(CAmount totalPayout, uint256 signedSessionTx); - CMutableTransaction MakeAgreePayoutTx(std::vector payouts, uint256 signedStakeTxHash); - CMutableTransaction MakeImportPayoutTx(std::vector payouts, - CTransaction signedDisputeTx, uint256 signedStakeTxHash, MoMProof momProof); -}; - - - -bool GetOpReturnHash(CScript script, uint256 &hash); - - -#endif /* BETPROTOCOL_H */ diff --git a/src/cc/dilithium.h b/src/cc/dilithium.h deleted file mode 100644 index 91d0a0753..000000000 --- a/src/cc/dilithium.h +++ /dev/null @@ -1,346 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -#include - -#ifndef HUSH_DILITHIUM_H -#define HUSH_DILITHIUM_H - -#define SHAKE128_RATE 168 -#define SHAKE256_RATE 136 - -void shake128_absorb(uint64_t *s, const uint8_t *input, int32_t inlen); -void shake128_squeezeblocks(uint8_t *output, int32_t nblocks, uint64_t *s); -void shake256_absorb(uint64_t *s, const uint8_t *input, int32_t inlen); -void shake256_squeezeblocks(uint8_t *output, int32_t nblocks, uint64_t *s); -void shake128(uint8_t *output, int32_t outlen, const uint8_t *input, int32_t inlen); -void shake256(uint8_t *output, int32_t outlen, const uint8_t *input, int32_t inlen); - -#endif - -#ifndef PARAMS_H -#define PARAMS_H - -#ifndef MODE -#define MODE 3 -#endif - -#define SEEDBYTES 32U -#define CRHBYTES 48U -#define N 256U -#define Q 8380417U -#define QBITS 23U -#define ROOT_OF_UNITY 1753U -#define D 14U -#define GAMMA1 ((Q - 1U)/16U) -#define GAMMA2 (GAMMA1/2U) -#define ALPHA (2U*GAMMA2) - -#if MODE == 0 -#define K 3U -#define L 2U -#define ETA 7U -#define SETABITS 4U -#define BETA 375U -#define OMEGA 64U - -#elif MODE == 1 -#define K 4U -#define L 3U -#define ETA 6U -#define SETABITS 4U -#define BETA 325U -#define OMEGA 80U - -#elif MODE == 2 -#define K 5U -#define L 4U -#define ETA 5U -#define SETABITS 4U -#define BETA 275U -#define OMEGA 96U - -#elif MODE == 3 -#define K 6U -#define L 5U -#define ETA 3U -#define SETABITS 3U -#define BETA 175U -#define OMEGA 120U - -#endif - -#define POL_SIZE_PACKED ((N*QBITS)/8) -#define POLT1_SIZE_PACKED ((N*(QBITS - D))/8) -#define POLT0_SIZE_PACKED ((N*D)/8) -#define POLETA_SIZE_PACKED ((N*SETABITS)/8) -#define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) -#define POLW1_SIZE_PACKED ((N*4)/8) -#define POLVECK_SIZE_PACKED (K*POL_SIZE_PACKED) -#define POLVECL_SIZE_PACKED (L*POL_SIZE_PACKED) - -#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) -#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) -#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) - -#endif -#ifndef POLY_H -#define POLY_H - -//#include -//#include "params.h" -//#include "fips202.h" - -typedef struct { - uint32_t coeffs[N]; -} poly __attribute__((aligned(32))); - -void poly_reduce(poly *a); -void poly_csubq(poly *a); -void poly_freeze(poly *a); - -void poly_add(poly *c, const poly *a, const poly *b); -void poly_sub(poly *c, const poly *a, const poly *b); -void poly_neg(poly *a); -void poly_shiftl(poly *a, uint32_t k); - -void poly_ntt(poly *a); -void poly_invntt_montgomery(poly *a); -void poly_pointwise_invmontgomery(poly *c, const poly *a, const poly *b); - -void poly_power2round(poly *a1, poly *a0, const poly *a); -void poly_decompose(poly *a1, poly *a0, const poly *a); -uint32_t poly_make_hint(poly *h, const poly *a, const poly *b); -void poly_use_hint(poly *a, const poly *b, const poly *h); - -int poly_chknorm(const poly *a, uint32_t B); -void poly_uniform(poly *a, const uint8_t *buf); -void poly_uniform_eta(poly *a, - const uint8_t seed[SEEDBYTES], - uint8_t nonce); -void poly_uniform_gamma1m1(poly *a, - const uint8_t seed[SEEDBYTES + CRHBYTES], - uint16_t nonce); - -void polyeta_pack(uint8_t *r, const poly *a); -void polyeta_unpack(poly *r, const uint8_t *a); - -void polyt1_pack(uint8_t *r, const poly *a); -void polyt1_unpack(poly *r, const uint8_t *a); - -void polyt0_pack(uint8_t *r, const poly *a); -void polyt0_unpack(poly *r, const uint8_t *a); - -void polyz_pack(uint8_t *r, const poly *a); -void polyz_unpack(poly *r, const uint8_t *a); - -void polyw1_pack(uint8_t *r, const poly *a); -#endif -#ifndef POLYVEC_H -#define POLYVEC_H - -//#include -//#include "params.h" -//#include "poly.h" - -/* Vectors of polynomials of length L */ -typedef struct { - poly vec[L]; -} polyvecl; - -void polyvecl_freeze(polyvecl *v); - -void polyvecl_add(polyvecl *w, const polyvecl *u, const polyvecl *v); - -void polyvecl_ntt(polyvecl *v); -void polyvecl_pointwise_acc_invmontgomery(poly *w, - const polyvecl *u, - const polyvecl *v); - -int polyvecl_chknorm(const polyvecl *v, uint32_t B); - - - -/* Vectors of polynomials of length K */ -typedef struct { - poly vec[K]; -} polyveck; - -void polyveck_reduce(polyveck *v); -void polyveck_csubq(polyveck *v); -void polyveck_freeze(polyveck *v); - -void polyveck_add(polyveck *w, const polyveck *u, const polyveck *v); -void polyveck_sub(polyveck *w, const polyveck *u, const polyveck *v); -void polyveck_shiftl(polyveck *v, uint32_t k); - -void polyveck_ntt(polyveck *v); -void polyveck_invntt_montgomery(polyveck *v); - -int polyveck_chknorm(const polyveck *v, uint32_t B); - -void polyveck_power2round(polyveck *v1, polyveck *v0, const polyveck *v); -void polyveck_decompose(polyveck *v1, polyveck *v0, const polyveck *v); -uint32_t polyveck_make_hint(polyveck *h, - const polyveck *u, - const polyveck *v); -void polyveck_use_hint(polyveck *w, const polyveck *v, const polyveck *h); - -#endif - -#ifndef NTT_H -#define NTT_H - -//#include -//#include "params.h" - -void ntt(uint32_t p[N]); -void invntt_frominvmont(uint32_t p[N]); - -#endif -#ifndef PACKING_H -#define PACKING_H - -//#include "params.h" -//#include "polyvec.h" - -void pack_pk(uint8_t pk[CRYPTO_PUBLICKEYBYTES], - const uint8_t rho[SEEDBYTES], const polyveck *t1); -void pack_sk(uint8_t sk[CRYPTO_SECRETKEYBYTES], - const uint8_t rho[SEEDBYTES], - const uint8_t key[SEEDBYTES], - const uint8_t tr[CRHBYTES], - const polyvecl *s1, - const polyveck *s2, - const polyveck *t0); -void pack_sig(uint8_t sig[CRYPTO_BYTES], - const polyvecl *z, const polyveck *h, const poly *c); - -void unpack_pk(uint8_t rho[SEEDBYTES], polyveck *t1, - const uint8_t pk[CRYPTO_PUBLICKEYBYTES]); -void unpack_sk(uint8_t rho[SEEDBYTES], - uint8_t key[SEEDBYTES], - uint8_t tr[CRHBYTES], - polyvecl *s1, - polyveck *s2, - polyveck *t0, - const uint8_t sk[CRYPTO_SECRETKEYBYTES]); -int unpack_sig(polyvecl *z, polyveck *h, poly *c, - const uint8_t sig[CRYPTO_BYTES]); - -#endif -#ifndef REDUCE_H -#define REDUCE_H - -//#include - -#define MONT 4193792U // 2^32 % Q -#define QINV 4236238847U // -q^(-1) mod 2^32 - -/* a <= Q*2^32 => r < 2*Q */ -uint32_t montgomery_reduce(uint64_t a); - -/* r < 2*Q */ -uint32_t reduce32(uint32_t a); - -/* a < 2*Q => r < Q */ -uint32_t csubq(uint32_t a); - -/* r < Q */ -uint32_t freeze(uint32_t a); - -#endif -#ifndef ROUNDING_H -#define ROUNDING_H - -//#include - -uint32_t power2round(const uint32_t a, uint32_t *a0); -uint32_t decompose(uint32_t a, uint32_t *a0); -uint32_t make_hint(const uint32_t a, const uint32_t b); -uint32_t use_hint(const uint32_t a, const uint32_t hint); - -#endif -#ifndef SIGN_H -#define SIGN_H - -//#include "params.h" -//#include "poly.h" -//#include "polyvec.h" - -void expand_mat(polyvecl mat[K], const uint8_t rho[SEEDBYTES]); -void challenge(poly *c, const uint8_t mu[CRHBYTES], - const polyveck *w1); - -int crypto_sign_keypair(uint8_t *pk, uint8_t *sk); - -int crypto_sign(uint8_t *sm, int32_t *smlen, - const uint8_t *msg, int32_t len, - const uint8_t *sk); - -int crypto_sign_open(uint8_t *m, int32_t *mlen, - const uint8_t *sm, int32_t smlen, - const uint8_t *pk); - -#endif - -#ifndef API_H -#define API_H - -#ifndef MODE -#define MODE 3 -#endif - -#if MODE == 0 -#if CRYPTO_PUBLICKEYBYTES -896U -CRYPTO_PUBLICKEYBYTES size error -#endif -#if CRYPTO_SECRETKEYBYTES -2096U -CRYPTO_SECRETKEYBYTES size error -#endif -#if CRYPTO_BYTES -1387U -CRYPTO_BYTES size error -#endif - -#elif MODE == 1 -#if CRYPTO_PUBLICKEYBYTES -1184U -CRYPTO_PUBLICKEYBYTES size error -#endif -#if CRYPTO_SECRETKEYBYTES -2800U -CRYPTO_SECRETKEYBYTES size error -#endif -#if CRYPTO_BYTES -2044U -CRYPTO_BYTES size error -#endif - -#elif MODE == 2 -#if CRYPTO_PUBLICKEYBYTES -1472U -CRYPTO_PUBLICKEYBYTES size error -#endif -#if CRYPTO_SECRETKEYBYTES -3504U -CRYPTO_SECRETKEYBYTES size error -#endif -#if CRYPTO_BYTES -2701U -CRYPTO_BYTES size error -#endif - -#elif MODE == 3 -#if CRYPTO_PUBLICKEYBYTES -1760U -CRYPTO_PUBLICKEYBYTES size error -#endif -#if CRYPTO_SECRETKEYBYTES -3856U -CRYPTO_SECRETKEYBYTES size error -#endif -#if CRYPTO_BYTES -3366U -CRYPTO_BYTES size error -#endif - -#endif - -#define CRYPTO_ALGNAME "Dilithium" - -int crypto_sign_keypair(uint8_t *pk, uint8_t *sk); -int crypto_sign(uint8_t *sm, int32_t *smlen, const uint8_t *msg, int32_t len, const uint8_t *sk); -int crypto_sign_open(uint8_t *m, int32_t *mlen, const uint8_t *sm, int32_t smlen, const uint8_t *pk); - -#endif From 958bc486d4acf4e445a00aeff28098ce012e229a Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 10 Feb 2024 22:37:22 -0500 Subject: [PATCH 04/21] Delete more CCs #381 --- src/cc/CCinclude.h | 40 ------- src/cc/CCtokenutils.cpp | 236 ++-------------------------------------- src/cc/CCutils.cpp | 121 ++------------------ src/cc/customcc.cpp | 22 +--- src/script/cc.cpp | 40 +------ 5 files changed, 21 insertions(+), 438 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 3af9e0711..9846939fb 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -18,41 +18,6 @@ #ifndef CC_INCLUDE_H #define CC_INCLUDE_H -/*! \file CCinclude.h -\brief Cryptoconditions - -CCs for teh lulz - -*/ - -/// \mainpage Brief introduction into cryptocondition contracts -/// There are only a very few types in bitcoin: pay to pubkey, pay to pubkey hash and pay to script hash (p2pk, p2pkh, p2sh). -/// There are actually more that are possible, but those three are 99%+ of bitcoin transactions. -/// So you can pay to a pubkey, or to its hash or to a script's hash. The last is how most of the more complex scripts are invoked. To spend a p2sh vout, you need to provide the redeemscript, -/// this script's hash is what the p2sh address was. -/// All of the above are the standard bitcoin vout types and there should be plenty of materials about it. -/// -/// Cryptoconditions (CC) contracts created a fourth type of vout, the CC vout. This is using the cryptoconditions standard and it is even a different signature mechanism, -/// ed25519 instead of secp256k1. It is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. -/// -/// But it gets more interesting. Each CC script has an evalcode. -/// This is just an arbitrary number but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is -/// how a faucet CC contract differentiates itself from a dice CC contract, the eval code is different. -/// -/// One effect from using a different eval code is that even if the rest of the CC script is the same, the bitcoin address that is calculated is different. -/// What this means is that for each pubkey, there is a unique address for each different eval code! -/// And this allows efficient segregation of one CC contracts transactions from another. -/// The final part that will make it all clear how the funds can be locked inside the contract. -/// This is what makes a contract, a contract. -/// I put both the privkey and pubkey for a randomly chosen address and associate it with each CC contract. -/// That means anybody can sign outputs for that privkey. -/// However, it is a CC output, so in addition to the signature, whatever constraints a CC contract implements must also be satistifed. -/// This allows funds to be locked and yet anybody is able to spend it, assuming they satisfy the CC's rules. -/// -/// One other technical note is that Hush has the insight-explorer extensions built in -/// so it can lookup directly all transactions to any address. -/// This is a key performance boosting thing as if it wasnt there, trying to get all the utxo for an address not in the wallet is quite time consuming. -/// #include #include