diff --git a/contrib/zmq/zmq_sub.py b/contrib/zmq/zmq_sub.py index decf29d42..2dbe2923b 100755 --- a/contrib/zmq/zmq_sub.py +++ b/contrib/zmq/zmq_sub.py @@ -10,8 +10,10 @@ zmqContext = zmq.Context() zmqSubSocket = zmqContext.socket(zmq.SUB) zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "hashblock") zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "hashtx") +zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "hashtxlock") zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "rawblock") zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "rawtx") +zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "rawtxlock") zmqSubSocket.connect("tcp://127.0.0.1:%i" % port) try: @@ -26,12 +28,18 @@ try: elif topic == "hashtx": print '- HASH TX -' print binascii.hexlify(body) + elif topic == "hashtxlock": + print '- HASH TX LOCK -' + print binascii.hexlify(body) elif topic == "rawblock": print "- RAW BLOCK HEADER -" print binascii.hexlify(body[:80]) elif topic == "rawtx": print '- RAW TX -' print binascii.hexlify(body) + elif topic == "rawtxlock": + print '- RAW TX LOCK -' + print binascii.hexlify(body) except KeyboardInterrupt: zmqContext.destroy() diff --git a/doc/zmq.md b/doc/zmq.md index 8d7ef37d7..f85c338b7 100644 --- a/doc/zmq.md +++ b/doc/zmq.md @@ -57,9 +57,11 @@ the commandline or in the configuration file. Currently, the following notifications are supported: -zmqpubhashtx=address + -zmqpubhashtxlock=address -zmqpubhashblock=address -zmqpubrawblock=address -zmqpubrawtx=address + -zmqpubrawtxlock=address The socket type is PUB and the address must be a valid ZeroMQ socket address. The same address can be used in more than one notification. diff --git a/src/init.cpp b/src/init.cpp index 06f9e0427..25f0cf443 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -481,8 +481,10 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageGroup(_("ZeroMQ notification options:")); strUsage += HelpMessageOpt("-zmqpubhashblock=
", _("Enable publish hash block in ")); strUsage += HelpMessageOpt("-zmqpubhashtx=", _("Enable publish hash transaction in ")); + strUsage += HelpMessageOpt("-zmqpubhashtxlock=", _("Enable publish hash transaction (locked via InstantSend) in ")); strUsage += HelpMessageOpt("-zmqpubrawblock=", _("Enable publish raw block in ")); strUsage += HelpMessageOpt("-zmqpubrawtx=", _("Enable publish raw transaction in ")); + strUsage += HelpMessageOpt("-zmqpubrawtxlock=", _("Enable publish raw transaction (locked via InstantSend) in ")); #endif strUsage += HelpMessageGroup(_("Debugging/Testing options:")); diff --git a/src/instantx.cpp b/src/instantx.cpp index 4f58e42d0..e938d082d 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -386,11 +386,12 @@ void UpdateLockedTransaction(CTransaction& tx, bool fForceNotification) { // there must be a successfully verified lock request if (!mapTxLockReq.count(txHash)) return; + int nSignatures = GetTransactionLockSignatures(txHash); + #ifdef ENABLE_WALLET if(pwalletMain && pwalletMain->UpdatedTransaction(txHash)){ // bumping this to update UI nCompleteTXLocks++; - int nSignatures = GetTransactionLockSignatures(txHash); // a transaction lock must have enough signatures to trigger this notification if(nSignatures == INSTANTX_SIGNATURES_REQUIRED || (fForceNotification && nSignatures > INSTANTX_SIGNATURES_REQUIRED)) { // notify an external script once threshold is reached @@ -403,6 +404,10 @@ void UpdateLockedTransaction(CTransaction& tx, bool fForceNotification) { } } #endif + + if(nSignatures == INSTANTX_SIGNATURES_REQUIRED || (fForceNotification && nSignatures > INSTANTX_SIGNATURES_REQUIRED)) { + GetMainSignals().NotifyTransactionLock(tx); + } } void LockTransactionInputs(CTransaction& tx) { diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 81f3b775f..b6c5752ce 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -15,6 +15,7 @@ CMainSignals& GetMainSignals() void RegisterValidationInterface(CValidationInterface* pwalletIn) { g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1)); g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2)); + g_signals.NotifyTransactionLock.connect(boost::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, _1)); g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); @@ -32,6 +33,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) { g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); + g_signals.NotifyTransactionLock.disconnect(boost::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, _1)); g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2)); g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1)); } @@ -44,6 +46,7 @@ void UnregisterAllValidationInterfaces() { g_signals.Inventory.disconnect_all_slots(); g_signals.SetBestChain.disconnect_all_slots(); g_signals.UpdatedTransaction.disconnect_all_slots(); + g_signals.NotifyTransactionLock.disconnect_all_slots(); g_signals.SyncTransaction.disconnect_all_slots(); g_signals.UpdatedBlockTip.disconnect_all_slots(); } diff --git a/src/validationinterface.h b/src/validationinterface.h index d52a96264..d621fd709 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -33,6 +33,7 @@ class CValidationInterface { protected: virtual void UpdatedBlockTip(const CBlockIndex *pindex) {} virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {} + virtual void NotifyTransactionLock(const CTransaction &tx) {} virtual void SetBestChain(const CBlockLocator &locator) {} virtual bool UpdatedTransaction(const uint256 &hash) { return false;} virtual void Inventory(const uint256 &hash) {} @@ -50,6 +51,8 @@ struct CMainSignals { boost::signals2::signal