Skip to content

Commit 428f304

Browse files
authored
Implement rawchainlocksig and rawtxlocksig (#2930)
* Pass is-lock into `CInstantSendManager::UpdateWalletTransaction()` * Implement `rawtxlocksig` which pushes tx+islock * Implement `rawchainlocksig` which pushes block+clsig * fix log category
1 parent c08e761 commit 428f304

20 files changed

+126
-44
lines changed

contrib/zmq/zmq_sub.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def __init__(self):
5151
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "hashinstantsenddoublespend")
5252
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawblock")
5353
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawchainlock")
54+
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawchainlocksig")
5455
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawtx")
5556
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawtxlock")
57+
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawtxlocksig")
5658
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawgovernancevote")
5759
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawgovernanceobject")
5860
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawinstantsenddoublespend")
@@ -95,12 +97,18 @@ async def handle(self) :
9597
elif topic == b"rawchainlock":
9698
print('- RAW CHAINLOCK ('+sequence+') -')
9799
print(binascii.hexlify(body[:80]).decode("utf-8"))
100+
elif topic == b"rawchainlocksig":
101+
print('- RAW CHAINLOCK SIG ('+sequence+') -')
102+
print(binascii.hexlify(body[:80]).decode("utf-8"))
98103
elif topic == b"rawtx":
99104
print('- RAW TX ('+sequence+') -')
100105
print(binascii.hexlify(body).decode("utf-8"))
101106
elif topic == b"rawtxlock":
102107
print('- RAW TX LOCK ('+sequence+') -')
103108
print(binascii.hexlify(body).decode("utf-8"))
109+
elif topic == b"rawtxlocksig":
110+
print('- RAW TX LOCK SIG ('+sequence+') -')
111+
print(binascii.hexlify(body).decode("utf-8"))
104112
elif topic == b"rawgovernancevote":
105113
print('- RAW GOVERNANCE VOTE ('+sequence+') -')
106114
print(binascii.hexlify(body).decode("utf-8"))

contrib/zmq/zmq_sub3.4.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ def __init__(self):
5555
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "hashinstantsenddoublespend")
5656
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawblock")
5757
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawchainlock")
58+
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawchainlocksig")
5859
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawtx")
5960
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawtxlock")
61+
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawtxlocksig")
6062
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawgovernancevote")
6163
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawgovernanceobject")
6264
self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "rawinstantsenddoublespend")
@@ -98,12 +100,18 @@ def handle(self) :
98100
elif topic == b"rawchainlock":
99101
print('- RAW CHAINLOCK ('+sequence+') -')
100102
print(binascii.hexlify(body[:80]).decode("utf-8"))
103+
elif topic == b"rawchainlocksig":
104+
print('- RAW CHAINLOCK SIG ('+sequence+') -')
105+
print(binascii.hexlify(body[:80]).decode("utf-8"))
101106
elif topic == b"rawtx":
102107
print('- RAW TX ('+sequence+') -')
103108
print(binascii.hexlify(body).decode("utf-8"))
104109
elif topic == b"rawtxlock":
105110
print('- RAW TX LOCK ('+sequence+') -')
106111
print(binascii.hexlify(body).decode("utf-8"))
112+
elif topic == b"rawtxlocksig":
113+
print('- RAW TX LOCK SIG ('+sequence+') -')
114+
print(binascii.hexlify(body).decode("utf-8"))
107115
elif topic == b"rawgovernancevote":
108116
print('- RAW GOVERNANCE VOTE ('+sequence+') -')
109117
print(binascii.hexlify(body).decode("utf-8"))

doc/zmq.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ Currently, the following notifications are supported:
6565
-zmqpubhashinstantsenddoublespend=address
6666
-zmqpubrawblock=address
6767
-zmqpubrawchainlock=address
68+
-zmqpubrawchainlocksig=address
6869
-zmqpubrawtx=address
6970
-zmqpubrawtxlock=address
71+
-zmqpubrawtxlocksig=address
7072
-zmqpubrawgovernancevote=address
7173
-zmqpubrawgovernanceobject=address
7274
-zmqpubrawinstantsenddoublespend=address

src/dsnotificationinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDet
8888
governance.UpdateCachesAndClean();
8989
}
9090

91-
void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex)
91+
void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLockSig& clsig)
9292
{
9393
llmq::quorumInstantSendManager->NotifyChainLock(pindex);
9494
}

src/dsnotificationinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CDSNotificationInterface : public CValidationInterface
2323
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
2424
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) override;
2525
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) override;
26-
void NotifyChainLock(const CBlockIndex* pindex) override;
26+
void NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLockSig& clsig) override;
2727

2828
private:
2929
CConnman& connman;

src/instantsend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ void CInstantSend::UpdateLockedTransaction(const CTxLockCandidate& txLockCandida
539539
}
540540
#endif
541541

