本文整理汇总了C++中GetTransaction函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTransaction函数的具体用法?C++ GetTransaction怎么用?C++ GetTransaction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetTransaction函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getTxTotalValue
double getTxTotalValue(std::string txid)
{
uint256 hash;
hash.SetHex(txid);
CTransaction tx;
uint256 hashBlock = 0;
if (!GetTransaction(hash, tx, hashBlock))
return 1000;
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << tx;
double value = 0;
double buffer = 0;
for (unsigned int i = 0; i < tx.vout.size(); i++)
{
const CTxOut& txout = tx.vout[i];
buffer = value + convertCoins(txout.nValue);
value = buffer;
}
return value;
}
开发者ID:cryptodeveloper,项目名称:Transfercoin,代码行数:25,代码来源:blockbrowser.cpp
示例2: getOutputs
std::string getOutputs(std::string txid)
{
uint256 hash;
hash.SetHex(txid);
CTransaction tx;
uint256 hashBlock = 0;
if (!GetTransaction(hash, tx, hashBlock))
return "fail";
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << tx;
std::string str = "";
for (unsigned int i = 0; i < tx.vout.size(); i++)
{
const CTxOut& txout = tx.vout[i];
CTxDestination source;
ExtractDestination(txout.scriptPubKey, source);
CBitcoinAddress addressSource(source);
std::string lol7 = addressSource.ToString();
double buffer = convertCoins(txout.nValue);
std::ostringstream ss;
ss << std::fixed << std::setprecision(4) << buffer;
std::string amount = ss.str();
str.append(lol7);
str.append(": ");
str.append(amount);
str.append(" TX");
str.append("\n");
}
return str;
}
开发者ID:cryptodeveloper,项目名称:Transfercoin,代码行数:34,代码来源:blockbrowser.cpp
示例3: on_transactionId_textChanged
void MultisigInputEntry::on_transactionId_textChanged(const QString &transactionId)
{
ui->transactionOutput->clear();
if(transactionId.isEmpty())
return;
// Make list of transaction outputs
txHash.SetHex(transactionId.toStdString().c_str());
CTransaction tx;
uint256 blockHash = 0;
if(!GetTransaction(txHash, tx, blockHash))
return;
for(unsigned int i = 0; i < tx.vout.size(); i++)
{
QString idStr;
idStr.setNum(i);
const CTxOut& txOut = tx.vout[i];
int64_t amount = txOut.nValue;
QString amountStr;
amountStr.sprintf("%.6f", (double) amount / COIN);
CScript script = txOut.scriptPubKey;
CTxDestination addr;
if(ExtractDestination(script, addr))
{
CBitcoinAddress address(addr);
QString addressStr(address.ToString().c_str());
ui->transactionOutput->addItem(idStr + QString(" - ") + addressStr + QString(" - ") + amountStr + QString(" MPRO"));
}
else
ui->transactionOutput->addItem(idStr + QString(" - ") + amountStr + QString(" MPRO"));
}
}
开发者ID:MEDIUMPROJECT,项目名称:MEDIUM,代码行数:32,代码来源:multisiginputentry.cpp
示例4: getPrevOut
CTxOut getPrevOut(const COutPoint& out)
{
CTransaction tx;
uint256 hashBlock;
if (GetTransaction(out.hash, tx, hashBlock, true))
return tx.vout[out.n];
return CTxOut();
}
开发者ID:michaili,项目名称:PIVX,代码行数:8,代码来源:blockexplorer.cpp
示例5: getInputs
std::string getInputs(std::string txid) {
uint256 hash;
hash.SetHex(txid);
CTransaction tx;
uint256 hashBlock = 0;
if (!GetTransaction(hash, tx, hashBlock)) {
return "fail";
}
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << tx;
std::string str = "";
for (unsigned int i = 0; i < tx.vin.size(); i++) {
uint256 hash;
const CTxIn& vin = tx.vin[i];
hash.SetHex(vin.prevout.hash.ToString());
CTransaction wtxPrev;
uint256 hashBlock = 0;
if (!GetTransaction(hash, wtxPrev, hashBlock)) {
return "fail";
}
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << wtxPrev;
CTxDestination source;
ExtractDestination(wtxPrev.vout[vin.prevout.n].scriptPubKey, source);
CBitcoinAddress addressSource(source);
std::string lol6 = addressSource.ToString();
const CScript target = wtxPrev.vout[vin.prevout.n].scriptPubKey;
double buffer = convertCoins(getInputValue(wtxPrev, target));
std::string amount = boost::to_string(buffer);
str.append(lol6);
str.append(": ");
str.append(amount);
str.append("SHADE");
str.append("\n");
}
return str;
}
开发者ID:EarlyClues,项目名称:Shade,代码行数:46,代码来源:blockbrowser.cpp
示例6: getTxFees
double getTxFees(std::string txid)
{
uint256 hash;
hash.SetHex(txid);
CTransaction tx;
uint256 hashBlock = 0;
if (!GetTransaction(hash, tx, hashBlock))
return 0.0001;
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << tx;
double value = 0;
double buffer = 0;
for (unsigned int i = 0; i < tx.vout.size(); i++)
{
const CTxOut& txout = tx.vout[i];
buffer = value + convertCoins(txout.nValue);
value = buffer;
}
double value0 = 0;
double buffer0 = 0;
double swp=0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
uint256 hash0;
const CTxIn& vin = tx.vin[i];
hash0.SetHex(vin.prevout.hash.ToString());
CTransaction wtxPrev;
uint256 hashBlock0 = 0;
if (!GetTransaction(hash0, wtxPrev, hashBlock0))
return 0;
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << wtxPrev;
const CScript target = wtxPrev.vout[vin.prevout.n].scriptPubKey;
swp =convertCoins(getInputValue(wtxPrev, target));
buffer0 = value0 + convertCoins(getInputValue(wtxPrev, target));
value0 = buffer0;
}
return value0 - value;
}
开发者ID:MsCollec,项目名称:Sync2,代码行数:46,代码来源:blockbrowser.cpp
示例7: GetTransaction
bool MgServerFeatureTransactionPool::RollbackTransaction(CREFSTRING transactionId)
{
Ptr<MgServerFeatureTransaction> tran = GetTransaction(transactionId);
if (NULL != tran.p)
{
tran->Rollback();
}
return RemoveTransaction(transactionId);
}
开发者ID:kanbang,项目名称:Colt,代码行数:10,代码来源:ServerFeatureTransactionPool.cpp
示例8: tr
void MultisigDialog::on_sendTransactionButton_clicked()
{
int64_t transactionSize = ui->signedTransaction->text().size() / 2;
if(transactionSize == 0)
return;
// Check the fee
int64_t fee = (int64_t ) (ui->fee->text().toDouble() * COIN);
int64_t minFee = MIN_TX_FEE * (1 + (int64_t) transactionSize / 1000);
if(fee < minFee)
{
QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm send transaction"), tr("The fee of the transaction (%1 XBTC21) is smaller than the expected fee (%2 XBTC21). Do you want to send the transaction anyway?").arg((double) fee / COIN).arg((double) minFee / COIN), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
if(ret != QMessageBox::Yes)
return;
}
else if(fee > minFee)
{
QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm send transaction"), tr("The fee of the transaction (%1 XBTC21) is bigger than the expected fee (%2 XBTC21). Do you want to send the transaction anyway?").arg((double) fee / COIN).arg((double) minFee / COIN), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
if(ret != QMessageBox::Yes)
return;
}
// Decode the raw transaction
std::vector<unsigned char> txData(ParseHex(ui->signedTransaction->text().toStdString()));
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
CTransaction tx;
try
{
ssData >> tx;
}
catch(std::exception &e)
{
(void)e;
return;
}
uint256 txHash = tx.GetHash();
// Check if the transaction is already in the blockchain
CTransaction existingTx;
uint256 blockHash = 0;
if(GetTransaction(txHash, existingTx, blockHash))
{
if(blockHash != 0)
return;
}
// Send the transaction to the local node
CTxDB txdb("r");
if(!tx.AcceptToMemoryPool(txdb, false))
return;
SyncWithWallets(tx, NULL, true);
//(CInv(MSG_TX, txHash), tx);
RelayTransaction(tx, txHash);
}
开发者ID:Bitcoin21,项目名称:V1.0,代码行数:54,代码来源:multisigdialog.cpp
示例9: MessageGetViaBranch
struct Transaction *MatchRequest(MESSAGE *message)
{
char *branch = MessageGetViaBranch(message);
SIP_METHOD method = MessageGetMethod(message);
if (method == SIP_METHOD_CANCEL) {
method = SIP_METHOD_INVITE;
}
char *methodName = MethodMap2String(method);
return GetTransaction(branch, methodName);
}
开发者ID:yjjfirst,项目名称:x-sip,代码行数:12,代码来源:TransactionManager.c
示例10: ValidateTimeout
bool MgServerFeatureTransactionPool::CommitTransaction(CREFSTRING transactionId)
{
ValidateTimeout(transactionId);
Ptr<MgServerFeatureTransaction> tran = GetTransaction(transactionId);
if (NULL != tran.p)
{
tran->Commit();
}
return RemoveTransaction(transactionId);
}
开发者ID:kanbang,项目名称:Colt,代码行数:12,代码来源:ServerFeatureTransactionPool.cpp
示例11: rest_tx
static bool rest_tx(HTTPRequest* req, const std::string& strURIPart)
{
if (!CheckWarmup(req))
return false;
std::string hashStr;
const RetFormat rf = ParseDataFormat(hashStr, strURIPart);
uint256 hash;
if (!ParseHashStr(hashStr, hash))
return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr);
if (g_txindex) {
g_txindex->BlockUntilSyncedToCurrentChain();
}
CTransactionRef tx;
uint256 hashBlock = uint256();
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
ssTx << tx;
switch (rf) {
case RetFormat::BINARY: {
std::string binaryTx = ssTx.str();
req->WriteHeader("Content-Type", "application/octet-stream");
req->WriteReply(HTTP_OK, binaryTx);
return true;
}
case RetFormat::HEX: {
std::string strHex = HexStr(ssTx.begin(), ssTx.end()) + "\n";
req->WriteHeader("Content-Type", "text/plain");
req->WriteReply(HTTP_OK, strHex);
return true;
}
case RetFormat::JSON: {
UniValue objTx(UniValue::VOBJ);
TxToUniv(*tx, hashBlock, objTx);
std::string strJSON = objTx.write() + "\n";
req->WriteHeader("Content-Type", "application/json");
req->WriteReply(HTTP_OK, strJSON);
return true;
}
default: {
return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + AvailableDataFormatsString() + ")");
}
}
}
开发者ID:fujicoin,项目名称:fujicoin,代码行数:52,代码来源:rest.cpp
示例12: getexplorerBlockHash
bool BlockExplorer::switchTo(const QString& query)
{
bool IsOk;
int64_t AsInt = query.toInt(&IsOk);
// If query is integer, get hash from height
if (IsOk && AsInt >= 0 && AsInt <= chainActive.Tip()->nHeight) {
std::string hex = getexplorerBlockHash(AsInt);
uint256 hash = uint256S(hex);
CBlockIndex* pIndex = mapBlockIndex[hash];
if (pIndex) {
setBlock(pIndex);
return true;
}
}
// If the query is not an integer, assume it is a block hash
uint256 hash = uint256S(query.toUtf8().constData());
// std::map<uint256, CBlockIndex*>::iterator iter = mapBlockIndex.find(hash);
BlockMap::iterator iter = mapBlockIndex.find(hash);
if (iter != mapBlockIndex.end()) {
setBlock(iter->second);
return true;
}
// If the query is neither an integer nor a block hash, assume a transaction hash
CTransaction tx;
uint256 hashBlock = 0;
if (GetTransaction(hash, tx, hashBlock, true)) {
setContent(TxToString(hashBlock, tx));
return true;
}
// If the query is not an integer, nor a block hash, nor a transaction hash, assume an address
CBitcoinAddress Address;
Address.SetString(query.toUtf8().constData());
if (Address.IsValid()) {
std::string Content = AddressToString(Address);
if (Content.empty())
return false;
setContent(Content);
return true;
}
return false;
}
开发者ID:michaili,项目名称:PIVX,代码行数:46,代码来源:blockexplorer.cpp
示例13: getAmount
int64 MultisigInputEntry::getAmount()
{
int64 amount = 0;
int nOutput = ui->transactionOutput->currentIndex();
CTransaction tx;
uint256 blockHash = 0;
if(GetTransaction(txHash, tx, blockHash))
{
if(nOutput < tx.vout.size())
{
const CTxOut& txOut = tx.vout[nOutput];
amount = txOut.nValue;
}
}
return amount;
}
开发者ID:tomasmartins,项目名称:TRMWallet,代码行数:18,代码来源:multisiginputentry.cpp
示例14: on_transactionOutput_currentIndexChanged
void MultisigInputEntry::on_transactionOutput_currentIndexChanged(int index)
{
if(ui->transactionOutput->itemText(index).isEmpty())
return;
CTransaction tx;
uint256 blockHash = 0;
if(!GetTransaction(txHash, tx, blockHash))
return;
const CTxOut& txOut = tx.vout[index];
CScript script = txOut.scriptPubKey;
if(script.IsPayToScriptHash())
{
ui->redeemScript->setEnabled(true);
if(model)
{
/* FIXME
// Try to find the redeem script
CBitcoinAddress dest;
if(ExtractAddress(script, dest))
{
CScriptID scriptID = boost::get<CScriptID>(dest);
CScriptID scriptID;
if(dest.GetScriptID(scriptID))
{
CScript redeemScript;
if(model->getWallet()->GetCScript(scriptID, redeemScript))
ui->redeemScript->setText(HexStr(redeemScript.begin(), redeemScript.end()).c_str());
}
}
*/
}
}
else
{
ui->redeemScript->setEnabled(false);
}
emit updateAmount();
}
开发者ID:d5000,项目名称:slimcoin,代码行数:42,代码来源:multisiginputentry.cpp
示例15: GetMinCollateralFee
bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const
{
strError = "";
fMissingConfirmations = false;
CAmount nMinFee = GetMinCollateralFee();
uint256 nExpectedHash = GetHash();
CTransactionRef txCollateral;
uint256 nBlockHash;
// RETRIEVE TRANSACTION IN QUESTION
if (!GetTransaction(nCollateralHash, txCollateral, Params().GetConsensus(), nBlockHash, true)) {
strError = strprintf("Can't find collateral tx %s", nCollateralHash.ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if (nBlockHash == uint256()) {
strError = strprintf("Collateral tx %s is not mined yet", txCollateral->ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if (txCollateral->vout.size() < 1) {
strError = strprintf("tx vout size less than 1 | %d", txCollateral->vout.size());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
// LOOK FOR SPECIALIZED GOVERNANCE SCRIPT (PROOF OF BURN)
CScript findScript;
findScript << OP_RETURN << ToByteVector(nExpectedHash);
LogPrint("gobject", "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n",
txCollateral->vout.size(), ScriptToAsmStr(findScript, false), nMinFee);
bool foundOpReturn = false;
for (const auto& output : txCollateral->vout) {
LogPrint("gobject", "CGovernanceObject::IsCollateralValid -- txout = %s, output.nValue = %lld, output.scriptPubKey = %s\n",
output.ToString(), output.nValue, ScriptToAsmStr(output.scriptPubKey, false));
if (!output.scriptPubKey.IsPayToPublicKeyHash() && !output.scriptPubKey.IsUnspendable()) {
strError = strprintf("Invalid Script %s", txCollateral->ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if (output.scriptPubKey == findScript && output.nValue >= nMinFee) {
foundOpReturn = true;
}
}
if (!foundOpReturn) {
strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral->ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
// GET CONFIRMATIONS FOR TRANSACTION
AssertLockHeld(cs_main);
int nConfirmationsIn = 0;
if (nBlockHash != uint256()) {
BlockMap::iterator mi = mapBlockIndex.find(nBlockHash);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
nConfirmationsIn += chainActive.Height() - pindex->nHeight + 1;
}
}
}
if ((nConfirmationsIn < GOVERNANCE_FEE_CONFIRMATIONS) &&
(!instantsend.IsLockedInstantSendTransaction(nCollateralHash) || llmq::quorumInstantSendManager->IsLocked(nCollateralHash))) {
strError = strprintf("Collateral requires at least %d confirmations to be relayed throughout the network (it has only %d)", GOVERNANCE_FEE_CONFIRMATIONS, nConfirmationsIn);
if (nConfirmationsIn >= GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS) {
fMissingConfirmations = true;
strError += ", pre-accepted -- waiting for required confirmations";
} else {
strError += ", rejected -- try again later";
}
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
strError = "valid";
return true;
}
开发者ID:dashpay,项目名称:dash,代码行数:89,代码来源:governance-object.cpp
示例16: LOCK2
bool CInstantSend::ResolveConflicts(const CTxLockCandidate& txLockCandidate)
{
LOCK2(cs_main, cs_instantsend);
uint256 txHash = txLockCandidate.GetHash();
// make sure the lock is ready
if(!txLockCandidate.IsAllOutPointsReady()) return false;
AssertLockHeld(mempool.cs); // protect mempool.mapNextTx
for (const auto& txin : txLockCandidate.txLockRequest.tx->vin) {
uint256 hashConflicting;
if(GetLockedOutPointTxHash(txin.prevout, hashConflicting) && txHash != hashConflicting) {
// completed lock which conflicts with another completed one?
// this means that majority of MNs in the quorum for this specific tx input are malicious!
std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash);
std::map<uint256, CTxLockCandidate>::iterator itLockCandidateConflicting = mapTxLockCandidates.find(hashConflicting);
if(itLockCandidate == mapTxLockCandidates.end() || itLockCandidateConflicting == mapTxLockCandidates.end()) {
// safety check, should never really happen
LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Found conflicting completed Transaction Lock, but one of txLockCandidate-s is missing, txid=%s, conflicting txid=%s\n",
txHash.ToString(), hashConflicting.ToString());
return false;
}
LogPrintf("CInstantSend::ResolveConflicts -- WARNING: Found conflicting completed Transaction Lock, dropping both, txid=%s, conflicting txid=%s\n",
txHash.ToString(), hashConflicting.ToString());
CTxLockRequest txLockRequest = itLockCandidate->second.txLockRequest;
CTxLockRequest txLockRequestConflicting = itLockCandidateConflicting->second.txLockRequest;
itLockCandidate->second.SetConfirmedHeight(0); // expired
itLockCandidateConflicting->second.SetConfirmedHeight(0); // expired
CheckAndRemove(); // clean up
// AlreadyHave should still return "true" for both of them
mapLockRequestRejected.insert(std::make_pair(txHash, txLockRequest));
mapLockRequestRejected.insert(std::make_pair(hashConflicting, txLockRequestConflicting));
// TODO: clean up mapLockRequestRejected later somehow
// (not a big issue since we already PoSe ban malicious masternodes
// and they won't be able to spam)
// TODO: ban all malicious masternodes permanently, do not accept anything from them, ever
// TODO: notify zmq+script about this double-spend attempt
// and let merchant cancel/hold the order if it's not too late...
// can't do anything else, fallback to regular txes
return false;
} else if (mempool.mapNextTx.count(txin.prevout)) {
// check if it's in mempool
hashConflicting = mempool.mapNextTx.find(txin.prevout)->second->GetHash();
if(txHash == hashConflicting) continue; // matches current, not a conflict, skip to next txin
// conflicts with tx in mempool
LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Failed to complete Transaction Lock, conflicts with mempool, txid=%s\n", txHash.ToString());
return false;
}
} // FOREACH
// No conflicts were found so far, check to see if it was already included in block
CTransactionRef txTmp;
uint256 hashBlock;
if(GetTransaction(txHash, txTmp, Params().GetConsensus(), hashBlock, true) && hashBlock != uint256()) {
LogPrint("instantsend", "CInstantSend::ResolveConflicts -- Done, %s is included in block %s\n", txHash.ToString(), hashBlock.ToString());
return true;
}
// Not in block yet, make sure all its inputs are still unspent
for (const auto& txin : txLockCandidate.txLockRequest.tx->vin) {
Coin coin;
if(!GetUTXOCoin(txin.prevout, coin)) {
// Not in UTXO anymore? A conflicting tx was mined while we were waiting for votes.
LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Failed to find UTXO %s, can't complete Transaction Lock\n", txin.prevout.ToStringShort());
return false;
}
}
LogPrint("instantsend", "CInstantSend::ResolveConflicts -- Done, txid=%s\n", txHash.ToString());
return true;
}
开发者ID:einalex,项目名称:syscoin,代码行数:74,代码来源:instantx.cpp
示例17: updateWallet
void updateWallet(const uint256 &hash, int status)
{
const QList<AdsModelRecord>::iterator lower = qLowerBound(
cache.begin(), cache.end(), hash, TxLessThan());
const bool inModel = (lower != cache.end() && (*lower).hash == hash);
const int lowerIndex = (lower - cache.begin());
{
switch(status)
{
case CT_NEW:
{
if(inModel)
{
break;
}
CTransaction tx;
uint256 hashBlock;
if (!GetTransaction(hash, tx, hashBlock))
{
break;
}
const AdsModelRecord toInsert = AdsModelRecord::decomposeTransaction(tx);
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
cache.insert(lowerIndex, toInsert);
parent->endInsertRows();
}
break;
case CT_DELETED:
if(!inModel)
{
break;
}
// Removed -- remove entire transaction from table
parent->beginRemoveRows(QModelIndex(), lowerIndex, lowerIndex);
cache.erase(lower);
parent->endRemoveRows();
break;
case CT_UPDATED:
// Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
// visible transactions.
break;
}
}
if (cache.size() > MAX_ADS)
{
// remove records, exceeding limit, beginning from oldest.
QList<AdsModelRecord>::iterator i = cache.begin(), iend = cache.end();
QList<AdsModelRecord>::iterator imindate = iend;
for(; i != iend; ++ i)
{
if (imindate == cache.end() || (*i).time < (*imindate).time)
{
imindate = i;
}
}
if (imindate != iend)
{
updateWallet((*imindate).hash, CT_DELETED);
}
}
}
开发者ID:CraigsCoin,项目名称:CraigsCoin,代码行数:62,代码来源:adstablemodel.cpp
示例18: addr
void SecondAuthDialog::on_signMessageButton_clicked()
{
/* Clear old signature to ensure users don't get confused on error with an old signature displayed */
ui->signatureOut->clear();
CBitcoinAddress addr(ui->addressIn->text().toStdString());
if (!addr.IsValid())
{
ui->addressIn->setValid(false);
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
ui->statusLabel->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again."));
return;
}
CKeyID keyID;
if (!addr.GetKeyID(keyID))
{
ui->addressIn->setValid(false);
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
ui->statusLabel->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again."));
return;
}
WalletModel::UnlockContext ctx(model->requestUnlock());
if (!ctx.isValid())
{
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
ui->statusLabel->setText(tr("Wallet unlock was cancelled."));
return;
}
CKey key;
if (!pwalletMain->GetKey(keyID, key))
{
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
ui->statusLabel->setText(tr("Private key for the entered address is not available."));
return;
}
uint256 hash;
hash.SetHex(ui->messageIn->text().toStdString());
CTransaction tx;
uint256 hashBlock = 0;
if (!GetTransaction(hash, tx, hashBlock) || !hashBlock) {
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
ui->statusLabel->setText(tr("No information available about transaction."));
return;
}
CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << ui->messageIn->text().toStdString();
std::vector<unsigned char> vchSig;
if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig))
{
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
ui->statusLabel->setText(QString("<nobr>") + tr("Message signing failed.") + QString("</nobr>"));
return;
}
ui->statusLabel->setStyleSheet("QLabel { color: green; }");
ui->statusLabel->setText(QString("<nobr>") + tr("Message signed.") + QString("</nobr>"));
ui->signatureOut->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size())));
}
开发者ID:BitSeedsOrg,项目名称:Bitseeds,代码行数:66,代码来源:secondauthdialog.cpp
示例19: oldVin
bool MultisigDialog::signMultisigTx(CMutableTransaction& tx, string& errorOut, QVBoxLayout* keyList)
{
//will be set false if all inputs are not fully signed(valid)
bool fComplete = true;
//if keyslist is not default value AND has items in list then true
bool fGivenKeys = (keyList != nullptr) && (keyList->count() > 0);
try{
//copy of vin for reference before vin is mutated
vector<CTxIn> oldVin(tx.vin);
CBasicKeyStore privKeystore;
//if keys were given, attempt to collect redeem and scriptpubkey
if(fGivenKeys){
for(int i = 0; i < keyList->count(); i++){
QWidget* keyFrame = qobject_cast<QWidget*>(keyList->itemAt(i)->widget());
QLineEdit* key = keyFrame->findChild<QLineEdit*>("key");
CBitcoinSecret vchSecret;
if (!vchSecret.SetString(key->text().toStdString()))
throw runtime_error("Invalid private key");
CKey cKey = vchSecret.GetKey();
if (!cKey.IsValid())
throw runtime_error("Private key outside allowed range");
privKeystore.AddKey(cKey);
}
for(CTxIn& txin : tx.vin){
//get inputs
CTransaction txVin;
uint256 hashBlock;
if (!GetTransaction(txin.prevout.hash, txVin, hashBlock, true))
throw runtime_error("txin could not be found");
if (hashBlock == 0)
throw runtime_error("txin is unconfirmed");
//get pubkey from input
CScript prevPubKey = txVin.vout[txin.prevout.n].scriptPubKey;
//get payment destination
CTxDestination address;
if(!ExtractDestination(prevPubKey, address)){
throw runtime_error("Could not find address for destination.");
}
//get redeem script related to destination
CScriptID hash = boost::get<CScriptID>(address);
CScript redeemScript;
if (!pwalletMain->GetCScript(hash, redeemScript)){
errorOut = "could not redeem";
}
privKeystore.AddCScript(redeemScript);
}
}else{
if (model->getEncryptionStatus() == model->Locked) {
if (!model->requestUnlock(true).isValid()) {
// Unlock wallet was cancelled
throw runtime_error("Error: Your wallet is locked. Please enter the wallet passphrase first.");
}
}
}
//choose between local wallet and provided
const CKeyStore& keystore = fGivenKeys ? privKeystore : *pwalletMain;
//attempt to sign each input from local wallet
int nIn = 0;
for(CTxIn& txin : tx.vin){
//get inputs
CTransaction txVin;
uint256 hashBlock;
if (!GetTransaction(txin.prevout.hash, txVin, hashBlock, true))
throw runtime_error("txin could not be found");
if (hashBlock == 0)
throw runtime_error("txin is unconfirmed");
txin.scriptSig.clear();
CScript prevPubKey = txVin.vout[txin.prevout.n].scriptPubKey;
//sign what we can
SignSignature(keystore, prevPubKey, tx, nIn);
//merge in any previous signatures
txin.scriptSig = CombineSignatures(prevPubKey, tx, nIn, txin.scriptSig, oldVin[nIn].scriptSig);
if (!VerifyScript(txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&tx, nIn))){
fComplete = false;
}
nIn++;
}
ui->signButtonStatus->setText(buildMultisigTxStatusString(fComplete, tx));
}catch(const runtime_error& e){
errorOut = string(e.what());
fComplete = false;
//.........这里部分代码省略.........
开发者ID:michaili,项目名称:PIVX,代码行数:101,代码来源:multisigdialog.cpp
示例20: LOCK
QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
{
QString strHTML;
{
LOCK(wallet->cs_wallet);
strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
int64_t nTime = wtx.GetTxTime();
int64_t nCredit = wtx.GetCredit(MINE_ALL);
int64_t nDebit = wtx.GetDebit(MINE_ALL);
int64_t nNet = nCredit - nDebit;
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
int nRequests = wtx.GetRequestCount();
if (nRequests != -1)
{
if (nRequests == 0)
strHTML += tr(", has not been successfully broadcast yet");
else if (nRequests > 0)
strHTML += tr(", broadcast through %n node(s)", "", nRequests);
}
strHTML += "<br>";
strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";
//
// From
//
if (wtx.IsCoinBase() || wtx.IsCoinStake())
{
strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
}
else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())
{
// Online transaction
strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";
}
else
{
// Offline transaction
if (nNet > 0)
{
// Credit
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
if (wallet->IsMine(txout))
{
CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
{
if (wallet->mapAddressBook.count(address))
{
std::vector<CTxDestination> addedAddresses;
for (unsigned int i = 0; i < wtx.vin.size(); i++)
{
uint256 hash;
const CTxIn& vin = wtx.vin[i];
hash.SetHex(vin.prevout.hash.ToString());
CTransaction wtxPrev;
uint256 hashBlock = 0;
if (!GetTransaction(hash, wtxPrev, hashBlock))
{
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
continue;
}
CTxDestination senderAddress;
if (!ExtractDestination(wtxPrev.vout[vin.prevout.n].scriptPubKey, senderAddress) )
{
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
}
else if(std::find(addedAddresses.begin(), addedAddresses.end(), senderAddress)
== addedAddresses.end() )
{
addedAddresses.push_back(senderAddress);
strHTML += "<b>" + tr("From") + ":</b> ";
strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(senderAddress).ToString());
if(wallet->mapAddressBook.find(senderAddress) != wallet->mapAddressBook.end())
if (!wallet->mapAddressBook[senderAddress].empty())
{
strHTML += " (" + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[senderAddress]) + ")";
}
strHTML += "<br>";
}
}
strHTML += "<b>" + tr("To") + ":</b> ";
strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString());
if (!wallet->mapAddressBook[address].empty())
strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";
else
strHTML += &quo
|
请发表评论