Compare commits

..
Author SHA1 Message Date
Alex Grintsvayg f288fac940 Bump version: 0.3.15 → 0.3.16 2016-10-13 16:07:25 -04:00
Alex Grintsvayg 7308f24663 get bumpversion back on track 2016-10-13 16:07:17 -04:00
Alex Grin 5a83924245 Merge pull request #47 from lbryio/new_seed_nodes
update fixed seed nodes
2016-10-13 16:05:28 -04:00
Alex Grintsvayg df5f764d52 add testnet dns seeds 2016-10-13 15:46:14 -04:00
Alex Grintsvayg c8199b158d update fixed seed nodes 2016-10-12 20:25:21 -04:00
Alex Grintsvayg 270307a290 license 2016-09-13 22:10:35 -04:00
James Kiselak 0d0d7c5320 Merge pull request #37 from kaykurokawa/bump_version
update version
2016-08-26 18:38:25 -04:00
Alex Grintsvayg e7eaf46f3c bumpversion 2016-08-25 19:14:44 -04:00
James Kiselak fa505b789a Merge pull request #38 from kaykurokawa/new_basic_tests
New basic tests
2016-08-17 21:09:47 -04:00
kkurokawa 1b80858a44 adding test to check the POW algorithm 2016-08-10 21:04:04 -04:00
kkurokawa e0089d19f2 adding test for block with bogus claim trie hash 2016-08-10 16:45:36 -04:00
kkurokawa e4481fc213 update version 2016-08-08 19:12:30 -04:00
Job Evers-Meltzer 083a4a1b88 Change build timeout to 40 minutes 2016-08-08 10:58:58 -05:00
Job Evers-Meltzer cbb6acd75c travis fix: only output last 1000 lines on error 2016-08-08 10:02:46 -05:00
Jack Robison 774246d16f Merge pull request #15 from jimmykiselak/claimid_rpc_updates
Claimid rpc updates
2016-08-06 21:25:33 -04:00
Job Evers‐Meltzer 3e26b5f342 Merge pull request #31 from lbryio/build-windows
add windows build to travis
2016-08-03 14:58:25 -05:00
James Kiselak 93eb2e3c47 Merge pull request #1 from kaykurokawa/claimid_rpc_updates_fix
patch for https://github.com/lbryio/lbrycrd/pull/15
2016-08-01 21:47:25 -04:00
kkurokawa ec3801f07a fixing listclaimnames not showing supports, updating help messages for rpc commands 2016-08-01 21:31:20 -04:00
Job Evers 2df151e325 add windows build to travis
Compiles lbrycrdd using mingw to produce a windows executable
2016-07-29 15:12:46 -05:00
Jimmy Kiselak a186aaa073 put useful documentation, also report the last takeover height 2016-07-18 23:29:41 -04:00
Jimmy Kiselak 80bb42c912 make getclaimsforname show useful info and group together supports 2016-07-18 22:37:30 -04:00
Jimmy Kiselak e713501a5d start making getclaimsforname rpc command 2016-07-14 23:11:31 -04:00
Jimmy Kiselak 0551e881f5 fix supports and fix printing of claimid and value for updates 2016-07-11 23:37:17 -04:00
Jimmy Kiselak 31008a84b2 begin updating wallet rpc to use claimids 2016-07-11 00:08:01 -04:00
14 changed files with 445 additions and 66 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
[bumpversion]
current_version = 0.3.16
commit = True
tag = True
+15
View File
@@ -0,0 +1,15 @@
The MIT License (MIT)
Copyright (c) 2015-2016 LBRY Inc
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+2 -2
View File
@@ -1,2 +1,2 @@
45.32.39.241:9246
45.32.40.180:9246
138.68.198.142:9246
138.197.224.252:9246
+1 -1
View File
@@ -1,6 +1,6 @@
# List of fixed seed nodes for testnet
45.32.39.241:19246
159.203.154.219:19246
# Onion nodes
#thfsmmn2jbitcoin.onion
+16 -11
View File
@@ -19,7 +19,7 @@ function HELP {
echo "-r: remove intermediate files."
echo "-l: build only lbrycrd"
echo "-d: build only the dependencies"
echo "-o: timeout build after 45 minutes"
echo "-o: timeout build after 40 minutes"
echo "-t: turn trace on"
echo "-h: show help"
exit 1
@@ -31,6 +31,9 @@ BUILD_DEPENDENCIES=true
BUILD_LBRYCRD=true
TIMEOUT=false
THREE_MB=3145728
# this flag gets set to False if
# the script exits due to a timeout
OUTPUT_LOG=true
while getopts :crldoth:w:d: FLAG; do
case $FLAG in
@@ -104,18 +107,19 @@ fi
NEXT_TIME=60
function exit_at_45() {
function exit_at_40() {
if [ -f "${START_TIME_FILE}" ]; then
NOW=$(date +%s)
START=$(cat "${START_TIME_FILE}")
TIMEOUT_SECS=2700 # 45 * 60
TIMEOUT_SECS=2400 # 40 * 60
TIME=$((NOW - START))
if (( TIME > NEXT_TIME )); then
echo "Build has taken $((TIME / 60)) minutes: $1"
NEXT_TIME=$((TIME + 60))
fi
if [ "$TIMEOUT" = true ] && (( TIME > TIMEOUT_SECS )); then
echo 'Exiting at 45 minutes to allow the cache to populate'
echo 'Exiting at 40 minutes to allow the cache to populate'
OUTPUT_LOG=false
exit 1
fi
fi
@@ -136,7 +140,7 @@ function wait_and_echo() {
# loop until the process is no longer running
# check every $SLEEP seconds, echoing a message every minute
while (ps -p "${PID}" > /dev/null); do
exit_at_45 "$2"
exit_at_40 "$2"
sleep "${SLEEP}"
done
# restore the xtrace setting
@@ -159,11 +163,11 @@ function background() {
function cleanup() {
rv=$?
# cat the log file if it exists
if [ -f "$2" ]; then
if [ -f "$2" ] && [ "${OUTPUT_LOG}" = true ]; then
echo
echo "Output of log file $2"
echo
tail -c $THREE_MB "$1"
tail -n 1000 "$2"
echo
fi
# delete the build directory
@@ -175,14 +179,15 @@ function cleanup() {
function cat_and_exit() {
rv=$?
# cat the log file if it exists
if [ -f "$1" ]; then
if [ -f "$1" ] && [ "${OUTPUT_LOG}" = true ]; then
echo
echo "Output of log file $1"
echo
# log size is limited to 4MB on travis
# so hopefully the last 3MB is enough
# This used to be the last 3MB but outputing that
# caused problems on travis.
# Hopefully the last 1000 lines is enough
# to debug whatever went wrong
tail -c $THREE_MB "$1"
tail -n 1000 "$1"
echo
fi
exit $rv
+4 -5
View File
@@ -126,8 +126,8 @@ public:
consensus.nMajorityEnforceBlockUpgrade = 750;
consensus.nMajorityRejectBlockOutdated = 950;
consensus.nMajorityWindow = 1000;
consensus.BIP34Height = 1;
consensus.BIP34Hash = uint256S("0xdecb9e2cca03a419fd9cca0cb2b1d5ad11b088f22f8f38556d93ac4358b86c24");
consensus.BIP34Height = 1;
consensus.BIP34Hash = uint256S("0xdecb9e2cca03a419fd9cca0cb2b1d5ad11b088f22f8f38556d93ac4358b86c24");
consensus.powLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 150; //retarget every block
consensus.nPowTargetSpacing = 150;
@@ -247,9 +247,8 @@ public:
vFixedSeeds.clear();
vSeeds.clear();
//vSeeds.push_back(CDNSSeedData("bitcoin.petertodd.org", "testnet-seed.bitcoin.petertodd.org"));
//vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me"));
//vSeeds.push_back(CDNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de"));
vSeeds.push_back(CDNSSeedData("lbry.io", "testdnsseed1.lbry.io"));
vSeeds.push_back(CDNSSeedData("lbry.io", "testdnsseed2.lbry.io"));
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
+3 -3
View File
@@ -8,11 +8,11 @@
* IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.
*/
static SeedSpec6 pnSeed6_main[] = {
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x20,0x27,0xf1}, 9246},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x20,0x28,0xb4}, 9246}
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x8a,0x44,0xc6,0x8e}, 9246},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x8a,0xc5,0xe0,0xfc}, 9246}
};
static SeedSpec6 pnSeed6_test[] = {
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x20,0x27,0xf1}, 19246}
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x9f,0xcb,0x9a,0xdb}, 19246}
};
#endif // BITCOIN_CHAINPARAMSSEEDS_H
+67
View File
@@ -458,6 +458,73 @@ bool CClaimTrie::getLastTakeoverForName(const std::string& name, int& lastTakeov
return false;
}
claimsForNameType CClaimTrie::getClaimsForName(const std::string& name) const
{
std::vector<CClaimValue> claims;
std::vector<CSupportValue> supports;
int nLastTakeoverHeight = 0;
const CClaimTrieNode* current = getNodeForName(name);
if (current)
{
if (!current->claims.empty())
{
nLastTakeoverHeight = current->nHeightOfLastTakeover;
}
for (std::vector<CClaimValue>::const_iterator itClaims = current->claims.begin(); itClaims != current->claims.end(); ++itClaims)
{
claims.push_back(*itClaims);
}
}
supportMapEntryType supportNode;
if (getSupportNode(name, supportNode))
{
for (std::vector<CSupportValue>::const_iterator itSupports = supportNode.begin(); itSupports != supportNode.end(); ++itSupports)
{
supports.push_back(*itSupports);
}
}
queueNameRowType namedClaimRow;
if (getQueueNameRow(name, namedClaimRow))
{
for (queueNameRowType::const_iterator itClaimsForName = namedClaimRow.begin(); itClaimsForName != namedClaimRow.end(); ++itClaimsForName)
{
claimQueueRowType claimRow;
if (getQueueRow(itClaimsForName->nHeight, claimRow))
{
for (claimQueueRowType::const_iterator itClaimRow = claimRow.begin(); itClaimRow != claimRow.end(); ++itClaimRow)
{
if (itClaimRow->first == name && itClaimRow->second.outPoint == itClaimsForName->outPoint)
{
claims.push_back(itClaimRow->second);
break;
}
}
}
}
}
queueNameRowType namedSupportRow;
if (getSupportQueueNameRow(name, namedSupportRow))
{
for (queueNameRowType::const_iterator itSupportsForName = namedSupportRow.begin(); itSupportsForName != namedSupportRow.end(); ++itSupportsForName)
{
supportQueueRowType supportRow;
if (getSupportQueueRow(itSupportsForName->nHeight, supportRow))
{
for (supportQueueRowType::const_iterator itSupportRow = supportRow.begin(); itSupportRow != supportRow.end(); ++itSupportRow)
{
if (itSupportRow->first == name && itSupportRow->second.outPoint == itSupportsForName->outPoint)
{
supports.push_back(itSupportRow->second);
break;
}
}
}
}
}
claimsForNameType allClaims(claims, supports, nLastTakeoverHeight);
return allClaims;
}
bool CClaimTrie::checkConsistency() const
{
if (empty())
+12
View File
@@ -265,6 +265,16 @@ typedef std::map<std::string, CClaimTrieNode*, nodenamecompare> nodeCacheType;
typedef std::map<std::string, uint256> hashMapType;
struct claimsForNameType
{
std::vector<CClaimValue> claims;
std::vector<CSupportValue> supports;
int nLastTakeoverHeight;
claimsForNameType(std::vector<CClaimValue> claims, std::vector<CSupportValue> supports, int nLastTakeoverHeight)
: claims(claims), supports(supports), nLastTakeoverHeight(nLastTakeoverHeight) {}
};
class CClaimTrieCache;
class CClaimTrie
@@ -290,6 +300,8 @@ public:
std::vector<namedNodeType> flattenTrie() const;
bool getInfoForName(const std::string& name, CClaimValue& claim) const;
bool getLastTakeoverForName(const std::string& name, int& lastTakeoverHeight) const;
claimsForNameType getClaimsForName(const std::string& name) const;
bool queueEmpty() const;
bool supportEmpty() const;
+2 -2
View File
@@ -16,8 +16,8 @@
//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 12
#define CLIENT_VERSION_REVISION 99
#define CLIENT_VERSION_BUILD 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 1
//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE false
+190 -20
View File
@@ -123,6 +123,41 @@ UniValue getclaimtrie(const UniValue& params, bool fHelp)
return ret;
}
bool getValueForClaim(const COutPoint& out, std::string& sValue)
{
CCoinsViewCache view(pcoinsTip);
const CCoins* coin = view.AccessCoins(out.hash);
if (!coin)
{
LogPrintf("%s: %s does not exist in the coins view, despite being associated with a name\n",
__func__, out.hash.GetHex());
return true;
}
if (coin->vout.size() < out.n || coin->vout[out.n].IsNull())
{
LogPrintf("%s: the specified txout of %s appears to have been spent\n", __func__, out.hash.GetHex());
return true;
}
int op;
std::vector<std::vector<unsigned char> > vvchParams;
if (!DecodeClaimScript(coin->vout[out.n].scriptPubKey, op, vvchParams))
{
LogPrintf("%s: the specified txout of %s does not have a name claim command\n", __func__, out.hash.GetHex());
return false;
}
if (op == OP_CLAIM_NAME)
{
sValue = std::string(vvchParams[1].begin(), vvchParams[1].end());
}
else if (op == OP_UPDATE_CLAIM)
{
sValue = std::string(vvchParams[2].begin(), vvchParams[2].end());
}
return true;
}
UniValue getvalueforname(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
@@ -145,27 +180,9 @@ UniValue getvalueforname(const UniValue& params, bool fHelp)
UniValue ret(UniValue::VOBJ);
if (!pclaimTrie->getInfoForName(name, claim))
return ret;
CCoinsViewCache view(pcoinsTip);
const CCoins* coin = view.AccessCoins(claim.outPoint.hash);
if (!coin)
{
LogPrintf("%s: %s does not exist in the coins view, despite being associated with a name\n",
__func__, claim.outPoint.hash.GetHex());
std::string sValue;
if (!getValueForClaim(claim.outPoint, sValue))
return ret;
}
if (coin->vout.size() < claim.outPoint.n || coin->vout[claim.outPoint.n].IsNull())
{
LogPrintf("%s: the specified txout of %s appears to have been spent\n", __func__, claim.outPoint.hash.GetHex());
return ret;
}
int op;
std::vector<std::vector<unsigned char> > vvchParams;
if (!DecodeClaimScript(coin->vout[claim.outPoint.n].scriptPubKey, op, vvchParams))
{
LogPrintf("%s: the specified txout of %s does not have a name claim command\n", __func__, claim.outPoint.hash.GetHex());
}
std::string sValue(vvchParams[1].begin(), vvchParams[1].end());
ret.push_back(Pair("value", sValue));
ret.push_back(Pair("txid", claim.outPoint.hash.GetHex()));
ret.push_back(Pair("n", (int)claim.outPoint.n));
@@ -175,6 +192,158 @@ UniValue getvalueforname(const UniValue& params, bool fHelp)
return ret;
}
typedef std::pair<CClaimValue, std::vector<CSupportValue> > claimAndSupportsType;
typedef std::map<uint160, claimAndSupportsType> claimSupportMapType;
typedef std::map<uint160, std::vector<CSupportValue> > supportsWithoutClaimsMapType;
UniValue claimsAndSupportsToJSON(claimSupportMapType::const_iterator itClaimsAndSupports, int nCurrentHeight)
{
UniValue ret(UniValue::VOBJ);
const CClaimValue claim = itClaimsAndSupports->second.first;
const std::vector<CSupportValue> supports = itClaimsAndSupports->second.second;
CAmount nEffectiveAmount = 0;
UniValue supportObjs(UniValue::VARR);
for (std::vector<CSupportValue>::const_iterator itSupports = supports.begin(); itSupports != supports.end(); ++itSupports)
{
UniValue supportObj(UniValue::VOBJ);
supportObj.push_back(Pair("txid", itSupports->outPoint.hash.GetHex()));
supportObj.push_back(Pair("n", (int)itSupports->outPoint.n));
supportObj.push_back(Pair("nHeight", itSupports->nHeight));
supportObj.push_back(Pair("nValidAtHeight", itSupports->nValidAtHeight));
if (itSupports->nValidAtHeight < nCurrentHeight)
{
nEffectiveAmount += itSupports->nAmount;
}
supportObj.push_back(Pair("nAmount", itSupports->nAmount));
supportObjs.push_back(supportObj);
}
ret.push_back(Pair("claimId", itClaimsAndSupports->first.GetHex()));
ret.push_back(Pair("txid", claim.outPoint.hash.GetHex()));
ret.push_back(Pair("n", (int)claim.outPoint.n));
ret.push_back(Pair("nHeight", claim.nHeight));
ret.push_back(Pair("nValidAtHeight", claim.nValidAtHeight));
if (claim.nValidAtHeight < nCurrentHeight)
{
nEffectiveAmount += claim.nAmount;
}
ret.push_back(Pair("nAmount", claim.nAmount));
std::string sValue;
if (getValueForClaim(claim.outPoint, sValue))
{
ret.push_back(Pair("value", sValue));
}
ret.push_back(Pair("nEffectiveAmount", nEffectiveAmount));
ret.push_back(Pair("supports", supportObjs));
return ret;
}
UniValue supportsWithoutClaimsToJSON(supportsWithoutClaimsMapType::const_iterator itSupportsWithoutClaims, int nCurrentHeight)
{
const std::vector<CSupportValue> supports = itSupportsWithoutClaims->second;
UniValue ret(UniValue::VOBJ);
UniValue supportObjs(UniValue::VARR);
ret.push_back(Pair("claimId (no matching claim)", itSupportsWithoutClaims->first.GetHex()));
for (std::vector<CSupportValue>::const_iterator itSupports = supports.begin(); itSupports != supports.end(); ++itSupports)
{
UniValue supportObj(UniValue::VOBJ);
supportObj.push_back(Pair("txid", itSupports->outPoint.hash.GetHex()));
supportObj.push_back(Pair("n", (int)itSupports->outPoint.n));
supportObj.push_back(Pair("nHeight", itSupports->nHeight));
supportObj.push_back(Pair("nValidAtHeight", itSupports->nValidAtHeight));
supportObj.push_back(Pair("nAmount", itSupports->nAmount));
supportObjs.push_back(supportObj);
}
ret.push_back(Pair("supports", supportObjs));
return ret;
}
UniValue getclaimsforname(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw std::runtime_error(
"getclaimsforname\n"
"Return all claims and supports for a name\n"
"Arguments: \n"
"1. \"name\" (string) the name for which to get claims and supports\n"
"Result:\n"
"{\n"
" \"nLastTakeoverheight\" (numeric) the last height at which ownership of the name changed\n"
" \"claims\": [ (array of object) claims for this name\n"
" {\n"
" \"claimId\" (string) the claimId of this claim\n"
" \"txid\" (string) the txid of this claim\n"
" \"n\" (numeric) the index of the claim in the transaction's list of outputs\n"
" \"nHeight\" (numeric) the height at which the claim was included in the blockchain\n"
" \"nValidAtHeight\" (numeric) the height at which the claim became/becomes valid\n"
" \"nAmount\" (numeric) the amount of the claim\n"
" \"nEffectiveAmount\" (numeric) the total effective amount of the claim, taking into effect whether the claim or support has reached its nValidAtHeight\n"
" \"supports\" : [ (array of object) supports for this claim\n"
" \"txid\" (string) the txid of the support\n"
" \"n\" (numeric) the index of the support in the transaction's list of outputs\n"
" \"nHeight\" (numeric) the height at which the support was included in the blockchain\n"
" \"nValidAtHeight\" (numeric) the height at which the support became/becomes valid\n"
" \"nAmount\" (numeric) the amount of the support\n"
" ]\n"
" }\n"
" ],\n"
" \"unmatched supports\": [ (array of object) supports that did not match a claim for this name\n"
" {\n"
" \"txid\" (string) the txid of the support\n"
" \"n\" (numeric) the index of the support in the transaction's list of outputs\n"
" \"nHeight\" (numeric) the height at which the support was included in the blockchain\n"
" \"nValidAtHeight\" (numeric) the height at which the support became/becomes valid\n"
" \"nAmount\" (numeric) the amount of the support\n"
" }\n"
" ]\n"
"}\n"
);
LOCK(cs_main);
std::string name = params[0].get_str();
claimsForNameType claimsForName = pclaimTrie->getClaimsForName(name);
int nCurrentHeight = chainActive.Height();
claimSupportMapType claimSupportMap;
supportsWithoutClaimsMapType supportsWithoutClaims;
for (std::vector<CClaimValue>::const_iterator itClaims = claimsForName.claims.begin(); itClaims != claimsForName.claims.end(); ++itClaims)
{
claimAndSupportsType claimAndSupports = std::make_pair(*itClaims, std::vector<CSupportValue>());
claimSupportMap.insert(std::pair<uint160, claimAndSupportsType>(itClaims->claimId, claimAndSupports));
}
for (std::vector<CSupportValue>::const_iterator itSupports = claimsForName.supports.begin(); itSupports != claimsForName.supports.end(); ++itSupports)
{
claimSupportMapType::iterator itClaimAndSupports = claimSupportMap.find(itSupports->supportedClaimId);
if (itClaimAndSupports == claimSupportMap.end())
{
std::pair<supportsWithoutClaimsMapType::iterator, bool> ret = supportsWithoutClaims.insert(std::pair<uint160, std::vector<CSupportValue> >(itSupports->supportedClaimId, std::vector<CSupportValue>()));
ret.first->second.push_back(*itSupports);
}
else
{
itClaimAndSupports->second.second.push_back(*itSupports);
}
}
UniValue ret(UniValue::VOBJ);
UniValue claimObjs(UniValue::VARR);
ret.push_back(Pair("nLastTakeoverHeight", claimsForName.nLastTakeoverHeight));
for (claimSupportMapType::const_iterator itClaimsAndSupports = claimSupportMap.begin(); itClaimsAndSupports != claimSupportMap.end(); ++itClaimsAndSupports)
{
UniValue claimAndSupportsObj = claimsAndSupportsToJSON(itClaimsAndSupports, nCurrentHeight);
claimObjs.push_back(claimAndSupportsObj);
}
ret.push_back(Pair("claims", claimObjs));
UniValue unmatchedSupports(UniValue::VARR);
for (supportsWithoutClaimsMapType::const_iterator itSupportsWithoutClaims = supportsWithoutClaims.begin(); itSupportsWithoutClaims != supportsWithoutClaims.end(); ++itSupportsWithoutClaims)
{
UniValue supportsObj = supportsWithoutClaimsToJSON(itSupportsWithoutClaims, nCurrentHeight);
unmatchedSupports.push_back(supportsObj);
}
ret.push_back(Pair("supports without claims", unmatchedSupports));
return ret;
}
UniValue gettotalclaimednames(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
@@ -529,6 +698,7 @@ static const CRPCCommand commands[] =
{ "Claimtrie", "getclaimsintrie", &getclaimsintrie, true },
{ "Claimtrie", "getclaimtrie", &getclaimtrie, true },
{ "Claimtrie", "getvalueforname", &getvalueforname, true },
{ "Claimtrie", "getclaimsforname", &getclaimsforname, true },
{ "Claimtrie", "gettotalclaimednames", &gettotalclaimednames, true },
{ "Claimtrie", "gettotalclaims", &gettotalclaims, true },
{ "Claimtrie", "gettotalvalueofclaims", &gettotalvalueofclaims, true },
+59
View File
@@ -2768,5 +2768,64 @@ BOOST_AUTO_TEST_CASE(claimtrievalue_proof)
}
// Check that blocks with bogus calimtrie hash is rejected
BOOST_AUTO_TEST_CASE(bogus_claimtrie_hash)
{
fRequireStandard = false;
BOOST_CHECK(pclaimTrie->nCurrentHeight = chainActive.Height() + 1);
LOCK(cs_main);
std::string sName("test");
std::string sValue1("test");
std::vector<unsigned char> vchName(sName.begin(), sName.end());
std::vector<unsigned char> vchValue1(sValue1.begin(), sValue1.end());
std::vector<CTransaction> coinbases;
BOOST_CHECK(CreateCoinbases(3, coinbases));
int orig_chain_height = chainActive.Height();
CMutableTransaction tx1 = BuildTransaction(coinbases[0]);
tx1.vout[0].scriptPubKey = CScript() << OP_CLAIM_NAME << vchName << vchValue1 << OP_2DROP << OP_DROP << OP_TRUE;
tx1.vout[0].nValue = 1;
COutPoint tx1OutPoint(tx1.GetHash(), 0);
AddToMempool(tx1);
CBlockTemplate *pblockTemp;
BOOST_CHECK(pblockTemp = CreateNewBlock(Params(), scriptPubKey));
pblockTemp->block.hashPrevBlock = chainActive.Tip()->GetBlockHash();
pblockTemp->block.nVersion = 1;
pblockTemp->block.nTime = chainActive.Tip()->GetBlockTime()+Params().GetConsensus().nPowTargetSpacing;
CMutableTransaction txCoinbase(pblockTemp->block.vtx[0]);
txCoinbase.vin[0].scriptSig = CScript() << CScriptNum(chainActive.Height());
txCoinbase.vout[0].nValue = GetBlockSubsidy(chainActive.Height() + 1, Params().GetConsensus());
pblockTemp->block.vtx[0] = CTransaction(txCoinbase);
pblockTemp->block.hashMerkleRoot = BlockMerkleRoot(pblockTemp->block);
//create bogus hash
uint256 bogusHashClaimTrie;
bogusHashClaimTrie.SetHex("aaa");
pblockTemp->block.hashClaimTrie = bogusHashClaimTrie;
for (int i = 0; ; ++i)
{
pblockTemp->block.nNonce = i;
if (CheckProofOfWork(pblockTemp->block.GetPoWHash(), pblockTemp->block.nBits, Params().GetConsensus()))
{
break;
}
}
CValidationState state;
bool success = ProcessNewBlock(state, Params(), NULL, &pblockTemp->block, true, NULL);
// will process , but will not be connected
BOOST_CHECK(success);
BOOST_CHECK(state.IsValid());
BOOST_CHECK(pblockTemp->block.GetHash() != chainActive.Tip()->GetBlockHash());
BOOST_CHECK_EQUAL(orig_chain_height,chainActive.Height());
delete pblockTemp;
}
BOOST_AUTO_TEST_SUITE_END()
+30
View File
@@ -3,6 +3,7 @@
#include "lbry.h"
#include "main.h"
#include "test/test_bitcoin.h"
#include "hash.h"
#include <cstdio>
#include <boost/test/unit_test.hpp>
@@ -95,6 +96,35 @@ BOOST_AUTO_TEST_CASE(pow_limit_check)
}
boost::test_tools::predicate_result
check_powhash_equals(std::string test_string,std::string expected_hash_hex)
{
std::vector<unsigned char> test_vect(test_string.begin(),test_string.end());
uint256 expected;
expected.SetHex(expected_hash_hex);
uint256 hash = PoWHash(test_vect);
//std::cout<<"hash :"<<hash.ToString()<<"\n";
if (hash == expected){
return true;
}
else
{
boost::test_tools::predicate_result res( false );
res.message() << "Hash of " << test_string << " != " << expected_hash_hex;
return res;
}
}
BOOST_AUTO_TEST_CASE(lbry_pow_test)
{
BOOST_CHECK(check_powhash_equals("test string","485f3920d48a0448034b0852d1489cfa475341176838c7d36896765221be35ce"));
BOOST_CHECK(check_powhash_equals(std::string(70,'a'),"eb44af2f41e7c6522fb8be4773661be5baa430b8b2c3a670247e9ab060608b75"));
BOOST_CHECK(check_powhash_equals(std::string(140,'d'),"74044747b7c1ff867eb09a84d026b02d8dc539fb6adcec3536f3dfa9266495d9"));
}
+39 -22
View File
@@ -442,7 +442,7 @@ UniValue claimname(const UniValue& params, bool fHelp)
}
void UpdateName(const std::vector<unsigned char> vchName, const std::vector<unsigned char> vchValue, CAmount nAmount, CWalletTx& wtxNew, CWalletTx wtxIn, unsigned int nTxOut)
void UpdateName(const std::vector<unsigned char> vchName, const uint160 claimId, const std::vector<unsigned char> vchValue, CAmount nAmount, CWalletTx& wtxNew, CWalletTx wtxIn, unsigned int nTxOut)
{
// Check amount
if (nAmount <= 0)
@@ -464,8 +464,9 @@ void UpdateName(const std::vector<unsigned char> vchName, const std::vector<unsi
if (!pwalletMain->GetKeyFromPool(newKey))
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
std::vector<unsigned char> vchClaimId(claimId.begin(), claimId.end());
CScript scriptPubKey = GetScriptForDestination(CTxDestination(newKey.GetID()));
CScript claimScript = CScript() << OP_CLAIM_NAME << vchName << vchValue << OP_2DROP << OP_DROP;
CScript claimScript = CScript() << OP_UPDATE_CLAIM << vchName << vchClaimId << vchValue << OP_2DROP << OP_2DROP;
claimScript = claimScript + scriptPubKey;
vector<CRecipient> vecSend;
@@ -501,7 +502,7 @@ UniValue updateclaim(const UniValue& params, bool fHelp)
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction containing the unspent txout which should be spent.\n"
"2. \"value\" (string, required) The value to assign to the name.\n"
"3. \"amount\" (numeric, required) The amount in LBRYcrd to send. eg 0.1\n"
"3. \"amount\" (numeric, required) The amount in LBRYcrd to use to bid for the name. eg 0.1\n"
"\nResult:\n"
"\"transactionid\" (string) The new transaction id.\n"
);
@@ -523,6 +524,7 @@ UniValue updateclaim(const UniValue& params, bool fHelp)
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
int op;
std::vector<std::vector<unsigned char> > vvchParams;
uint160 claimId;
CWalletTx wtxNew;
bool fFound = false;
for (unsigned int i = 0; !fFound && i < wtx.vout.size(); i++)
@@ -533,7 +535,15 @@ UniValue updateclaim(const UniValue& params, bool fHelp)
{
vchName = vvchParams[0];
EnsureWalletIsUnlocked();
UpdateName(vchName, vchValue, nAmount, wtxNew, wtx, i);
if (op == OP_CLAIM_NAME)
{
claimId = ClaimIdHash(wtx.GetHash(), i);
}
else if (op == OP_UPDATE_CLAIM)
{
claimId = uint160(vvchParams[1]);
}
UpdateName(vchName, claimId, vchValue, nAmount, wtxNew, wtx, i);
fFound = true;
}
}
@@ -668,7 +678,8 @@ void ListNameClaims(const CWalletTx& wtx, const string& strAccount, int nMinDept
LogPrintf("%s(): Txout classified as name claim could not be decoded. Txid: %s", __func__, wtx.GetHash().ToString());
continue;
}
else if (((op == OP_CLAIM_NAME) && (vvchParams.size() != 2)) || ((op == OP_SUPPORT_CLAIM) && (vvchParams.size() != 3)))
else if (((op == OP_CLAIM_NAME || op == OP_SUPPORT_CLAIM) && (vvchParams.size() != 2)) ||
((op == OP_UPDATE_CLAIM) && (vvchParams.size() != 3)))
{
LogPrintf("%s(): Wrong number of params to name claim script. Got %d, expected %d. Txid: %s", __func__, vvchParams.size(), ((op == OP_CLAIM_NAME) ? 2 : 3), wtx.GetHash().ToString());
continue;
@@ -677,15 +688,22 @@ void ListNameClaims(const CWalletTx& wtx, const string& strAccount, int nMinDept
entry.push_back(Pair("name", sName));
if (op == OP_CLAIM_NAME)
{
uint160 claimId = ClaimIdHash(wtx.GetHash(), s.vout);
entry.push_back(Pair("claimId", claimId.GetHex()));
string sValue (vvchParams[1].begin(), vvchParams[1].end());
entry.push_back(Pair("value", sValue));
}
else if (op == OP_UPDATE_CLAIM)
{
uint160 claimId(vvchParams[1]);
entry.push_back(Pair("claimId", claimId.GetHex()));
string sValue(vvchParams[2].begin(), vvchParams[2].end());
entry.push_back(Pair("value", sValue));
}
else if (op == OP_SUPPORT_CLAIM)
{
uint256 txhash(vvchParams[1]);
entry.push_back(Pair("supported_txid", txhash.GetHex()));
int32_t nOut = vch_to_uint32_t(vvchParams[2]);
entry.push_back(Pair("supported_nOut", nOut));
uint160 claimId(vvchParams[1]);
entry.push_back(Pair("supported_claimid", claimId.GetHex()));
}
entry.push_back(Pair("txid", wtx.GetHash().ToString()));
entry.push_back(Pair("account", strSentAccount));
@@ -737,7 +755,7 @@ UniValue listnameclaims(const UniValue& params, bool fHelp)
if (fHelp || params.size() > 3)
throw runtime_error(
"listnameclaims activeonly minconf\n"
"listnameclaims includesuppports activeonly minconf\n"
"Return a list of all transactions claiming names.\n"
"\nArguments\n"
"1. includesupports (bool, optional) Whether to also include claim supports. Default is true.\n"
@@ -748,6 +766,7 @@ UniValue listnameclaims(const UniValue& params, bool fHelp)
" {\n"
" \"name\":\"claimedname\", (string) The name that is claimed.\n"
" \"claimtype\":\"claimtype\", (string) CLAIM or SUPPORT.\n"
" \"claimId\":\"claimId\", (string) The claimId of the claim.\n"
" \"value\":\"value\" (string) The value assigned to the name, if claimtype is CLAIM.\n"
" \"account\":\"accountname\", (string) The account name associated with the transaction. \n"
" It will be \"\" for the default account.\n"
@@ -813,34 +832,32 @@ UniValue supportclaim(const UniValue& params, bool fHelp)
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() != 4)
if (fHelp || params.size() != 3)
throw runtime_error(
"supportclaim \"name\" \"txid\" nout amount\n"
"supportclaim \"name\" \"claimid\" \"amount\"\n"
"Increase the value of a claim. Whichever claim has the greatest value, including all support values, will be the authoritative claim, according to the rest of the rules. The name is the name which is claimed by the claim that will be supported, the txid is the txid of the claim that will be supported, nout is the transaction output which contains the claim to be supported, and amount is the amount which will be added to the value of the claim. If the claim is currently the authoritative claim, this support will go into effect immediately. Otherwise, it will go into effect after 100 blocks. The support will be in effect until it is spent, and will lose its effect when the claim is spent or expires. The amount is a real and is rounded to the nearest .00000001\n"
+ HelpRequiringPassphrase() +
"\nArguments:\n"
"1. \"name\" (string, required) The name claimed by the claim to support.\n"
"2. \"txid\" (string, required) The transaction id of the claim to support.\n"
"3. \"nout\" (integer, required) The transaction output of the transaction which contains the claim to be supported.\n"
"4. \"amount\" (numeric, required) The amount in LBC to use to support the claim.\n"
"2. \"claimid\" (string, required) The claimid of the claim to support. This can be obtained by TODO PUT IN PLACE THAT SHOWS THIS.\n"
"3. \"amount\" (numeric, required) The amount in LBC to use to support the claim.\n"
"\nResult:\n"
"\"transactionid\" (string) The transaction id of the support.\n"
);
string sName = params[0].get_str();
string sTxid = params[1].get_str();
uint256 txid;
txid.SetHex(sTxid);
string sClaimId = params[1].get_str();
uint160 claimId;
claimId.SetHex(sClaimId);
std::vector<unsigned char> vchName (sName.begin(), sName.end());
std::vector<unsigned char> vchTxid (txid.begin(), txid.end());
std::vector<unsigned char> vchnOut = uint32_t_to_vch(params[2].get_int());
CAmount nAmount = AmountFromValue(params[3]);
std::vector<unsigned char> vchClaimId (claimId.begin(), claimId.end());
CAmount nAmount = AmountFromValue(params[2]);
CWalletTx wtx;
EnsureWalletIsUnlocked();
CScript supportScript = CScript() << OP_SUPPORT_CLAIM << vchName << vchTxid << vchnOut << OP_2DROP << OP_2DROP;
CScript supportScript = CScript() << OP_SUPPORT_CLAIM << vchName << vchClaimId << OP_2DROP << OP_DROP;
CreateClaim(supportScript, nAmount, wtx);