mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-24 05:44:30 +00:00
Bug fix: sendrawtransaction was not relaying properly
This commit is contained in:
parent
4a7d53ee23
commit
771ffb5e28
@ -10,6 +10,7 @@
|
|||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "net.h"
|
||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -454,17 +455,29 @@ Value sendrawtransaction(const Array& params, bool fHelp)
|
|||||||
catch (std::exception &e) {
|
catch (std::exception &e) {
|
||||||
throw JSONRPCError(-22, "TX decode failed");
|
throw JSONRPCError(-22, "TX decode failed");
|
||||||
}
|
}
|
||||||
|
uint256 hashTx = tx.GetHash();
|
||||||
|
|
||||||
// push to local node
|
// See if the transaction is already in a block
|
||||||
CTxDB txdb("r");
|
// or in the memory pool:
|
||||||
if (!tx.AcceptToMemoryPool(txdb))
|
CTransaction existingTx;
|
||||||
throw JSONRPCError(-22, "TX rejected");
|
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);
|
SyncWithWallets(tx, NULL, true);
|
||||||
|
}
|
||||||
|
RelayMessage(CInv(MSG_TX, hashTx), tx);
|
||||||
|
|
||||||
// relay to network
|
return hashTx.GetHex();
|
||||||
CInv inv(MSG_TX, tx.GetHash());
|
|
||||||
RelayInventory(inv);
|
|
||||||
|
|
||||||
return tx.GetHash().GetHex();
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user