本文整理汇总了C++中CTransaction::AcceptToMemoryPool方法的典型用法代码示例。如果您正苦于以下问题:C++ CTransaction::AcceptToMemoryPool方法的具体用法?C++ CTransaction::AcceptToMemoryPool怎么用?C++ CTransaction::AcceptToMemoryPool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTransaction
的用法示例。
在下文中一共展示了CTransaction::AcceptToMemoryPool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_sendTransactionButton_clicked
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);
}
示例2: sendrawtransaction
Value sendrawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 1)
throw runtime_error(
"sendrawtransaction <hex string>\n"
"Submits raw transaction (serialized, hex-encoded) to local node and network.");
//RPCTypeCheck(params, list_of(str_type));
// parse hex string from parameter
vector<unsigned char> txData(ParseHex(params[0].get_str()));
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
CTransaction tx;
// deserialize binary data stream
try {
ssData >> tx;
}
catch (std::exception &e) {
throw JSONRPCError(-22, "TX decode failed");
}
uint256 hashTx = tx.GetHash();
// See if the transaction is already in a block
// or in the memory pool:
CTransaction existingTx;
uint256 hashBlock = 0;
//if (GetTransaction(hashTx, existingTx, hashBlock))
//{
// if (hashBlock != 0)
// throw JSONRPCError(-5, string("transaction already in block ")+hashBlock.GetHex());
// // Not in block, but already in the memory pool; will drop
// // through to re-relay it.
//}
//else
{
// push to local node
CTxDB txdb("r");
if (!tx.AcceptToMemoryPool(txdb))
throw JSONRPCError(-22, "TX rejected");
SyncWithWallets(tx, NULL, true);
}
RelayMessage(CInv(MSG_TX, hashTx), tx);
return hashTx.GetHex();
}