From 751cdbc2afb756f4f4ee709a27d4d806fc47c802 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 22 Jul 2018 02:59:11 -1100 Subject: [PATCH] Test --- src/cc/CCassets.h | 1 - src/cc/CCcustom.cpp | 4 +++- src/cc/eval.cpp | 5 +++-- src/cc/eval.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 6dd8265a7..d7f6a13f4 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -29,7 +29,6 @@ extern const char *AssetsCCaddr; extern char AssetsCChexstr[67]; // CCassetsCore -CC *MakeAssetCond(CPubKey pk); CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk); CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description); CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,uint64_t price,std::vector origpubkey); diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 551706759..3a46d0da5 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -19,7 +19,8 @@ CCcustom has most of the functions that need to be extended to create a new CC contract. EVAL_CONTRACT is the naming convention and it should be added to cc/eval.h - + bool Eval::Dispatch() in cc/eval.h needs to add the validation function in the switch + 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. @@ -32,6 +33,7 @@ const char *AssetsCCaddr = "RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6" ;//"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 }; +CC *MakeAssetCond(CPubKey pk); CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv) { diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 6f3a5827e..2f77ced1a 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -69,8 +69,9 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) case EVAL_IMPORTCOIN: return ImportCoin(vparams, txTo, nIn); break; - default: - return ProcessCCevals(ecode,this,vparams,txTo,nIn); + + case EVAL_ASSETS: + return ProcessAssets(this, vparams, txTo, nIn); break; } return Invalid("invalid-code"); diff --git a/src/cc/eval.h b/src/cc/eval.h index 79262edb6..96af359f1 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -266,7 +266,7 @@ typedef std::pair TxProof; uint256 GetMerkleRoot(const std::vector& vLeaves); -bool ProcessCCevals(uint8_t evalcode,Eval* eval, std::vector paramsNull,const CTransaction &ctx, unsigned int nIn); +bool ProcessAssets(Eval* eval, std::vector paramsNull, const CTransaction &tx, unsigned int nIn); #endif /* CC_EVAL_H */