From 65505b3d55a6f86439b8cd193dd0a83bf62fa9bd Mon Sep 17 00:00:00 2001 From: kkurokawa Date: Fri, 5 Aug 2016 11:47:20 -0400 Subject: [PATCH] Adding claimtrie script generation functions --- src/nameclaim.cpp | 23 +++++++++++++++++++++++ src/nameclaim.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/nameclaim.cpp b/src/nameclaim.cpp index 292123992..f3d2978d0 100644 --- a/src/nameclaim.cpp +++ b/src/nameclaim.cpp @@ -25,6 +25,29 @@ uint32_t vch_to_uint32_t(std::vector& vchN) return n; } +CScript ClaimNameScript(std::string name, std::string value) +{ + std::vector vchName(name.begin(), name.end()); + std::vector vchValue(value.begin(), value.end()); + return CScript() << OP_CLAIM_NAME << vchName << vchValue << OP_2DROP << OP_DROP << OP_TRUE; + +} +CScript SupportClaimScript(std::string name, uint160 claimId) +{ + std::vector vchName(name.begin(), name.end()); + std::vector vchClaimId(claimId.begin(),claimId.end()); + return CScript() << OP_SUPPORT_CLAIM << vchName << vchClaimId << OP_2DROP << OP_DROP << OP_TRUE; +} +CScript UpdateClaimScript(std::string name, uint160 claimId, std::string value) +{ + std::vector vchName(name.begin(), name.end()); + std::vector vchClaimId(claimId.begin(),claimId.end()); + std::vector vchValue(value.begin(), value.end()); + return CScript() << OP_UPDATE_CLAIM << vchName << vchClaimId << vchValue << OP_2DROP << OP_2DROP << OP_TRUE; + +} + + bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector >& vvchParams) { CScript::const_iterator pc = scriptIn.begin(); diff --git a/src/nameclaim.h b/src/nameclaim.h index 8c0144b86..6821af470 100644 --- a/src/nameclaim.h +++ b/src/nameclaim.h @@ -14,6 +14,9 @@ // Scripts exceeding this size are rejected in CheckTransaction in main.cpp #define MAX_CLAIM_NAME_SIZE 255 +CScript ClaimNameScript(std::string name, std::string value); +CScript SupportClaimScript(std::string name, uint160 claimId); +CScript UpdateClaimScript(std::string name, uint160 claimId, std::string value); bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector >& vvchParams); bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector >& vvchParams, CScript::const_iterator& pc); CScript StripClaimScriptPrefix(const CScript& scriptIn); @@ -26,4 +29,5 @@ size_t ClaimScriptSize(const CScript& scriptIn); // get size of the name in a claim script, returns 0 if scriptin is not a claimetrie transaction size_t ClaimNameSize(const CScript& scriptIn); + #endif // BITCOIN_NAMECLAIM_H