<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title>Chemaclass - tutorial</title><subtitle>Tech Lead sharing practical insights on software craftsmanship, TDD, leadership, Bitcoin, and AI. Blog posts, book summaries, and conference talks.</subtitle><link rel="self" type="application/atom+xml" href="https://chemaclass.com/tags/tutorial/atom.xml"/><link rel="alternate" type="text/html" href="https://chemaclass.com"/><generator uri="https://www.getzola.org/">Zola</generator><updated>2026-04-17T00:00:00+00:00</updated><id>https://chemaclass.com/tags/tutorial/atom.xml</id><entry xml:lang="en"><title>Inside the .claude Folder</title><subtitle>A tutorial through rules, skills, agents, hooks, and settings</subtitle><category term="ai" scheme="https://chemaclass.com/tags/ai/" label="Ai"/><category term="software" scheme="https://chemaclass.com/tags/software/" label="Software"/><category term="tutorial" scheme="https://chemaclass.com/tags/tutorial/" label="Tutorial"/><category term="craftsmanship" scheme="https://chemaclass.com/tags/craftsmanship/" label="Craftsmanship"/><category term="developer-tools" scheme="https://chemaclass.com/tags/developer-tools/" label="Developer Tools"/><category term="productivity" scheme="https://chemaclass.com/tags/productivity/" label="Productivity"/><published>2026-04-17T00:00:00+00:00</published><updated>2026-04-17T00:00:00+00:00</updated><author><name>
Chemaclass</name></author><link rel="alternate" type="text/html" href="https://chemaclass.com/blog/inside-the-claude-folder/"/><id>https://chemaclass.com/blog/inside-the-claude-folder/</id><summary type="html">A hands-on tour of Claude Code's project folder. What rules, skills, agents, hooks, and settings each do, and how they fit together.</summary><content type="html">&lt;p>Every project I work on has a &lt;code>.claude/&lt;/code> folder at the root. Committed to git, like the rest of the code.&lt;/p>
&lt;p>That folder turns Claude Code from a generic assistant into a project-aware teammate. Everyone who clones the repo inherits the same setup.&lt;/p>
&lt;p>Agentic coding is only as good as the context you give the agent. The &lt;code>.claude/&lt;/code> folder is where that context lives.&lt;/p>
&lt;span id="continue-reading">&lt;/span>&lt;h2 id="the-claude-folder-at-a-glance">The .claude folder, at a glance
&lt;a class="heading-anchor" href="#the-claude-folder-at-a-glance" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="plain">&lt;span class="giallo-l">&lt;span>.claude/&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>├── CLAUDE.md # project onboarding&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>├── settings.json # permissions, hooks, env&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>├── skills/ # reusable procedures (slash commands)&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>├── rules/ # glob-targeted conventions&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>├── hooks/ # shell scripts run on events&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>└── agents/ # specialized roles&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>Six layers, one folder. Context, safety, procedures, guardrails, automation, specialists.&lt;/p>
&lt;h2 id="the-foundation">The foundation
&lt;a class="heading-anchor" href="#the-foundation" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="claude-md-where-everything-starts">CLAUDE.md: where everything starts
&lt;a class="heading-anchor" href="#claude-md-where-everything-starts" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Claude Code reads &lt;code>CLAUDE.md&lt;/code> on every boot. The onboarding doc.&lt;/p>
&lt;p>In &lt;a rel="external" href="https://github.com/phel-lang/phel-lang">Phel&lt;/a>, mine covers the compiler pipeline (Lexer → Parser → Analyzer → Emitter), module structure, conventions, and key commands.&lt;/p>
&lt;p>A global &lt;code>~/.claude/CLAUDE.md&lt;/code> applies to &lt;em>all&lt;/em> your projects. The project file says &lt;em>how this codebase works&lt;/em>. The global file says &lt;em>how I work&lt;/em>.&lt;/p>
&lt;p>Every byte ships in every prompt. Keep it short.
Past one screen, move detail into &lt;code>rules/&lt;/code> or &lt;code>skills/&lt;/code>.&lt;/p>
&lt;blockquote>
&lt;p>A good &lt;code>CLAUDE.md&lt;/code> is a good onboarding doc. The better it is, the less you repeat yourself.&lt;/p>
&lt;/blockquote>
&lt;h3 id="settings-json-safety-before-leverage">settings.json: safety before leverage
&lt;a class="heading-anchor" href="#settings-json-safety-before-leverage" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Before giving the agent more power, lock down what it must never do.&lt;/p>
&lt;p>&lt;code>.claude/settings.json&lt;/code> holds three things: &lt;strong>permissions&lt;/strong> (allow/deny), &lt;strong>hooks&lt;/strong> (event commands), and &lt;strong>env&lt;/strong> (variables). A gitignored &lt;code>settings.local.json&lt;/code> keeps personal overrides separate.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Permissions example from Phel&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="json">&lt;span class="giallo-l">&lt;span>{&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">permissions&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> {&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">allow&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> [&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Bash(composer:*)&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Bash(./bin/phel:*)&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Bash(git:*)&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Bash(gh:*)&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span> ]&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">deny&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> [&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Bash(rm -rf:*)&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Bash(sudo:*)&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span> ]&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span> }&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>}&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;/div>
&lt;/details>
&lt;p>Allow unlocks flow. Deny draws the line agents cannot cross, even when asked politely.&lt;/p>
&lt;blockquote>
&lt;p>Permissions are the floor. Everything else builds on top of a safe baseline.&lt;/p>
&lt;/blockquote>
&lt;h2 id="procedures-and-guardrails">Procedures and guardrails
&lt;a class="heading-anchor" href="#procedures-and-guardrails" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="skills-procedures-you-can-run">Skills: procedures you can run
&lt;a class="heading-anchor" href="#skills-procedures-you-can-run" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Next pain after onboarding: repetition. Skills solve that.&lt;/p>
&lt;p>A skill is a markdown file in &lt;code>.claude/skills/&lt;/code>, a procedure you call with a slash:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>&lt;code>/gh-issue &amp;lt;number&amp;gt;&lt;/code>&lt;/strong>: issue to branch, TDD plan, PR.&lt;/li>
&lt;li>&lt;strong>&lt;code>/commit&lt;/code>&lt;/strong>: fix, analysis, tests, conventional commit.&lt;/li>
&lt;li>&lt;strong>&lt;code>/refactor-check&lt;/code>&lt;/strong>: SOLID, naming, architecture smells.&lt;/li>
&lt;li>&lt;strong>&lt;code>/release [version]&lt;/code>&lt;/strong>: changelog, PHAR, tag, release.&lt;/li>
&lt;/ul>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Skills vs rules vs raw prompting&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;ul>
&lt;li>&lt;strong>Raw prompt&lt;/strong>: &lt;em>“fix issue #42”&lt;/em>. Agent improvises. Different every time.&lt;/li>
&lt;li>&lt;strong>Rule&lt;/strong>: &lt;em>“use conventional commits”&lt;/em>. Shapes output, not procedure.&lt;/li>
&lt;li>&lt;strong>Skill&lt;/strong>: &lt;em>“&lt;code>/gh-issue 42&lt;/code>”&lt;/em>. The procedure &lt;em>is&lt;/em> the instruction.&lt;/li>
&lt;/ul>
&lt;p>Skills turn tribal knowledge into runnable steps anyone can execute.&lt;/p>
&lt;/div>
&lt;/details>
&lt;blockquote>
&lt;p>Skills capture what to do. Rules capture what not to do.&lt;/p>
&lt;/blockquote>
&lt;h3 id="rules-the-guardrails">Rules: the guardrails
&lt;a class="heading-anchor" href="#rules-the-guardrails" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>&lt;code>CLAUDE.md&lt;/code> is read every session. Rules only when they match. Files in &lt;code>.claude/rules/&lt;/code> target code areas with glob patterns: the agent loads only what applies, keeping context lean.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Glob-targeted rules in practice&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>Rule files in Phel:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>&lt;code>compiler.md&lt;/code>&lt;/strong>: strict 4-phase pipeline, no bypassing.&lt;/li>
&lt;li>&lt;strong>&lt;code>php.md&lt;/code>&lt;/strong>: PER 3.0, &lt;code>final&lt;/code> classes, &lt;code>readonly&lt;/code>, Gacela.&lt;/li>
&lt;li>&lt;strong>&lt;code>phel.md&lt;/code>&lt;/strong>: kebab-case, &lt;code>defn-&lt;/code> private, &lt;code>:doc&lt;/code>/&lt;code>:example&lt;/code> required.&lt;/li>
&lt;li>&lt;strong>&lt;code>integration-tests.md&lt;/code>&lt;/strong>: &lt;code>--PHEL--&lt;/code> / &lt;code>--PHP--&lt;/code> fixture sections.&lt;/li>
&lt;/ul>
&lt;p>Compiler rules don’t fire when editing Phel source. Phel rules don’t fire when editing PHP infrastructure.&lt;/p>
&lt;/div>
&lt;/details>
&lt;p>Rules are not suggestions. They travel with the code: a convention change and its rule ship in the same commit. No drift, no outdated wiki.&lt;/p>
&lt;p>&lt;img src="/images/blog/2026-04-17/middle.webp" alt="blog-middle" />&lt;/p>
&lt;h2 id="automation-and-delegation">Automation and delegation
&lt;a class="heading-anchor" href="#automation-and-delegation" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="hooks-automation-at-the-edges">Hooks: automation at the edges
&lt;a class="heading-anchor" href="#hooks-automation-at-the-edges" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Rules tell the agent what to do. Hooks make sure it happens even if the agent forgets.&lt;/p>
&lt;p>Shell commands triggered by Claude Code events (&lt;code>PreToolUse&lt;/code>, &lt;code>PostToolUse&lt;/code>, &lt;code>Stop&lt;/code>), wired through &lt;code>settings.json&lt;/code>. In Phel, &lt;code>PreToolUse&lt;/code> blocks edits to critical files (&lt;code>build/release.sh&lt;/code>, &lt;code>.github/*&lt;/code>, &lt;code>composer.lock&lt;/code>). &lt;code>PostToolUse&lt;/code> auto-formats PHP via &lt;code>php-cs-fixer&lt;/code>.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Hooks wiring&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="json">&lt;span class="giallo-l">&lt;span>{&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">hooks&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> {&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PreToolUse&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> [&lt;/span>&lt;span>{&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">matcher&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Edit|Write&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">hooks&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> [&lt;/span>&lt;span>{&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">type&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">command&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">command&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">.claude/hooks/protect-files.sh&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span> }&lt;/span>&lt;span>]&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span> }&lt;/span>&lt;span>]&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PostToolUse&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> [&lt;/span>&lt;span>{&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">matcher&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Edit|Write&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">hooks&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span> [&lt;/span>&lt;span>{&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">type&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">command&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span>,&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">command&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">&amp;quot;&lt;/span>&lt;span>:&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">.claude/hooks/format-php.sh&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;span> }&lt;/span>&lt;span>]&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span> }&lt;/span>&lt;span>]&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span> }&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span>}&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;/div>
&lt;/details>
&lt;blockquote>
&lt;p>Rules are what the agent should know. Hooks are what the system enforces anyway.&lt;/p>
&lt;/blockquote>
&lt;h3 id="agents-specialized-roles">Agents: specialized roles
&lt;a class="heading-anchor" href="#agents-specialized-roles" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Everything so far shapes one agent. Agents add specialists the main agent can delegate to, each with its own tools, permissions, and model. Most advanced piece. Recommend it last.&lt;/p>
&lt;p>A few from Phel:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Explorer&lt;/strong> (Sonnet, read-only): files, structure mapping.&lt;/li>
&lt;li>&lt;strong>Clean Code Reviewer&lt;/strong>: SOLID and naming on diffs.&lt;/li>
&lt;li>&lt;strong>TDD Coach&lt;/strong>: red-green-refactor enforcement.&lt;/li>
&lt;li>&lt;strong>Domain Architect&lt;/strong>: module boundaries, compiler pipeline.&lt;/li>
&lt;li>&lt;strong>Debugger&lt;/strong>: compiler errors across all phases.&lt;/li>
&lt;/ul>
&lt;p>Each agent runs in its own context window: the main session stays clean while the specialist digs deep. The win is not only cost, it is focus. An agent with only read and grep cannot rewrite your codebase by mistake.&lt;/p>
&lt;blockquote>
&lt;p>Right model for the right job. Fast and cheap for exploration. Deep and careful for architecture.&lt;/p>
&lt;/blockquote>
&lt;h2 id="start-small-grow-with-friction">Start small, grow with friction
&lt;a class="heading-anchor" href="#start-small-grow-with-friction" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Do not build all of this on day one.&lt;/p>
&lt;p>The order, driven by real friction:&lt;/p>
&lt;ol>
&lt;li>Start with &lt;a href="https://chemaclass.com/blog/inside-the-claude-folder/#claude-md-where-everything-starts">&lt;code>CLAUDE.md&lt;/code>&lt;/a>.&lt;/li>
&lt;li>Lock down &lt;a href="https://chemaclass.com/blog/inside-the-claude-folder/#settings-json-safety-before-leverage">&lt;code>settings.json&lt;/code>&lt;/a> permissions.&lt;/li>
&lt;li>First time you repeat yourself, write a &lt;a href="https://chemaclass.com/blog/inside-the-claude-folder/#skills-procedures-you-can-run">skill&lt;/a>.&lt;/li>
&lt;li>First time the agent breaks a convention, add a &lt;a href="https://chemaclass.com/blog/inside-the-claude-folder/#rules-the-guardrails">rule&lt;/a>.&lt;/li>
&lt;li>First time something bad almost gets committed, add a &lt;a href="https://chemaclass.com/blog/inside-the-claude-folder/#hooks-automation-at-the-edges">hook&lt;/a>.&lt;/li>
&lt;li>First time a generalist is wrong for the job, define a &lt;a href="https://chemaclass.com/blog/inside-the-claude-folder/#agents-specialized-roles">specialist&lt;/a>.&lt;/li>
&lt;/ol>
&lt;p>Each step fixes a problem you actually had. Not one you imagined.&lt;/p>
&lt;blockquote>
&lt;p>The setup grows from real friction, not from upfront design.&lt;/p>
&lt;/blockquote>
&lt;p>Commit the folder. Share it. When someone joins, their session inherits everything.&lt;/p>
&lt;p>Treat &lt;code>.claude/&lt;/code> like infrastructure. Version it. Review it. Evolve it with the codebase.&lt;/p>
&lt;p>&lt;img src="/images/blog/2026-04-17/footer.webp" alt="blog-footer" />&lt;/p></content></entry><entry xml:lang="en"><title>How Bitcoin Works</title><subtitle>Blockchain, cryptography, and consensus</subtitle><category term="bitcoin" scheme="https://chemaclass.com/tags/bitcoin/" label="Bitcoin"/><category term="cryptography" scheme="https://chemaclass.com/tags/cryptography/" label="Cryptography"/><category term="tutorial" scheme="https://chemaclass.com/tags/tutorial/" label="Tutorial"/><published>2025-12-22T00:00:00+00:00</published><updated>2025-12-22T00:00:00+00:00</updated><author><name>
Chemaclass</name></author><link rel="alternate" type="text/html" href="https://chemaclass.com/blog/how-bitcoin-works/"/><id>https://chemaclass.com/blog/how-bitcoin-works/</id><summary type="html">Transactions, blocks, mining, the UTXO model, and Lightning Network: how Bitcoin actually works under the hood, explained in plain terms.</summary><content type="html">&lt;p>This post explains how Bitcoin works under the hood. If you’re looking for why Bitcoin matters, start with &lt;a href="/blog/bitcoin-fundamentals/">Bitcoin Fundamentals&lt;/a>.&lt;/p>
&lt;span id="continue-reading">&lt;/span>
&lt;p>&lt;em>For the technically curious.&lt;/em>&lt;/p>
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/bBC-nXj3Ng4"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;h2 id="the-blockchain">The Blockchain
&lt;a class="heading-anchor" href="#the-blockchain" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="the-double-spend-problem">The Double-Spend Problem
&lt;a class="heading-anchor" href="#the-double-spend-problem" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Digital money has a fundamental problem: how do you prevent someone from copying their coins and spending them twice? Traditional systems solve this with a central authority (banks, PayPal) that tracks who owns what. Bitcoin’s breakthrough was solving this without any central party.&lt;/p>
&lt;p>The solution: a shared ledger that everyone can verify but no one controls.&lt;/p>
&lt;h3 id="how-it-works">How It Works
&lt;a class="heading-anchor" href="#how-it-works" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Bitcoin uses a blockchain: a chain of blocks where each block contains transactions and links to the previous block through cryptographic hashes.&lt;/p>
&lt;p>A &lt;strong>hash function&lt;/strong> takes any input and produces a fixed-size fingerprint. Change one bit of input, and the output changes completely. This makes tampering obvious. Bitcoin uses SHA-256, which produces a 256-bit output.&lt;/p>
&lt;p>Each block contains:&lt;/p>
&lt;ul>
&lt;li>A list of transactions&lt;/li>
&lt;li>A hash of the previous block header&lt;/li>
&lt;li>A proof-of-work solution (more below)&lt;/li>
&lt;/ul>
&lt;p>Before transactions get into a block, they wait in the mempool. Miners pick transactions from this pool, prioritizing those with higher fees. Watch this in real-time at &lt;a rel="external" href="https://mempool.space/">mempool.space&lt;/a>.&lt;/p>
&lt;p>Every node keeps a complete copy of the blockchain. No single server to hack, no central database to corrupt. To change history, you’d need to rewrite blocks on the majority of nodes worldwide.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Block Structure&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>A block has two parts: the &lt;strong>header&lt;/strong> (80 bytes) and the &lt;strong>body&lt;/strong> (transactions).&lt;/p>
&lt;p>The header contains:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Version&lt;/strong>: Protocol version&lt;/li>
&lt;li>&lt;strong>Previous block hash&lt;/strong>: Links to the chain&lt;/li>
&lt;li>&lt;strong>Merkle root&lt;/strong>: Hash of all transactions in the block&lt;/li>
&lt;li>&lt;strong>Timestamp&lt;/strong>: When the block was created&lt;/li>
&lt;li>&lt;strong>Difficulty target&lt;/strong>: How hard the puzzle was&lt;/li>
&lt;li>&lt;strong>Nonce&lt;/strong>: The solution miners found&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Merkle trees&lt;/strong> organize transactions efficiently. Each transaction is hashed, then pairs of hashes are combined and hashed again, building up to a single root hash. This allows proving a transaction exists in a block without downloading all transactions. Useful for lightweight wallets.&lt;/p>
&lt;p>Block weight is measured in virtual bytes (vB). The limit is 4 million weight units, roughly 1-1.5 MB of data per block.&lt;/p>
&lt;/div>
&lt;/details>
&lt;h2 id="transactions-cryptography">Transactions &amp;amp; Cryptography
&lt;a class="heading-anchor" href="#transactions-cryptography" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="the-utxo-model">The UTXO Model
&lt;a class="heading-anchor" href="#the-utxo-model" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Bitcoin doesn’t use accounts with balances. Instead, it tracks &lt;strong>Unspent Transaction Outputs (UTXOs)&lt;/strong>. Think of them as digital coins of varying sizes.&lt;/p>
&lt;p>When you receive bitcoin, you get a UTXO. When you spend, you consume entire UTXOs as inputs and create new ones as outputs. If you have a 1 BTC UTXO and want to send 0.3 BTC, you spend the whole UTXO and create two outputs: 0.3 BTC to the recipient and ~0.7 BTC back to yourself (minus fees).&lt;/p>
&lt;p>Your “balance” is the sum of all UTXOs you can spend.&lt;/p>
&lt;h3 id="public-key-cryptography">Public-Key Cryptography
&lt;a class="heading-anchor" href="#public-key-cryptography" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Bitcoin transactions use public-key cryptography:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Private key&lt;/strong>: A secret 256-bit number. This proves ownership.&lt;/li>
&lt;li>&lt;strong>Public key&lt;/strong>: Derived mathematically from the private key. Shared publicly.&lt;/li>
&lt;/ul>
&lt;p>When you send bitcoin, you sign the transaction with your private key. This signature proves you own the UTXOs being spent without revealing the private key. Anyone can verify the signature using your public key.&lt;/p>
&lt;h3 id="programmable-money">Programmable Money
&lt;a class="heading-anchor" href="#programmable-money" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Bitcoin isn’t just digital cash. It has its own programming language called &lt;strong>Script&lt;/strong>. Every transaction includes a small program that defines the conditions for spending.&lt;/p>
&lt;p>Most transactions use simple scripts: “whoever can prove they own this public key can spend these coins.” But Script enables much more: multi-signature wallets requiring multiple keys, time-locked transactions that can’t be spent until a certain date, and complex conditions combining multiple requirements.&lt;/p>
&lt;p>This makes Bitcoin programmable money. For a deeper dive into Script and address types, see &lt;a href="/blog/programmable-money/">Programmable Money&lt;/a>.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Elliptic Curve Cryptography&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>Bitcoin uses &lt;strong>ECDSA&lt;/strong> (Elliptic Curve Digital Signature Algorithm) with the &lt;strong>secp256k1&lt;/strong> curve. This curve was chosen for efficiency and because it wasn’t designed by any government agency (unlike NIST curves), reducing backdoor concerns.&lt;/p>
&lt;p>A private key is a random 256-bit integer. The public key is derived by multiplying this number by a generator point on the curve. Easy to compute forward, practically impossible to reverse.&lt;/p>
&lt;p>&lt;strong>Transaction signing&lt;/strong> involves:&lt;/p>
&lt;ol>
&lt;li>Hashing the transaction data&lt;/li>
&lt;li>Creating a signature using the private key&lt;/li>
&lt;li>Including the signature and public key in the transaction&lt;/li>
&lt;/ol>
&lt;p>&lt;strong>SIGHASH flags&lt;/strong> control what parts of a transaction the signature covers:&lt;/p>
&lt;ul>
&lt;li>&lt;code>SIGHASH_ALL&lt;/code>: Signs all inputs and outputs (most common)&lt;/li>
&lt;li>&lt;code>SIGHASH_NONE&lt;/code>: Signs inputs only&lt;/li>
&lt;li>&lt;code>SIGHASH_SINGLE&lt;/code>: Signs one specific output&lt;/li>
&lt;li>These can be combined with &lt;code>ANYONECANPAY&lt;/code> for advanced use cases&lt;/li>
&lt;/ul>
&lt;/div>
&lt;/details>
&lt;h2 id="mining-consensus">Mining &amp;amp; Consensus
&lt;a class="heading-anchor" href="#mining-consensus" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>How does a decentralized network agree on which transactions are valid? Through proof-of-work mining.&lt;/p>
&lt;h3 id="the-puzzle">The Puzzle
&lt;a class="heading-anchor" href="#the-puzzle" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Miners race to find a number (the &lt;strong>nonce&lt;/strong>) that, when combined with the block header and hashed, produces a result below a target value. It’s like rolling dice until you get a number under 100, except with 2^256 possible outcomes.&lt;/p>
&lt;p>The work is:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Hard to find&lt;/strong>: Requires trillions of guesses&lt;/li>
&lt;li>&lt;strong>Easy to verify&lt;/strong>: One hash check proves the solution&lt;/li>
&lt;/ul>
&lt;p>This asymmetry is key. Anyone can verify a block instantly, but creating one requires real computational work.&lt;/p>
&lt;h3 id="why-it-matters">Why It Matters
&lt;a class="heading-anchor" href="#why-it-matters" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Mining serves three purposes:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Secures the network&lt;/strong>: Rewriting history means redoing all hash work&lt;/li>
&lt;li>&lt;strong>Issues new coins&lt;/strong>: Following a predictable schedule (halving every 210,000 blocks)&lt;/li>
&lt;li>&lt;strong>Processes transactions&lt;/strong>: Including them in the permanent record&lt;/li>
&lt;/ol>
&lt;p>Every 2016 blocks (~2 weeks), the network adjusts difficulty to maintain ~10 minute block times. More hashpower joins? Puzzles get harder. Hashpower leaves? Puzzles get easier.&lt;/p>
&lt;p>Explore mining pools and hashrate at &lt;a rel="external" href="https://mempool.space/mining">mempool.space/mining&lt;/a>.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Difficulty and Game Theory&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>&lt;strong>Difficulty calculation&lt;/strong>: The target is a 256-bit number. A valid block hash must be below this target. Lower target = harder puzzle. The network adjusts every 2016 blocks based on how long those blocks actually took vs. the expected 20,160 minutes.&lt;/p>
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/S9JGmA5_unY"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;p>&lt;strong>Hashrate and security&lt;/strong>: Bitcoin’s security comes from the cost to rewrite history. With ~500 EH/s (exahashes per second) of hashrate, attacking the network would require controlling majority hashpower. That means billions in hardware and electricity, plus the attack would crash the asset’s value.&lt;/p>
&lt;p>&lt;strong>Economic incentives&lt;/strong>: Miners spend real resources (electricity, hardware). They only profit if they play by the rules. A miner who creates invalid blocks wastes their work because nodes reject invalid blocks. This aligns individual profit motive with network security.&lt;/p>
&lt;p>&lt;strong>51% attacks&lt;/strong>: If an attacker controlled majority hashrate, they could theoretically double-spend by mining an alternative chain. But the economics make this irrational for large values: the attack destroys the value of what you’re stealing.&lt;/p>
&lt;/div>
&lt;/details>
&lt;h2 id="addresses-wallets">Addresses &amp;amp; Wallets
&lt;a class="heading-anchor" href="#addresses-wallets" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Bitcoin addresses are derived from public keys. Different formats have evolved:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>P2PKH&lt;/strong>: Legacy addresses starting with “1”&lt;/li>
&lt;li>&lt;strong>P2SH&lt;/strong>: Script addresses starting with “3”&lt;/li>
&lt;li>&lt;strong>P2WPKH&lt;/strong>: Native SegWit addresses starting with “bc1q”&lt;/li>
&lt;li>&lt;strong>P2TR&lt;/strong>: Taproot addresses starting with “bc1p”&lt;/li>
&lt;/ul>
&lt;p>For technical details on each type, see &lt;a href="/blog/programmable-money/#common-bitcoin-address-types">Programmable Money&lt;/a>.&lt;/p>
&lt;h3 id="wallets">Wallets
&lt;a class="heading-anchor" href="#wallets" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>A wallet manages your keys and constructs transactions. It doesn’t hold your coins. Coins exist on the blockchain. The wallet holds keys that prove you can spend them.&lt;/p>
&lt;p>&lt;strong>Hot wallets&lt;/strong> connect to the internet. Convenient for daily use, more vulnerable. Examples: phone apps, browser extensions.&lt;/p>
&lt;p>&lt;strong>Cold wallets&lt;/strong> stay offline. More secure for savings. Examples: hardware wallets (Ledger, Trezor), paper wallets.&lt;/p>
&lt;h3 id="hd-wallets-and-seed-phrases">HD Wallets and Seed Phrases
&lt;a class="heading-anchor" href="#hd-wallets-and-seed-phrases" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Modern wallets are &lt;strong>Hierarchical Deterministic (HD)&lt;/strong>. One master seed generates unlimited keys in a tree structure. Back up the seed once, recover everything.&lt;/p>
&lt;p>&lt;strong>BIP-39&lt;/strong> defines the 12 or 24-word seed phrase most wallets use. These words encode entropy that derives all your keys. Lose the phrase, lose access. Anyone with the phrase controls the funds.&lt;/p>
&lt;blockquote>
&lt;p>Never store seed phrases digitally. Write them down. Store securely offline.&lt;/p>
&lt;/blockquote>
&lt;p>How big is the BIP-39 keyspace, really? I built &lt;a rel="external" href="https://github.com/Chemaclass/seed-hunter">seed-hunter&lt;/a>, an open-source educational Go CLI that tries to brute-force a 12-word seed against the real Bitcoin network. It logs every attempt and shows live progress with ETAs spanning 10²⁹ to 10³⁹ years. A burglar checking one trillion seed phrases per second since the Big Bang would have completed 0.000_000_008% of the search by now. The point isn’t to break Bitcoin, it’s to make the math viscerally obvious: thermodynamics, not just computation, forbids the attack.&lt;/p>
&lt;h2 id="the-network">The Network
&lt;a class="heading-anchor" href="#the-network" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Bitcoin is a peer-to-peer network. No central servers. Nodes connect to each other, share transactions and blocks, and enforce rules independently.&lt;/p>
&lt;h3 id="node-types">Node Types
&lt;a class="heading-anchor" href="#node-types" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>&lt;strong>Full nodes&lt;/strong> download and validate every block and transaction. They enforce all consensus rules and don’t trust anyone. Running a full node means you verify everything yourself.&lt;/p>
&lt;p>&lt;strong>SPV (light) clients&lt;/strong> only download block headers. They trust that miners validated the transactions. Less security, but works on phones and low-power devices.&lt;/p>
&lt;p>&lt;strong>Mining nodes&lt;/strong> are full nodes that also compete to create new blocks.&lt;/p>
&lt;h3 id="how-transactions-propagate">How Transactions Propagate
&lt;a class="heading-anchor" href="#how-transactions-propagate" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>When you broadcast a transaction:&lt;/p>
&lt;ol>
&lt;li>Your wallet sends it to connected nodes&lt;/li>
&lt;li>Each node validates and forwards to its peers&lt;/li>
&lt;li>Within seconds, the transaction reaches most of the network&lt;/li>
&lt;li>Miners include it in their candidate blocks&lt;/li>
&lt;/ol>
&lt;p>Blocks propagate similarly. When a miner finds a valid block, it spreads across the network in seconds.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Network Architecture&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>&lt;strong>Peer discovery&lt;/strong>: Nodes find each other through DNS seeds (hardcoded addresses that return active node IPs) and by sharing peer addresses with connected nodes.&lt;/p>
&lt;p>&lt;strong>Gossip protocol&lt;/strong>: Information spreads through “inv” (inventory) messages. A node announces it has something new, peers request it if interested. This prevents bandwidth waste from duplicate data.&lt;/p>
&lt;p>&lt;strong>Compact blocks&lt;/strong> (BIP-152) speed up block propagation. Since nodes already have most transactions in their mempool, blocks can be transmitted as just the header plus short transaction IDs.&lt;/p>
&lt;/div>
&lt;/details>
&lt;h2 id="security-confirmations">Security &amp;amp; Confirmations
&lt;a class="heading-anchor" href="#security-confirmations" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="why-confirmations-matter">Why Confirmations Matter
&lt;a class="heading-anchor" href="#why-confirmations-matter" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>When a transaction is included in a block, it has 1 confirmation. Each subsequent block adds another confirmation.&lt;/p>
&lt;p>More confirmations = harder to reverse. To undo a confirmed transaction, an attacker would need to mine an alternative chain faster than the honest network. Each block makes this exponentially harder.&lt;/p>
&lt;p>&lt;strong>General guidelines:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>0 confirmations: Transaction broadcast but not yet in a block. Can be double-spent.&lt;/li>
&lt;li>1 confirmation: In a block. Reversal requires significant hashpower.&lt;/li>
&lt;li>6 confirmations: Standard for large amounts. Reversal practically impossible.&lt;/li>
&lt;/ul>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Confirmation Security&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>Satoshi’s whitepaper includes the probability calculation. With an attacker controlling fraction &lt;code>q&lt;/code> of hashpower:&lt;/p>
&lt;ul>
&lt;li>If &lt;code>q &amp;lt; 0.5&lt;/code>: Probability of catching up decreases exponentially with each confirmation&lt;/li>
&lt;li>At 6 confirmations with &lt;code>q = 0.1&lt;/code> (10% hashpower): Success probability &amp;lt; 0.1%&lt;/li>
&lt;/ul>
&lt;p>The “6 confirmations” rule assumes a well-funded attacker with substantial but minority hashpower. For smaller transactions, fewer confirmations are often acceptable.&lt;/p>
&lt;p>&lt;strong>Finality in Bitcoin&lt;/strong> is probabilistic, not absolute. But after enough confirmations, the probability of reversal approaches zero for any realistic attacker.&lt;/p>
&lt;/div>
&lt;/details>
&lt;h2 id="incentive-alignment">Incentive Alignment
&lt;a class="heading-anchor" href="#incentive-alignment" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Bitcoin isn’t just a clever technology. It’s a system where every participant’s self-interest reinforces the network.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Miners&lt;/strong> invest in hardware and electricity. They only profit by producing valid blocks. Cheating wastes their investment because nodes reject invalid blocks instantly.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Nodes&lt;/strong> enforce the rules to protect their own holdings. A node operator who accepts invalid transactions devalues their own bitcoin. Self-interest makes them honest validators.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Users&lt;/strong> pay fees to get transactions processed. Higher fees mean faster confirmation. This creates demand for block space and funds network security.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Developers&lt;/strong> contribute to software they themselves use. Bugs hurt their own holdings. Improvements benefit everyone, including them.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Holders&lt;/strong> benefit from network security and adoption. The more secure and useful Bitcoin becomes, the more valuable their holdings. They’re incentivized to support the ecosystem.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>No central coordinator. No trust required. Everyone acts in their own interest, and the system benefits everyone.&lt;/p>
&lt;blockquote>
&lt;p>“Don’t trust, verify.” Anyone can run a node and verify every transaction, every block, every rule. You don’t need to trust banks, governments, or even other Bitcoin users. The math proves itself.&lt;/p>
&lt;/blockquote>
&lt;h2 id="scaling-the-lightning-network">Scaling: The Lightning Network
&lt;a class="heading-anchor" href="#scaling-the-lightning-network" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Bitcoin’s base layer processes about 7 transactions per second. That’s by design: keeping things decentralized requires blocks small enough for anyone to verify. But this limits how many transactions it can handle.&lt;/p>
&lt;p>The Lightning Network solves this with a second layer built on top of Bitcoin. It enables:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Instant payments&lt;/strong>: No waiting for block confirmations&lt;/li>
&lt;li>&lt;strong>Near-zero fees&lt;/strong>: Fractions of a cent&lt;/li>
&lt;li>&lt;strong>High capacity&lt;/strong>: Millions of transactions per second&lt;/li>
&lt;/ul>
&lt;p>Lightning works by opening “payment channels” between parties. Transactions within a channel happen off-chain, instantly. Only the opening and closing of channels require on-chain transactions. You can visualize the network topology and statistics at &lt;a rel="external" href="https://mempool.space/lightning">mempool.space/lightning&lt;/a>.&lt;/p>
&lt;blockquote>
&lt;p>Bitcoin’s base layer provides security and final settlement. Lightning provides speed and scale. Different tools for different jobs.&lt;/p>
&lt;/blockquote>
&lt;p>If you want to run your own Lightning node and take full control of your payments, I wrote a guide on how to &lt;a href="/blog/run-your-ln-node/">Run your LN node on a Raspberry Pi&lt;/a>.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: How Lightning Works&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>Payment channels use &lt;strong>2-of-2 multisig&lt;/strong> addresses. Both parties must sign to move funds. This creates a shared account that neither can steal from.&lt;/p>
&lt;p>&lt;strong>HTLCs (Hash Time-Locked Contracts)&lt;/strong> enable multi-hop payments. The mechanism:&lt;/p>
&lt;ol>
&lt;li>Alice wants to pay Carol through Bob&lt;/li>
&lt;li>Carol generates a secret and gives Alice the hash&lt;/li>
&lt;li>Alice creates an HTLC: “Bob gets paid if he reveals the secret within 24 hours”&lt;/li>
&lt;li>Bob creates a similar HTLC with Carol&lt;/li>
&lt;li>Carol reveals the secret to Bob, claiming payment&lt;/li>
&lt;li>Bob uses the same secret to claim from Alice&lt;/li>
&lt;/ol>
&lt;p>If anyone fails to cooperate, the timelock expires and funds return. The secret travels backward, payments travel forward.&lt;/p>
&lt;p>&lt;strong>Watchtowers&lt;/strong> monitor the blockchain for cheating attempts. If your counterparty tries to broadcast an old channel state, the watchtower can penalize them, even while you’re offline.&lt;/p>
&lt;/div>
&lt;/details>
&lt;h2 id="the-bigger-picture">The Bigger Picture
&lt;a class="heading-anchor" href="#the-bigger-picture" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>What makes Bitcoin remarkable isn’t any single component. It’s how they fit together into a self-reinforcing system.&lt;/p>
&lt;p>Cryptography proves ownership without trusted authorities. Proof-of-work makes history expensive to rewrite. Economic incentives turn individual greed into collective security. Decentralization removes single points of failure. And the fixed supply creates digital scarcity for the first time in history.&lt;/p>
&lt;p>Every piece supports every other piece. Remove one, and the system weakens. Together, they create something that has never existed before: money that can’t be inflated, transactions that can’t be censored, and property that can’t be confiscated.&lt;/p>
&lt;blockquote>
&lt;p>No banks. No governments. No trusted third parties. Just math, code, and a global network of nodes all enforcing the same rules.&lt;/p>
&lt;/blockquote>
&lt;p>Whether that matters to you depends on where you live and how much you trust your institutions. But the option exists now. And no one can take it away.&lt;/p>
&lt;details class="deep-dive">
&lt;summary class="deep-dive__header">
&lt;span class="deep-dive__icon">&lt;/span>
&lt;span class="deep-dive__title">Deep Dive: Rabbit Holes&lt;/span>
&lt;/summary>
&lt;div class="deep-dive__content">
&lt;p>Bitcoin’s technical depth goes far beyond what fits in one post. Here are topics worth exploring if you want to go deeper:&lt;/p>
&lt;p>&lt;strong>&lt;a rel="external" href="https://bitcoinops.org/en/topics/segregated-witness/">SegWit&lt;/a>&lt;/strong> (Segregated Witness) was Bitcoin’s 2017 upgrade that moved signature data outside the main transaction structure. This fixed transaction malleability (a bug that prevented Lightning), introduced block weight for more efficient space usage, and did it all while staying backwards-compatible with old nodes.&lt;/p>
&lt;p>&lt;strong>&lt;a rel="external" href="https://bitcoinops.org/en/topics/taproot/">Taproot &amp;amp; Schnorr&lt;/a>&lt;/strong> landed in 2021, upgrading Bitcoin’s cryptography. Schnorr signatures are smaller and enable aggregation (multiple signatures become one). Taproot makes complex spending conditions look identical to simple payments on-chain, improving both privacy and efficiency.&lt;/p>
&lt;p>&lt;strong>&lt;a rel="external" href="https://bitcoin.stackexchange.com/questions/30817/what-is-a-soft-fork">Soft forks vs hard forks&lt;/a>&lt;/strong>: How does Bitcoin upgrade without a central authority? Soft forks add new rules that old nodes still accept. Hard forks change rules in ways old nodes reject. Understanding this distinction explains why Bitcoin evolves slowly and why contentious changes are rare.&lt;/p>
&lt;p>&lt;strong>&lt;a rel="external" href="https://mempool.space/docs/faq#what-is-rbf">Fee mechanics&lt;/a>&lt;/strong>: The fee market is more nuanced than “pay more, confirm faster.” Replace-By-Fee (RBF) lets you bump a stuck transaction’s fee. Child-Pays-For-Parent (CPFP) lets recipients accelerate incoming payments by spending them with high fees.&lt;/p>
&lt;p>&lt;strong>&lt;a rel="external" href="https://bitcoinops.org/en/topics/timelocks/">Timelocks&lt;/a>&lt;/strong>: Bitcoin can lock funds until conditions are met. &lt;code>CLTV&lt;/code> (CheckLockTimeVerify) locks until a specific block height or timestamp. &lt;code>CSV&lt;/code> (CheckSequenceVerify) locks for a relative time after confirmation. These primitives enable Lightning channels, inheritance schemes, and atomic swaps.&lt;/p>
&lt;p>&lt;strong>&lt;a rel="external" href="https://learnmeabitcoin.com/technical/mining/coinbase-transaction/">Coinbase transactions&lt;/a>&lt;/strong>: The only way new bitcoin enters circulation. Every block begins with a special transaction that pays the miner the block reward plus all fees. These newly minted coins can’t be spent for 100 blocks, a rule that protects against chain reorganizations.&lt;/p>
&lt;p>The deeper you go, the more you find.&lt;/p>
&lt;/div>
&lt;/details></content></entry><entry xml:lang="en"><title>Run Your LN Node on a Raspberry Pi</title><subtitle>Take full control of your Lightning payments with Alby Hub</subtitle><category term="bitcoin" scheme="https://chemaclass.com/tags/bitcoin/" label="Bitcoin"/><category term="open-source" scheme="https://chemaclass.com/tags/open-source/" label="Open Source"/><category term="privacy" scheme="https://chemaclass.com/tags/privacy/" label="Privacy"/><category term="tutorial" scheme="https://chemaclass.com/tags/tutorial/" label="Tutorial"/><published>2025-02-17T00:00:00+00:00</published><updated>2025-02-17T00:00:00+00:00</updated><author><name>
Chemaclass</name></author><link rel="alternate" type="text/html" href="https://chemaclass.com/blog/run-your-ln-node/"/><id>https://chemaclass.com/blog/run-your-ln-node/</id><summary type="html">In this guide, I'll show you how to set up a fully custodial Lightning Network (LN) node using Alby Hub on a Raspberry Pi, giving you complete control over your node. Alby Hub offers a DIY free version for a self-custodial Lightning wallet, ensuring full ownership of your funds while being 100% open-source.</summary><content type="html">&lt;p>In this guide, I’ll show you how to set up a fully custodial Lightning Network (LN) node using Alby Hub on a Raspberry Pi, giving you complete control over your node. Alby Hub offers a DIY free version for a self-custodial Lightning wallet, ensuring full ownership of your funds while being 100% open-source.&lt;/p>
&lt;span id="continue-reading">&lt;/span>
&lt;p>It supports both Lightning and Nostr addresses, enabling seamless connectivity across ecosystems, and integrates effortlessly with dozens of Bitcoin applications. With built-in Lightning Service Provider (LSP) services and the Alby Go mobile app, managing your node on the go has never been easier.&lt;/p>
&lt;hr />
&lt;blockquote>
&lt;p>Important: This is NOT a Bitcoin miner or a full node. It’s simply a Raspberry Pi running on an SD card power-efficient and low-cost.&lt;/p>
&lt;/blockquote>
&lt;p>⚠️ &lt;strong>Disclaimer&lt;/strong> ⚠️&lt;/p>
&lt;ul>
&lt;li>I assume you &lt;strong>understand &lt;a rel="external" href="https://bitcoin.org/">Bitcoin&lt;/a>&lt;/strong>’s fundamental concepts.&lt;/li>
&lt;li>I assume you know &lt;strong>how the &lt;a rel="external" href="https://lightning.network/">Lightning Network&lt;/a> (LN) works&lt;/strong>.&lt;/li>
&lt;/ul>
&lt;p>Anyway, I’ve included a brief recap of the Lightning Network basics below.&lt;/p>
&lt;h2 id="what-is-the-lightning-network">What is the Lightning Network?
&lt;a class="heading-anchor" href="#what-is-the-lightning-network" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>The LN is a second-layer solution built on top of Bitcoin to enable fast, cheap, and scalable transactions.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Why?&lt;/strong> Bitcoin’s base layer is secure but slow and expensive for small payments due to block size limits and fees.&lt;/li>
&lt;li>&lt;strong>How?&lt;/strong> LN uses off-chain payment channels that allow users to transact instantly without waiting for blockchain confirmations.&lt;/li>
&lt;/ul>
&lt;h3 id="key-concepts">Key Concepts
&lt;a class="heading-anchor" href="#key-concepts" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Payment Channels&lt;/strong>: Users open a channel by making an on-chain transaction, then send unlimited instant payments within that channel.&lt;/li>
&lt;li>&lt;strong>Routing&lt;/strong>: You don’t need a direct channel with everyone, payments can be routed through multiple connected nodes.&lt;/li>
&lt;li>&lt;strong>Low Fees&lt;/strong>: Only opening/closing channels require on-chain fees; most transactions cost fractions of a cent.&lt;/li>
&lt;/ul>
&lt;h3 id="goal">Goal
&lt;a class="heading-anchor" href="#goal" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>LN makes Bitcoin usable for everyday transactions, like buying coffee, without waiting 10+ minutes for confirmations.&lt;/p>
&lt;blockquote>
&lt;p>In short: Lightning Network = Instant + Cheap Bitcoin payments, secured by Bitcoin’s blockchain.&lt;/p>
&lt;/blockquote>
&lt;hr />
&lt;h2 id="setting-up-alby-hub">Setting up Alby Hub
&lt;a class="heading-anchor" href="#setting-up-alby-hub" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>&lt;a rel="external" href="https://albyhub.com/">Alby Hub&lt;/a> is a free, open-source (&lt;a rel="external" href="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/alby-hub/faq-alby-hub/should-i-open-a-private-or-public-channel">ideally private&lt;/a>) Lightning Network node.&lt;/p>
&lt;h3 id="requirements">Requirements
&lt;a class="heading-anchor" href="#requirements" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Before we begin, you are going to need the following things:&lt;/p>
&lt;ul>
&lt;li>A windows or mac or linux computer&lt;/li>
&lt;li>&lt;strong>Raspberry Pi 4&lt;/strong> or &lt;strong>5&lt;/strong> (For &lt;a rel="external" href="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/hidden-archives/raspberry-pi-zero">&lt;strong>Zero 2W&lt;/strong> see this tutorial!&lt;/a>)
&lt;ul>
&lt;li>&lt;em>In this tutorial, I am using a raspi-4b (~60€)&lt;/em>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>The charger for your raspi &lt;em>(~10€)&lt;/em>&lt;/li>
&lt;li>SD memory card (32/64gb) &lt;em>(~10€)&lt;/em>&lt;/li>
&lt;li>Adapter SD card to USB (to flash the OS into the raspi) &lt;em>(~10€)&lt;/em>&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="/images/blog/2025-02-17/requirements.webp" alt="tutorial" />&lt;/p>
&lt;h3 id="installation-steps">Installation Steps
&lt;a class="heading-anchor" href="#installation-steps" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;h4 id="1-flash-a-linux-kernel-into-the-sd-card">1. Flash a Linux kernel into the SD card
&lt;a class="heading-anchor" href="#1-flash-a-linux-kernel-into-the-sd-card" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h4>
&lt;blockquote>
&lt;p>Suggestion: You can use &lt;a rel="external" href="https://www.raspberrypi.com/software/">RPI imager&lt;/a> on your computer.
Use it to flash the recommended raspi OS for you&lt;/p>
&lt;/blockquote>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-1.jpg" alt="tutorial" />&lt;/p>
&lt;p>On the Storage you will see your SD card after inserting it into your laptop.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-2.jpg" alt="tutorial" />&lt;/p>
&lt;p>Once you click “Next”, you will see different settings. Click to &lt;strong>Edit Settings&lt;/strong>&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-3.jpg" alt="tutorial" />&lt;/p>
&lt;p>On &lt;code>Settings &amp;gt; General&lt;/code>: set your hostname, the username and password for your admin user.
Make sure you enable your WIFI, otherwise you will have to plug it to the router with an RJ-45.
&lt;span id="hostname-setup">&lt;/span>&lt;/p>
&lt;blockquote>
&lt;p>For this tutorial, I am using &lt;code>testhub&lt;/code> as hostname, you can use &lt;code>albyhub&lt;/code> or whatever you prefer.&lt;/p>
&lt;/blockquote>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-4.jpg" alt="tutorial" />&lt;/p>
&lt;p>&lt;span id="pi-enable-ssh">&lt;/span>
On &lt;code>Settings &amp;gt; Services&lt;/code>: make sure the access via SSH is enabled. We are going to need it to install Alby Hub.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-5.jpg" alt="tutorial" />&lt;/p>
&lt;p>Click “Save” and click “Yes” to start the installation.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-6.jpg" alt="tutorial" />&lt;/p>
&lt;p>You will see a confirmation. Click “Yes”. It will take ~10 mins…&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-7.jpg" alt="tutorial" />&lt;/p>
&lt;p>Now we got the SD with a fresh linux kernel ready to use!&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-8.jpg" alt="tutorial" />&lt;/p>
&lt;h4 id="2-insert-the-sd-into-the-raspi">2. Insert the SD into the raspi
&lt;a class="heading-anchor" href="#2-insert-the-sd-into-the-raspi" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h4>
&lt;p>Extract the SD from the laptop and insert it in the raspi first.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-9.jpg" alt="tutorial" />&lt;/p>
&lt;p>Once the SD is inserted, then plug in the power cable. It will turn on automatically as soon as you plug it in.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-10.jpg" alt="tutorial" />&lt;/p>
&lt;h4 id="3-alby-hub-installation">3. Alby Hub installation
&lt;a class="heading-anchor" href="#3-alby-hub-installation" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h4>
&lt;p>It will take ~5mins since you turned it on to be able to access to it. How can you make sure it’s alive? Open the terminal and ping the hostname you defined while flashing the SD on &lt;a href="/blog/run-your-ln-node/#hostname-setup">Settings &amp;gt; General&lt;/a>, remember it ended up with &lt;code>.local&lt;/code>:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">ping&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> testhub.local&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>It’s normal if you don’t get any answer at the beginning… until you do get this.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-11.jpg" alt="tutorial" />&lt;/p>
&lt;p>&lt;span id="pi-install-alby-hub">&lt;/span>
Now you can &lt;strong>install Alby Hub&lt;/strong> in your raspi &lt;strong>using the SSH connection&lt;/strong> that you &lt;a href="/blog/run-your-ln-node/#pi-enable-ssh">enabled earlier&lt;/a>:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6A737D, #6A737D);">#&lt;/span>&lt;span style="color: light-dark(#6A737D, #6A737D);"> Source code: https://github.com/getAlby/hub/tree/master/scripts/pi-aarch64&lt;/span>&lt;/span>
&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">ssh&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> testhub@testhub.local&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;#39;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">/bin/bash -c &amp;quot;$(curl -fsSL https://getalby.com/install/hub/pi-aarch64-install.sh)&amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;#39;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>You will be asked to type the word “yes”; type it.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-12.jpg" alt="tutorial" />&lt;/p>
&lt;p>Then, you will be asked to enter your password. Enter the password you chose in &lt;a href="/blog/run-your-ln-node/#hostname-setup">Settings &amp;gt; General&lt;/a> for the username.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-13.jpg" alt="tutorial" />&lt;/p>
&lt;h4 id="4-alby-hub-setup">4. Alby Hub Setup
&lt;a class="heading-anchor" href="#4-alby-hub-setup" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h4>
&lt;p>Wait another 2-3 mins and visit your host: &lt;a rel="external" href="http://testhub.local/">http://testhub.local/&lt;/a>&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-14.jpg" alt="tutorial" />&lt;/p>
&lt;p>Your Alby hub is now running. Let’s connect it to your GetAlby account!&lt;/p>
&lt;hr />
&lt;h2 id="creating-a-getalby-account">Creating a GetAlby Account
&lt;a class="heading-anchor" href="#creating-a-getalby-account" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>🔗 &lt;a rel="external" href="https://getalby.com/">getalby.com&lt;/a>&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-15.jpg" alt="tutorial" />&lt;/p>
&lt;hr />
&lt;h2 id="connecting-getalby-with-alby-hub">Connecting GetAlby with Alby Hub
&lt;a class="heading-anchor" href="#connecting-getalby-with-alby-hub" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>I created an account named testhub.&lt;/p>
&lt;p>&lt;strong>Left&lt;/strong>: the GetAlby account. &lt;strong>Right&lt;/strong>: the node in the raspi.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-16.jpg" alt="tutorial" />&lt;/p>
&lt;p>Click “&lt;strong>Connect Now&lt;/strong>”.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-17.jpg" alt="tutorial" />&lt;/p>
&lt;p>Click “&lt;strong>Request Authorization Code&lt;/strong>”.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-18.jpg" alt="tutorial" />&lt;/p>
&lt;p>You get the auth code (&lt;strong>left&lt;/strong>) that you need to insert it into your setup (&lt;strong>right&lt;/strong>).&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-19.jpg" alt="tutorial" />&lt;/p>
&lt;p>&lt;span id="alby-hub-password">&lt;/span>
Create a &lt;strong>Password&lt;/strong> for your Alby Hub installed in your raspi. It can be different from the password that you set up for your root user in the rapi itself.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-20.jpg" alt="tutorial" />&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-21.jpg" alt="tutorial" />&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-22.jpg" alt="tutorial" />&lt;/p>
&lt;p>Now it’s time to &lt;strong>Link your Alby Account&lt;/strong>&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-23.jpg" alt="tutorial" />&lt;/p>
&lt;p>Unless you specify otherwise, set the default “Budget renewal: &lt;em>Monthly 1M sats&lt;/em>”.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-24.jpg" alt="tutorial" />
&lt;img src="/images/blog/2025-02-17/tuto-25.jpg" alt="tutorial" />&lt;/p>
&lt;hr />
&lt;h2 id="opening-lightning-channels">Opening Lightning Channels
&lt;a class="heading-anchor" href="#opening-lightning-channels" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>I recommend following the &lt;strong>Initial Steps&lt;/strong> to set up your Alby Hub.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-27.jpg" alt="tutorial" />&lt;/p>
&lt;p>Let’s open the first channel.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-28.jpg" alt="tutorial" />&lt;/p>
&lt;p>You need to pay ~$20 in sats to open a 1M sats &lt;em>&lt;strong>incoming liquidity channel&lt;/strong>&lt;/em>.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-29.jpg" alt="tutorial" />&lt;/p>
&lt;p>After the payment, then you will see the channel open. It might take a couple of mins until the &lt;strong>&lt;em>funding transaction&lt;/em>&lt;/strong> is mined in the next block.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-30.jpg" alt="tutorial" />&lt;/p>
&lt;hr />
&lt;h2 id="receiving-sats">Receiving Sats
&lt;a class="heading-anchor" href="#receiving-sats" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>You can receive sats using your LN Address.&lt;/p>
&lt;p>&lt;strong>Left&lt;/strong>: Public page linked to your &lt;a rel="external" href="https://getalby.com/p/chemaclass">node&lt;/a>.
&lt;strong>Right&lt;/strong>: Private page from your Alby Hub.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-33.jpg" alt="tutorial" />&lt;/p>
&lt;blockquote>
&lt;p>Optional: You can add ln funds to your wallet using GetAlby’s third-party services: &lt;a rel="external" href="https://getalby.com/topup">getalby.com/topup&lt;/a> - mind the KYC…&lt;/p>
&lt;/blockquote>
&lt;hr />
&lt;h2 id="using-your-sats">Using Your Sats
&lt;a class="heading-anchor" href="#using-your-sats" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>After that, you will be able to use it via the &lt;a rel="external" href="https://getalby.com/">Alby Extension&lt;/a> or the &lt;a rel="external" href="https://albygo.com/">AlbyGo&lt;/a>.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-31.jpg" alt="tutorial" />&lt;/p>
&lt;p>Your node is the ultimate source of truth. Connecting these apps to it will allow you to use your sats seamlessly across different platforms.&lt;/p>
&lt;p>&lt;img src="/images/blog/2025-02-17/tuto-32.jpg" alt="tutorial" />&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Disclaimer&lt;/strong>: the testhub LN address was created only for testing and tutorial purposes. My real address is &lt;a rel="external" href="https://getalby.com/p/chemaclass">chemaclass&lt;/a> ;)&lt;/p>
&lt;/blockquote>
&lt;h2 id="maintenance-and-troubleshooting">Maintenance and Troubleshooting
&lt;a class="heading-anchor" href="#maintenance-and-troubleshooting" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="updating-your-node">Updating Your Node
&lt;a class="heading-anchor" href="#updating-your-node" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Similar to the installation process, there’s a script available to update your node. You can find it in the source repository: &lt;a rel="external" href="https://github.com/getAlby/hub/tree/master/scripts/pi-aarch64">GitHub - Alby Hub Update Script&lt;/a>&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">ssh&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> testhub@testhub.local&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;#39;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">/bin/bash -c &amp;quot;$(curl -fsSL https://getalby.com/install/hub/pi-aarch64-update.sh)&amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;#39;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;h3 id="handling-power-outages">Handling Power Outages
&lt;a class="heading-anchor" href="#handling-power-outages" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>If the power goes out, the Raspberry Pi will turn off. Once power is restored, it will automatically restart, but Alby Hub will prompt you to enter the password you set earlier.&lt;/p>
&lt;hr />
&lt;p>&lt;strong>Related links&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;a rel="external" href="https://guides.getalby.com/">GetAlby - User Guide&lt;/a>&lt;/li>
&lt;li>&lt;a rel="external" href="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/hidden-archives/raspberry-pi-zero">Installing Alby Hub in a Raspberry Zero&lt;/a>&lt;/li>
&lt;/ul></content></entry></feed>