jmcore.commitment_blacklist
jmcore.commitment_blacklist
PoDLE commitment blacklist for preventing commitment reuse.
When a PoDLE commitment is used in a CoinJoin (whether successful or failed), it should be blacklisted to prevent reuse. This module provides persistence and checking of the commitment blacklist.
The blacklist is shared across the JoinMarket network via !hp2 messages.
Classes
CommitmentBlacklist
Thread-safe commitment blacklist with file persistence.
The blacklist is stored as a simple text file with one commitment per line. This matches the reference implementation's format for compatibility.
Source code in jmcore/src/jmcore/commitment_blacklist.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Attributes
blacklist_path = blacklist_path
instance-attribute
Functions
__contains__(commitment: str) -> bool
Check if a commitment is blacklisted using 'in' operator.
Source code in jmcore/src/jmcore/commitment_blacklist.py
164 165 166 | |
__init__(blacklist_path: Path | None = None, data_dir: Path | None = None)
Initialize the commitment blacklist.
Args: blacklist_path: Path to the blacklist file. If None, uses data_dir. data_dir: Data directory for JoinMarket (defaults to get_default_data_dir()). Only used if blacklist_path is None.
Source code in jmcore/src/jmcore/commitment_blacklist.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
__len__() -> int
Return the number of blacklisted commitments.
Source code in jmcore/src/jmcore/commitment_blacklist.py
159 160 161 162 | |
add(commitment: str, persist: bool = True) -> bool
Add a commitment to the blacklist.
Args: commitment: The commitment hash (hex string) persist: If True, save to disk immediately
Returns: True if the commitment was newly added, False if already present
Source code in jmcore/src/jmcore/commitment_blacklist.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
check_and_add(commitment: str, persist: bool = True) -> bool
Check if a commitment is blacklisted, and if not, add it.
This is the primary method for handling commitments during CoinJoin. It atomically checks and adds in a single operation.
Args: commitment: The commitment hash (hex string) persist: If True, save to disk immediately after adding
Returns: True if the commitment is NEW (allowed), False if already blacklisted
Source code in jmcore/src/jmcore/commitment_blacklist.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
is_blacklisted(commitment: str) -> bool
Check if a commitment is blacklisted.
Args: commitment: The commitment hash (hex string, typically 64 chars)
Returns: True if the commitment is blacklisted, False otherwise
Source code in jmcore/src/jmcore/commitment_blacklist.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
Functions
add_commitment(commitment: str, persist: bool = True) -> bool
Add a commitment to the global blacklist.
Convenience function that uses the global blacklist.
Args: commitment: The commitment hash (hex string) persist: If True, save to disk immediately
Returns: True if the commitment was newly added, False if already present
Source code in jmcore/src/jmcore/commitment_blacklist.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
check_and_add_commitment(commitment: str, persist: bool = True) -> bool
Check if a commitment is allowed and add it to the blacklist.
Convenience function that uses the global blacklist. This is the primary function to use during CoinJoin processing.
Args: commitment: The commitment hash (hex string) persist: If True, save to disk immediately after adding
Returns: True if the commitment is NEW (allowed), False if already blacklisted
Source code in jmcore/src/jmcore/commitment_blacklist.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
check_commitment(commitment: str) -> bool
Check if a commitment is allowed (not blacklisted).
Convenience function that uses the global blacklist.
Args: commitment: The commitment hash (hex string)
Returns: True if the commitment is allowed, False if blacklisted
Source code in jmcore/src/jmcore/commitment_blacklist.py
215 216 217 218 219 220 221 222 223 224 225 226 227 | |
get_blacklist(blacklist_path: Path | None = None, data_dir: Path | None = None) -> CommitmentBlacklist
Get the global commitment blacklist instance.
Args: blacklist_path: Path to the blacklist file. Only used on first call to initialize the singleton. data_dir: Data directory for JoinMarket. Only used on first call to initialize the singleton.
Returns: The global CommitmentBlacklist instance
Source code in jmcore/src/jmcore/commitment_blacklist.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
set_blacklist_path(blacklist_path: Path | None = None, data_dir: Path | None = None) -> None
Set the path for the global blacklist.
Must be called before any blacklist operations. If the blacklist has already been initialized, this will reinitialize it with the new path.
Args: blacklist_path: Explicit path to blacklist file data_dir: Data directory (used if blacklist_path is None)
Source code in jmcore/src/jmcore/commitment_blacklist.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |