@@ -1947,9 +1947,9 @@ void PeerManagerImpl::BlockConnected(
19471947 {
19481948 LOCK (m_recent_confirmed_transactions_mutex);
19491949 for (const auto & ptx : pblock->vtx ) {
1950- m_recent_confirmed_transactions.insert (ptx->GetHash ());
1951- if (ptx->GetHash () != ptx-> GetWitnessHash ()) {
1952- m_recent_confirmed_transactions.insert (ptx->GetWitnessHash ());
1950+ m_recent_confirmed_transactions.insert (ptx->GetHash (). ToUint256 () );
1951+ if (ptx->HasWitness ()) {
1952+ m_recent_confirmed_transactions.insert (ptx->GetWitnessHash (). ToUint256 () );
19531953 }
19541954 }
19551955 }
@@ -3003,8 +3003,8 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
30033003 while (CTransactionRef porphanTx = m_orphanage.GetTxToReconsider (peer.m_id )) {
30043004 const MempoolAcceptResult result = m_chainman.ProcessTransaction (porphanTx);
30053005 const TxValidationState& state = result.m_state ;
3006- const uint256 & orphanHash = porphanTx->GetHash ();
3007- const uint256 & orphan_wtxid = porphanTx->GetWitnessHash ();
3006+ const Txid & orphanHash = porphanTx->GetHash ();
3007+ const Wtxid & orphan_wtxid = porphanTx->GetWitnessHash ();
30083008
30093009 if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
30103010 LogPrint (BCLog::TXPACKAGES, " accepted orphan tx %s (wtxid=%s)\n " , orphanHash.ToString (), orphan_wtxid.ToString ());
@@ -3052,7 +3052,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
30523052 // See also comments in https://github.com/bitcoin/bitcoin/pull/18044#discussion_r443419034
30533053 // for concerns around weakening security of unupgraded nodes
30543054 // if we start doing this too early.
3055- m_recent_rejects.insert (porphanTx->GetWitnessHash ());
3055+ m_recent_rejects.insert (porphanTx->GetWitnessHash (). ToUint256 () );
30563056 // If the transaction failed for TX_INPUTS_NOT_STANDARD,
30573057 // then we know that the witness was irrelevant to the policy
30583058 // failure, since this check depends only on the txid
@@ -3061,10 +3061,10 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
30613061 // processing of this transaction in the event that child
30623062 // transactions are later received (resulting in
30633063 // parent-fetching by txid via the orphan-handling logic).
3064- if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && porphanTx->GetWitnessHash () != porphanTx-> GetHash ()) {
3064+ if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && porphanTx->HasWitness ()) {
30653065 // We only add the txid if it differs from the wtxid, to
30663066 // avoid wasting entries in the rolling bloom filter.
3067- m_recent_rejects.insert (porphanTx->GetHash ());
3067+ m_recent_rejects.insert (porphanTx->GetHash (). ToUint256 () );
30683068 }
30693069 }
30703070 m_orphanage.EraseTx (orphanHash);
@@ -4319,8 +4319,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
43194319 // regardless of what witness is provided, we will not accept
43204320 // this, so we don't need to allow for redownload of this txid
43214321 // from any of our non-wtxidrelay peers.
4322- m_recent_rejects.insert (tx.GetHash ());
4323- m_recent_rejects.insert (tx.GetWitnessHash ());
4322+ m_recent_rejects.insert (tx.GetHash (). ToUint256 () );
4323+ m_recent_rejects.insert (tx.GetWitnessHash (). ToUint256 () );
43244324 m_txrequest.ForgetTxHash (tx.GetHash ());
43254325 m_txrequest.ForgetTxHash (tx.GetWitnessHash ());
43264326 }
@@ -4339,7 +4339,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
43394339 // See also comments in https://github.com/bitcoin/bitcoin/pull/18044#discussion_r443419034
43404340 // for concerns around weakening security of unupgraded nodes
43414341 // if we start doing this too early.
4342- m_recent_rejects.insert (tx.GetWitnessHash ());
4342+ m_recent_rejects.insert (tx.GetWitnessHash (). ToUint256 () );
43434343 m_txrequest.ForgetTxHash (tx.GetWitnessHash ());
43444344 // If the transaction failed for TX_INPUTS_NOT_STANDARD,
43454345 // then we know that the witness was irrelevant to the policy
@@ -4349,8 +4349,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
43494349 // processing of this transaction in the event that child
43504350 // transactions are later received (resulting in
43514351 // parent-fetching by txid via the orphan-handling logic).
4352- if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && tx.GetWitnessHash () != tx. GetHash ()) {
4353- m_recent_rejects.insert (tx.GetHash ());
4352+ if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && tx.HasWitness ()) {
4353+ m_recent_rejects.insert (tx.GetHash (). ToUint256 () );
43544354 m_txrequest.ForgetTxHash (tx.GetHash ());
43554355 }
43564356 if (RecursiveDynamicUsage (*ptx) < 100000 ) {
@@ -5780,17 +5780,22 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
57805780 LOCK (tx_relay->m_bloom_filter_mutex );
57815781
57825782 for (const auto & txinfo : vtxinfo) {
5783- const uint256& hash = peer->m_wtxid_relay ? txinfo.tx ->GetWitnessHash () : txinfo.tx ->GetHash ();
5784- CInv inv (peer->m_wtxid_relay ? MSG_WTX : MSG_TX, hash);
5785- tx_relay->m_tx_inventory_to_send .erase (hash);
5783+ CInv inv{
5784+ peer->m_wtxid_relay ? MSG_WTX : MSG_TX,
5785+ peer->m_wtxid_relay ?
5786+ txinfo.tx ->GetWitnessHash ().ToUint256 () :
5787+ txinfo.tx ->GetHash ().ToUint256 (),
5788+ };
5789+ tx_relay->m_tx_inventory_to_send .erase (inv.hash );
5790+
57865791 // Don't send transactions that peers will not put into their mempool
57875792 if (txinfo.fee < filterrate.GetFee (txinfo.vsize )) {
57885793 continue ;
57895794 }
57905795 if (tx_relay->m_bloom_filter ) {
57915796 if (!tx_relay->m_bloom_filter ->IsRelevantAndUpdate (*txinfo.tx )) continue ;
57925797 }
5793- tx_relay->m_tx_inventory_known_filter .insert (hash);
5798+ tx_relay->m_tx_inventory_known_filter .insert (inv. hash );
57945799 vInv.push_back (inv);
57955800 if (vInv.size () == MAX_INV_SZ) {
57965801 m_connman.PushMessage (pto, msgMaker.Make (NetMsgType::INV, vInv));
0 commit comments