mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-23 04:54:30 +00:00
adds userName to transaction
This commit is contained in:
parent
73e1f33dc8
commit
9cb71491a6
@ -51,10 +51,12 @@ public:
|
||||
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
|
||||
genesis.nVersion = 1;
|
||||
genesis.nTime = 1231006505;
|
||||
genesis.nBits = 0x1d00ffff;
|
||||
genesis.nNonce = 2083236893;
|
||||
genesis.nBits = 0x207fffff;
|
||||
genesis.nNonce = 0;
|
||||
|
||||
hashGenesisBlock = genesis.GetHash();
|
||||
printf("hashGenesisBlock %s\n", hashGenesisBlock.ToString().c_str());
|
||||
printf("genesis.hashMerkleRoot %s\n", genesis.hashMerkleRoot.ToString().c_str());
|
||||
//assert(hashGenesisBlock == uint256("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
|
||||
//assert(genesis.hashMerkleRoot == uint256("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
|
||||
|
10
src/core.cpp
10
src/core.cpp
@ -87,9 +87,13 @@ std::string CTransaction::ToString() const
|
||||
message.size(),
|
||||
userID.size(),
|
||||
pubKey.size());
|
||||
str += " " + message.ToString() + "\n";
|
||||
str += " " + userID.ToString() + "\n";
|
||||
str += " " + pubKey.ToString() + "\n";
|
||||
if( message.size() ) {
|
||||
str += " message: " + message.ToString() + "\n";
|
||||
} else {
|
||||
str += " userName: " + userName.ToString() + "\n";
|
||||
str += " userID: " + userID.ToString() + "\n";
|
||||
str += " pubKey: " + pubKey.ToString() + "\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
11
src/core.h
11
src/core.h
@ -183,6 +183,7 @@ public:
|
||||
static const int CURRENT_VERSION=1;
|
||||
int nVersion;
|
||||
CScript message;
|
||||
CScript userName;
|
||||
CScript userID;
|
||||
CScript pubKey;
|
||||
//std::vector<CTxIn> vin;
|
||||
@ -199,6 +200,7 @@ public:
|
||||
READWRITE(this->nVersion);
|
||||
nVersion = this->nVersion;
|
||||
READWRITE(message);
|
||||
READWRITE(userName);
|
||||
READWRITE(userID);
|
||||
READWRITE(pubKey);
|
||||
)
|
||||
@ -207,21 +209,21 @@ public:
|
||||
{
|
||||
nVersion = CTransaction::CURRENT_VERSION;
|
||||
message.clear();
|
||||
userName.clear();
|
||||
userID.clear();
|
||||
pubKey.clear();
|
||||
}
|
||||
|
||||
bool IsNull() const
|
||||
{
|
||||
return (message.empty() && userID.empty() && pubKey.empty());
|
||||
return (message.empty() && userName.empty() && userID.empty() && pubKey.empty());
|
||||
}
|
||||
|
||||
uint256 GetHash() const;
|
||||
bool IsNewerThan(const CTransaction& old) const;
|
||||
|
||||
bool IsCoinBase() const
|
||||
bool IsSpamMessage() const
|
||||
{
|
||||
//[MF] reusing coinbase as spam string
|
||||
return (!message.empty() && userID.empty() && pubKey.empty());
|
||||
}
|
||||
|
||||
@ -229,6 +231,7 @@ public:
|
||||
{
|
||||
return (a.nVersion == b.nVersion &&
|
||||
a.message == b.message &&
|
||||
a.userName == b.userName &&
|
||||
a.userID == b.userID &&
|
||||
a.pubKey == b.pubKey);
|
||||
}
|
||||
@ -393,7 +396,7 @@ public:
|
||||
int nVersion;
|
||||
|
||||
// construct a CCoins from a CTransaction, at a given height
|
||||
CCoins(const CTransaction &tx, int nHeightIn) : fCoinBase(tx.IsCoinBase()), vout(), nHeight(nHeightIn), nVersion(tx.nVersion) { }
|
||||
CCoins(const CTransaction &tx, int nHeightIn) : fCoinBase(tx.IsSpamMessage()), vout(), nHeight(nHeightIn), nVersion(tx.nVersion) { }
|
||||
|
||||
// empty constructor
|
||||
CCoins() : fCoinBase(false), vout(0), nHeight(0), nVersion(0) { }
|
||||
|
28
src/main.cpp
28
src/main.cpp
@ -575,7 +575,7 @@ int64 GetValueOut(const CTransaction& tx)
|
||||
//
|
||||
bool AreInputsStandard(const CTransaction& tx, CCoinsViewCache& mapInputs)
|
||||
{
|
||||
if (tx.IsCoinBase())
|
||||
if (tx.IsSpamMessage())
|
||||
return true; // Coinbases don't use vin normally
|
||||
/* [MF]
|
||||
for (unsigned int i = 0; i < tx.vin.size(); i++)
|
||||
@ -645,7 +645,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx)
|
||||
|
||||
unsigned int GetP2SHSigOpCount(const CTransaction& tx, CCoinsViewCache& inputs)
|
||||
{
|
||||
if (tx.IsCoinBase())
|
||||
if (tx.IsSpamMessage())
|
||||
return 0;
|
||||
|
||||
unsigned int nSigOps = 0;
|
||||
@ -820,7 +820,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fLimitFr
|
||||
return error("CTxMemPool::accept() : CheckTransaction failed");
|
||||
|
||||
// Coinbase is only valid in a block, not as a loose transaction
|
||||
if (tx.IsCoinBase())
|
||||
if (tx.IsSpamMessage())
|
||||
return state.DoS(100, error("CTxMemPool::accept() : coinbase as individual tx"));
|
||||
|
||||
/*
|
||||
@ -1092,7 +1092,7 @@ int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet) const
|
||||
|
||||
int CMerkleTx::GetBlocksToMaturity() const
|
||||
{
|
||||
if (!IsCoinBase())
|
||||
if (!IsSpamMessage())
|
||||
return 0;
|
||||
return max(0, (COINBASE_MATURITY+20) - GetDepthInMainChain());
|
||||
}
|
||||
@ -1113,7 +1113,7 @@ bool CWalletTx::AcceptWalletTransaction()
|
||||
// Add previous supporting transactions first
|
||||
BOOST_FOREACH(CMerkleTx& tx, vtxPrev)
|
||||
{
|
||||
if (!tx.IsCoinBase())
|
||||
if (!tx.IsSpamMessage())
|
||||
{
|
||||
uint256 hash = tx.GetHash();
|
||||
if (!mempool.exists(hash) && pcoinsTip->HaveCoins(hash))
|
||||
@ -1523,7 +1523,7 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input)
|
||||
|
||||
int64 CCoinsViewCache::GetValueIn(const CTransaction& tx)
|
||||
{
|
||||
if (tx.IsCoinBase())
|
||||
if (tx.IsSpamMessage())
|
||||
return 0;
|
||||
|
||||
int64 nResult = 0;
|
||||
@ -1537,7 +1537,7 @@ int64 CCoinsViewCache::GetValueIn(const CTransaction& tx)
|
||||
void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight, const uint256 &txhash)
|
||||
{
|
||||
// mark inputs spent
|
||||
if (!tx.IsCoinBase()) {
|
||||
if (!tx.IsSpamMessage()) {
|
||||
/* [MF]
|
||||
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
|
||||
CCoins &coins = inputs.GetCoins(txin.prevout.hash);
|
||||
@ -1554,7 +1554,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
|
||||
|
||||
bool CCoinsViewCache::HaveInputs(const CTransaction& tx)
|
||||
{
|
||||
if (!tx.IsCoinBase()) {
|
||||
if (!tx.IsSpamMessage()) {
|
||||
/* [MF]
|
||||
// first check whether information about the prevout hash is available
|
||||
for (unsigned int i = 0; i < tx.vin.size(); i++) {
|
||||
@ -1594,7 +1594,7 @@ bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned in
|
||||
|
||||
bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, std::vector<CScriptCheck> *pvChecks)
|
||||
{
|
||||
if (!tx.IsCoinBase())
|
||||
if (!tx.IsSpamMessage())
|
||||
{
|
||||
/* [MF]
|
||||
if (pvChecks)
|
||||
@ -1886,7 +1886,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
|
||||
*/
|
||||
CTxUndo txundo;
|
||||
UpdateCoins(tx, state, view, txundo, pindex->nHeight, block.GetTxHash(i));
|
||||
if (!tx.IsCoinBase())
|
||||
if (!tx.IsSpamMessage())
|
||||
blockundo.vtxundo.push_back(txundo);
|
||||
|
||||
vPos.push_back(std::make_pair(block.GetTxHash(i), pos));
|
||||
@ -1997,7 +1997,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
// We only do this for blocks after the last checkpoint (reorganisation before that
|
||||
// point should only happen with -reindex/-loadblock, or a misbehaving peer.
|
||||
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
||||
if (!tx.IsCoinBase() && pindex->nHeight > Checkpoints::GetTotalBlocksEstimate())
|
||||
if (!tx.IsSpamMessage() && pindex->nHeight > Checkpoints::GetTotalBlocksEstimate())
|
||||
vResurrect.push_back(tx);
|
||||
}
|
||||
|
||||
@ -2281,10 +2281,10 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
||||
return state.Invalid(error("CheckBlock() : block timestamp too far in the future"));
|
||||
|
||||
// First transaction must be coinbase, the rest must not be
|
||||
if (block.vtx.empty() || !block.vtx[0].IsCoinBase())
|
||||
if (block.vtx.empty() || !block.vtx[0].IsSpamMessage())
|
||||
return state.DoS(100, error("CheckBlock() : first tx is not coinbase"));
|
||||
for (unsigned int i = 1; i < block.vtx.size(); i++)
|
||||
if (block.vtx[i].IsCoinBase())
|
||||
if (block.vtx[i].IsSpamMessage())
|
||||
return state.DoS(100, error("CheckBlock() : more than one coinbase"));
|
||||
|
||||
// Check transactions
|
||||
@ -4367,7 +4367,7 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
|
||||
for (map<uint256, CTransaction>::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi)
|
||||
{
|
||||
CTransaction& tx = (*mi).second;
|
||||
if (tx.IsCoinBase() || !IsFinalTx(tx))
|
||||
if (tx.IsSpamMessage() || !IsFinalTx(tx))
|
||||
continue;
|
||||
|
||||
COrphan* porphan = NULL;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
bool TransactionRecord::showTransaction(const CWalletTx &wtx)
|
||||
{
|
||||
if (wtx.IsCoinBase())
|
||||
if (wtx.IsSpamMessage())
|
||||
{
|
||||
// Ensures we show generated coins / mined transactions at depth 1
|
||||
if (!wtx.IsInMainChain())
|
||||
@ -155,7 +155,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
||||
// Sort order, unrecorded transactions sort to the top
|
||||
status.sortKey = strprintf("%010d-%01d-%010u-%03d",
|
||||
(pindex ? pindex->nHeight : std::numeric_limits<int>::max()),
|
||||
(wtx.IsCoinBase() ? 1 : 0),
|
||||
(wtx.IsSpamMessage() ? 1 : 0),
|
||||
wtx.nTimeReceived,
|
||||
idx);
|
||||
status.confirmed = wtx.IsConfirmed();
|
||||
|
@ -304,7 +304,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
uint256 txHash = tx.GetHash();
|
||||
setTxIndex[txHash] = i++;
|
||||
|
||||
if (tx.IsCoinBase())
|
||||
if (tx.IsSpamMessage())
|
||||
continue;
|
||||
|
||||
Object entry;
|
||||
|
@ -36,7 +36,7 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
|
||||
{
|
||||
int confirms = wtx.GetDepthInMainChain();
|
||||
entry.push_back(Pair("confirmations", confirms));
|
||||
if (wtx.IsCoinBase())
|
||||
if (wtx.IsSpamMessage())
|
||||
entry.push_back(Pair("generated", true));
|
||||
if (confirms)
|
||||
{
|
||||
@ -408,7 +408,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
|
||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
if (wtx.IsCoinBase() || !IsFinalTx(wtx))
|
||||
if (wtx.IsSpamMessage() || !IsFinalTx(wtx))
|
||||
continue;
|
||||
/*
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
@ -455,7 +455,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
|
||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
if (wtx.IsCoinBase() || !IsFinalTx(wtx))
|
||||
if (wtx.IsSpamMessage() || !IsFinalTx(wtx))
|
||||
continue;
|
||||
/*
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
@ -841,7 +841,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
|
||||
if (wtx.IsCoinBase() || !IsFinalTx(wtx))
|
||||
if (wtx.IsSpamMessage() || !IsFinalTx(wtx))
|
||||
continue;
|
||||
|
||||
int nDepth = wtx.GetDepthInMainChain();
|
||||
@ -997,7 +997,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||
Object entry;
|
||||
entry.push_back(Pair("account", account));
|
||||
entry.push_back(Pair("address", CBitcoinAddress(r.first).ToString()));
|
||||
if (wtx.IsCoinBase())
|
||||
if (wtx.IsSpamMessage())
|
||||
{
|
||||
if (wtx.GetDepthInMainChain() < 1)
|
||||
entry.push_back(Pair("category", "orphan"));
|
||||
|
@ -629,7 +629,7 @@ int CWalletTx::GetRequestCount() const
|
||||
int nRequests = -1;
|
||||
{
|
||||
LOCK(pwallet->cs_wallet);
|
||||
if (IsCoinBase())
|
||||
if (IsSpamMessage())
|
||||
{
|
||||
// Generated block
|
||||
if (hashBlock != 0)
|
||||
@ -838,7 +838,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
||||
{
|
||||
CWalletTx& wtx = item.second;
|
||||
if (wtx.IsCoinBase() && wtx.IsSpent(0))
|
||||
if (wtx.IsSpamMessage() && wtx.IsSpent(0))
|
||||
continue;
|
||||
|
||||
CCoins coins;
|
||||
@ -870,7 +870,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
else
|
||||
{
|
||||
// Re-accept any txes of ours that aren't already in a block
|
||||
if (!wtx.IsCoinBase())
|
||||
if (!wtx.IsSpamMessage())
|
||||
wtx.AcceptWalletTransaction();
|
||||
}
|
||||
}
|
||||
@ -887,11 +887,11 @@ void CWalletTx::RelayWalletTransaction()
|
||||
{
|
||||
BOOST_FOREACH(const CMerkleTx& tx, vtxPrev)
|
||||
{
|
||||
if (!tx.IsCoinBase())
|
||||
if (!tx.IsSpamMessage())
|
||||
if (tx.GetDepthInMainChain() == 0)
|
||||
RelayTransaction((CTransaction)tx, tx.GetHash());
|
||||
}
|
||||
if (!IsCoinBase())
|
||||
if (!IsSpamMessage())
|
||||
{
|
||||
if (GetDepthInMainChain() == 0) {
|
||||
uint256 hash = GetHash();
|
||||
@ -1014,7 +1014,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed) const
|
||||
if (fOnlyConfirmed && !pcoin->IsConfirmed())
|
||||
continue;
|
||||
|
||||
if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0)
|
||||
if (pcoin->IsSpamMessage() && pcoin->GetBlocksToMaturity() > 0)
|
||||
continue;
|
||||
/*
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
||||
@ -1708,7 +1708,7 @@ std::map<CTxDestination, int64> CWallet::GetAddressBalances()
|
||||
if (!IsFinalTx(*pcoin) || !pcoin->IsConfirmed())
|
||||
continue;
|
||||
|
||||
if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0)
|
||||
if (pcoin->IsSpamMessage() && pcoin->GetBlocksToMaturity() > 0)
|
||||
continue;
|
||||
|
||||
int nDepth = pcoin->GetDepthInMainChain();
|
||||
|
@ -585,7 +585,7 @@ public:
|
||||
int64 GetCredit(bool fUseCache=true) const
|
||||
{
|
||||
// Must wait until coinbase is safely deep enough in the chain before valuing it
|
||||
if (IsCoinBase() && GetBlocksToMaturity() > 0)
|
||||
if (IsSpamMessage() && GetBlocksToMaturity() > 0)
|
||||
return 0;
|
||||
|
||||
// GetBalance can assume transactions in mapWallet won't change
|
||||
@ -598,7 +598,7 @@ public:
|
||||
|
||||
int64 GetImmatureCredit(bool fUseCache=true) const
|
||||
{
|
||||
if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain())
|
||||
if (IsSpamMessage() && GetBlocksToMaturity() > 0 && IsInMainChain())
|
||||
{
|
||||
if (fUseCache && fImmatureCreditCached)
|
||||
return nImmatureCreditCached;
|
||||
@ -613,7 +613,7 @@ public:
|
||||
int64 GetAvailableCredit(bool fUseCache=true) const
|
||||
{
|
||||
// Must wait until coinbase is safely deep enough in the chain before valuing it
|
||||
if (IsCoinBase() && GetBlocksToMaturity() > 0)
|
||||
if (IsSpamMessage() && GetBlocksToMaturity() > 0)
|
||||
return 0;
|
||||
|
||||
if (fUseCache && fAvailableCreditCached)
|
||||
|
Loading…
x
Reference in New Issue
Block a user