tumbler.builder
tumbler.builder
Plan builder.
Constructs a :class:~tumbler.plan.Plan from a list of destination
addresses and the current wallet state (per-mixdepth balances). Callers are
expected to hold wallet locks while reading balances; the builder itself is
pure and side-effect free so it is trivially testable.
Shape of the produced plan
The plan is a sequence of phases grouped into two conceptual stages:
- Stage 1 - origin cleavage. For every non-empty mixdepth, schedule one
:class:
~tumbler.plan.TakerCoinjoinPhasesweep to an internal address of the next mixdepth. This severs the pre-tumble coin graph before any funds reach a destination. - Stage 2 - destination mixing. For each destination, schedule a
small number of fractional taker CoinJoins, optionally interleaved with
:class:
~tumbler.plan.MakerSessionPhasesessions, and a final sweep to the destination address.
The role mixing mitigates, but does not eliminate, the subset-sum signature
problem tracked in upstream issue #114. See the design doc at
docs/technical/tumbler-redesign.md for rationale.
Attributes
INTERNAL_DESTINATION = 'INTERNAL'
module-attribute
_ = PhaseKind
module-attribute
Classes
PlanBuilder
dataclass
Turns :class:TumbleParameters into a :class:~tumbler.plan.Plan.
Source code in tumbler/src/tumbler/builder.py
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
Attributes
params: TumbleParameters
instance-attribute
wallet_name: str
instance-attribute
Methods:
build() -> Plan
Source code in tumbler/src/tumbler/builder.py
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 | |
TumbleParameters
dataclass
High-level knobs passed to :meth:PlanBuilder.build.
These are copied into :class:~tumbler.plan.PlanParameters on the plan
so the choices can be inspected later and the plan can be rebuilt for
debugging. They do not drive the runner directly.
Source code in tumbler/src/tumbler/builder.py
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 | |
Attributes
destinations: list[str]
instance-attribute
include_maker_sessions: bool = True
class-attribute
instance-attribute
maker_count_max: int = 9
class-attribute
instance-attribute
maker_count_min: int = 5
class-attribute
instance-attribute
maker_session_idle_timeout_seconds: float | None = None
class-attribute
instance-attribute
If set, maker phases exit successfully when no CoinJoin has been served within this many seconds. Useful as a safety fallback when the wallet is never selected as a counterparty.
maker_session_seconds: float = 12.0 * 60.0 * 60.0
class-attribute
instance-attribute
max_phase_retries: int = 3
class-attribute
instance-attribute
Maximum re-tries per failed taker CoinJoin phase before the plan fails.
mincjamount_sats: int = 100000
class-attribute
instance-attribute
mintxcount: int = 2
class-attribute
instance-attribute
Minimum number of destination-bearing taker CJs per mixdepth (excluding sweep).
mixdepth_balances: Mapping[int, int]
instance-attribute
Current confirmed balance per mixdepth, in satoshis.
num_destinations: int
property
rng: random.Random
property
rounding_chance: float = 0.25
class-attribute
instance-attribute
Probability that any given non-sweep taker CJ amount is rounded to a random number of significant figures. Reference default is 0.25 (25%). Set to 0.0 to disable rounding entirely. Sweeps are never rounded.
rounding_sigfig_weights: tuple[float, float, float, float, float] = (55, 15, 25, 65, 40)
class-attribute
instance-attribute
Weights for choosing the number of significant figures to round to
when rounding fires. The five weights map to 1, 2, 3, 4, 5 sigfigs
respectively. Reference defaults from
jmclient/cli_options.py:rounding_sigfig_weights.
seed: int | None = None
class-attribute
instance-attribute
stage1_wait_multiplier: float = 3.0
class-attribute
instance-attribute
Multiplier on time_lambda_seconds for stage-1 (cleavage) sweeps.
Reference default is 3x: stage-1 cuts the link to the pre-tumble coin history, so longer waits there are particularly important.
time_lambda_seconds: float = 6.0 * 60.0 * 60.0
class-attribute
instance-attribute
Average wait between phases (mean of an exponential distribution).
Default is 6 hours, matching the reference implementation's
--timelambda=360 option. Anything shorter risks defeating the
timing-correlation defence; values are clamped per-sample at 10x mean.