本文整理汇总了C++中GetTransaction函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTransaction函数的具体用法?C++ GetTransaction怎么用?C++ GetTransaction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetTransaction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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"));
}
}
示例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();
}
示例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;
}
示例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;
}
示例7: GetTransaction
bool MgServerFeatureTransactionPool::RollbackTransaction(CREFSTRING transactionId)
{
Ptr<MgServerFeatureTransaction> tran = GetTransaction(transactionId);
if (NULL != tran.p)
{
tran->Rollback();
}
return RemoveTransaction(transactionId);
}
示例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);
}
示例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);
}
示例10: ValidateTimeout
bool MgServerFeatureTransactionPool::CommitTransaction(CREFSTRING transactionId)
{
ValidateTimeout(transactionId);
Ptr<MgServerFeatureTransaction> tran = GetTransaction(transactionId);
if (NULL != tran.p)
{
tran->Commit();
}
return RemoveTransaction(transactionId);
}
示例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() + ")");
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}