542-
GetMainSignals().NotifyTransactionLock(*txLockCandidate.txLockRequest.tx);
542+
llmq::CInstantSendLock islock;
543+
GetMainSignals().NotifyTransactionLock(*txLockCandidate.txLockRequest.tx, islock);
543544

544545
LogPrint(BCLog::INSTANTSEND, "CInstantSend::UpdateLockedTransaction -- done, txid=%s\n", txHash.ToString());
545546
}

src/llmq/quorums_chainlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ void CChainLocksHandler::EnforceBestChainLock()
526526
}
527527

528528
if (pindexNotify) {
529-
GetMainSignals().NotifyChainLock(pindexNotify);
529+
GetMainSignals().NotifyChainLock(pindexNotify, clsig);
530530
}
531531
}
532532

src/llmq/quorums_instantsend.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -920,31 +920,33 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, const uint256& has
920920

921921
RemoveMempoolConflictsForLock(hash, islock);
922922
ResolveBlockConflicts(hash, islock);
923-
UpdateWalletTransaction(islock.txid, tx);
923+
UpdateWalletTransaction(tx, islock);
924924
}
925925

926-
void CInstantSendManager::UpdateWalletTransaction(const uint256& txid, const CTransactionRef& tx)
926+
void CInstantSendManager::UpdateWalletTransaction(const CTransactionRef& tx, const CInstantSendLock& islock)
927927
{
928+
if (tx == nullptr) {
929+
return;
930+
}
931+
928932
#ifdef ENABLE_WALLET
929933
if (!pwalletMain) {
930934
return;
931935
}
932936

933-
if (pwalletMain->UpdatedTransaction(txid)) {
937+
if (pwalletMain->UpdatedTransaction(tx->GetHash())) {
934938
// notify an external script once threshold is reached
935939
std::string strCmd = GetArg("-instantsendnotify", "");
936940
if (!strCmd.empty()) {
937-
boost::replace_all(strCmd, "%s", txid.GetHex());
941+
boost::replace_all(strCmd, "%s", tx->GetHash().GetHex());
938942
boost::thread t(runCommand, strCmd); // thread runs free
939943
}
940944
}
941945
#endif
942946

943-
if (tx) {
944-
GetMainSignals().NotifyTransactionLock(*tx);
945-
// bump mempool counter to make sure newly mined txes are picked up by getblocktemplate
946-
mempool.AddTransactionsUpdated(1);
947-
}
947+
GetMainSignals().NotifyTransactionLock(*tx, islock);
948+
// bump mempool counter to make sure newly mined txes are picked up by getblocktemplate
949+
mempool.AddTransactionsUpdated(1);
948950
}
949951

950952
void CInstantSendManager::SyncTransaction(const CTransaction& tx, const CBlockIndex* pindex, int posInBlock)

src/llmq/quorums_instantsend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class CInstantSendManager : public CRecoveredSigsListener
139139
bool PreVerifyInstantSendLock(NodeId nodeId, const CInstantSendLock& islock, bool& retBan);
140140
bool ProcessPendingInstantSendLocks();
141141
void ProcessInstantSendLock(NodeId from, const uint256& hash, const CInstantSendLock& islock);
142-
void UpdateWalletTransaction(const uint256& txid, const CTransactionRef& tx);
142+
void UpdateWalletTransaction(const CTransactionRef& tx, const CInstantSendLock& islock);
143143

144144
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock);
145145
void AddNonLockedTx(const CTransactionRef& tx);

src/validationinterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
1717
g_signals.NotifyHeaderTip.connect(boost::bind(&CValidationInterface::NotifyHeaderTip, pwalletIn, _1, _2));
1818
g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
1919
g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));
20-
g_signals.NotifyTransactionLock.connect(boost::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, _1));
21-
g_signals.NotifyChainLock.connect(boost::bind(&CValidationInterface::NotifyChainLock, pwalletIn, _1));
20+
g_signals.NotifyTransactionLock.connect(boost::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, _1, _2));
21+
g_signals.NotifyChainLock.connect(boost::bind(&CValidationInterface::NotifyChainLock, pwalletIn, _1, _2));
2222
g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
2323
g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
2424
g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
@@ -41,8 +41,8 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
4141
g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
4242
g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
4343
g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
44-
g_signals.NotifyChainLock.disconnect(boost::bind(&CValidationInterface::NotifyChainLock, pwalletIn, _1));
45-
g_signals.NotifyTransactionLock.disconnect(boost::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, _1));
44+
g_signals.NotifyChainLock.disconnect(boost::bind(&CValidationInterface::NotifyChainLock, pwalletIn, _1, _2));
45+
g_signals.NotifyTransactionLock.disconnect(boost::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, _1, _2));
4646
g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));
4747
g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
4848
g_signals.NewPoWValidBlock.disconnect(boost::bind(&CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2));

0 commit comments

Comments
 (0)