Bitcoin Forum
April 28, 2024, 05:18:04 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is the fastest and most memory-efficient way to check for RBF-bumped txs?  (Read 74 times)
NotATether (OP)
Legendary
*
Online Online

Activity: 1582
Merit: 6701


bitcoincleanup.com / bitmixlist.org


View Profile WWW
July 06, 2023, 12:54:43 PM
Merited by hugeblack (2)
 #1

In my code, I have a list of transactions from Satoshi's address (the 1A1z... address from the Genesis block), but there is at least one pair of transactions which are i) unconfirmed and ii) one of these transactions bumped the other using RBF, which means the one with smaller fee is invalid and should be dumped.

To safe you time, it's these two:

Code:
 {'address': '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa',
  'txid': '8784c4c7f32a9173ef33030f87fc07c00db13222c9b112c850adbe08dcb49775',
  'index': 0,
  'amount': 5.58e-06,
  'height': None},
 {'address': '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa',
  'txid': 'd081505e5ffc3a1110ba47d09f1273b2ae35297c12e34f5dfdcf72d264e0c90d',
  'index': 1,
  'amount': 5.58e-06,
  'height': None}

As I said, I have the list of transactions including these two and I also have vsize and fee/vbyte information. So now I need to find an algorithm that hopefully does not involve looking back at every UTXO that has just been processed, looking for duplicates (because that will take O(N^2) time, and I'm hoping there's something closer to O(N log N) or even O(N)).

For context: This is with Python.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
1714324684
Hero Member
*
Offline Offline

Posts: 1714324684

View Profile Personal Message (Offline)

Ignore
1714324684
Reply with quote  #2

1714324684
Report to moderator
Once a transaction has 6 confirmations, it is extremely unlikely that an attacker without at least 50% of the network's computation power would be able to reverse it.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714324684
Hero Member
*
Offline Offline

Posts: 1714324684

View Profile Personal Message (Offline)

Ignore
1714324684
Reply with quote  #2

1714324684
Report to moderator
1714324684
Hero Member
*
Offline Offline

Posts: 1714324684

View Profile Personal Message (Offline)

Ignore
1714324684
Reply with quote  #2

1714324684
Report to moderator
1714324684
Hero Member
*
Offline Offline

Posts: 1714324684

View Profile Personal Message (Offline)

Ignore
1714324684
Reply with quote  #2

1714324684
Report to moderator
witcher_sense
Legendary
*
Offline Offline

Activity: 2310
Merit: 4313

🔐BitcoinMessage.Tools🔑


View Profile WWW
July 07, 2023, 07:31:27 AM
Merited by hugeblack (2)
 #2

As far as I know, collections.Counter can be used to find and extract duplicates in an array with a time and space complexity of O(N). You also need to apply additional filtering based on the count of similar transactions, fee parameters, and probably transaction status. Use list comprehensions to build these filters because they are more memory-efficient than in-built functions such as map and filter.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!