More of 80% of the pending transacction on mempool are dust.Well that is actually anoying i did a small sampling from the mempool pending TXs and I count only those with one input, one ouput and output value less than 600 satoshis, and more of the 80% of those match with this criteria.
Here is the code that i used was:
import sys
import json
import math
import time
import random
import requests
def round_up_to_decimals(number, decimals):
factor = 10 ** decimals
rounded_number = math.ceil(number * factor) / factor
return rounded_number
def get_tx(txid):
tx = None
try:
url = ""
if networkname=="bitcoin":
url = "https://mempool.space/api/tx/" + txid
elif networkname=="testnet":
url = "https://mempool.space/testnet/api/tx/" + txid
else:
print("Unknow network")
exit()
response = requests.get(url)
if response.status_code == 200:
tx = response.json()
return tx
else:
return tx
except Exception as e:
print(f"An error occurred: {e}")
return tx
def get_mempool_txids():
time.sleep(0.01)
txids = []
try:
url = ""
if networkname=="bitcoin":
url = "https://mempool.space/api/mempool/txids"
elif networkname=="testnet":
url = "https://mempool.space/testnet/api/mempool/txids"
else:
print("Unknow network")
exit()
response = requests.get(url)
if response.status_code == 200:
txids = response.json()
return txids
except Exception as e:
print(f"An error occurred: {e}")
return txids
networkname = "bitcoin"
print("Downloading mempool txids list")
txids = get_mempool_txids()
# Save in to file optional
#print("Saving file....")
#with open("mempooltxids.txt", "w") as file:
# file.writelines("%s\n" % txid for txid in txids)
if len(txids) == 0:
print("Error getting mempool TX")
print(f"Total TX on mempool: {len(txids)}")
dust_counter = 0
total_counter = 0
for i in range(0,1000):
txid = random.choice(txids)
tx = get_tx(txid)
if(tx is None):
print(f"Error")
dust_percentage = 100 * (round_up_to_decimals(dust_counter/total_counter,4))
print(f"\nTotal dust tx found {dust_counter} of {total_counter}: %{dust_percentage}")
exit()
if(len(tx['vin']) == 1 and len(tx['vout']) == 1 and tx['vout'][0]['value'] < 600):
dust_counter += 1
#txids.remove(txid)
total_counter += 1
print(".",end="")
sys.stdout.flush()
dust_percentage = 100 * (round_up_to_decimals(dust_counter/total_counter,2))
print(f"\nTotal dust txs found {dust_counter} of {total_counter}: %{dust_percentage}")
Output:
albertobsd:~$ python3 count_dust_tx_mempool.py
Downloading mempool txids list
Saving file....
Total TX on mempool: 564411
...
Total dust txs found 855 of 1000: %85.5
According to the Mempool.space API documentation:
GET Mempool Transaction IDs
Get the full list of txids in the mempool as an array. The order of the txids is arbitrary and does not match bitcoind.
I use random choice in python
The choice() method returns a randomly selected element from the specified sequence.
So in general this problem may get worse in the future if the ordinals don't stop their SPAM