<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.0">Jekyll</generator><link href="https://bitdevsmaputo.org/feed.xml" rel="self" type="application/atom+xml" /><link href="https://bitdevsmaputo.org/" rel="alternate" type="text/html" /><updated>2026-10-16T14:57:10+00:00</updated><id>https://bitdevsmaputo.org/feed.xml</id><title type="html">BitDevs Maputo</title><subtitle>BitDevs Maputo é uma comunidade em Maputo, Moçambique, para desenvolvedores, pesquisadores e entusiastas interessados no desenvolvimento e aplicação prática do Bitcoin, Nostr e protocolos relacionados.</subtitle><entry xml:lang="en"><title type="html">Socratic Seminar 01: Who Really Runs Bitcoin?</title><link href="https://bitdevsmaputo.org/en/2026-10-17-socratic-seminar-01" rel="alternate" type="text/html" title="Socratic Seminar 01: Who Really Runs Bitcoin?" /><published>2026-10-17T00:00:00+00:00</published><updated>2026-10-17T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/en/socratic-seminar-01</id><content type="html" xml:base="https://bitdevsmaputo.org/en/2026-10-17-socratic-seminar-01">&lt;h2 id=&quot;location&quot;&gt;Location&lt;/h2&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;The event will be hosted at &lt;strong&gt;Hotel Onomo&lt;/strong&gt;, Maputo&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://maps.app.goo.gl/usnCTwnL3faNRdG29&quot;&gt;Map&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Date:&lt;/strong&gt; October 17, 2026&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Time:&lt;/strong&gt; 09:00 to 12:00&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;announcements&quot;&gt;Announcements&lt;/h2&gt;

&lt;p&gt;Join us for the first BitDevs Maputo &lt;a href=&quot;/about&quot;&gt;Socratic Seminar&lt;/a&gt;!
We will run Bitcoin Core on our own laptops and find out who really
runs Bitcoin. A special thank you to our sponsor &lt;a href=&quot;https://www.btrust.tech/&quot;&gt;Btrust&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bring your laptop.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;reminders&quot;&gt;Reminders&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;We prefer no photos and no videos during the event&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.chathamhouse.org/about-us/chatham-house-rule&quot;&gt;Chatham House Rule&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Leave the meeting space as clean as you found it&lt;/li&gt;
  &lt;li&gt;Suggest topics for the next Socratic Seminar! &lt;a href=&quot;/about/find-topics&quot;&gt;Where to find topics?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;topics&quot;&gt;Topics&lt;/h1&gt;

&lt;h3 id=&quot;opening&quot;&gt;Opening&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Angela&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Welcome and introduction to the Socratic format&lt;/li&gt;
  &lt;li&gt;Introduction to BitDevs Maputo and the goals of the seminar&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;introduction&quot;&gt;Introduction&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Daniel&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Introduction to Bitcoin Famba&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;bitcoin-core&quot;&gt;Bitcoin Core&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Custódio&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://bitcoincore.org/en/download/&quot;&gt;Download and run a Bitcoin Core node&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md&quot;&gt;JSON-RPC interface: the commands we will use&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/bips.md&quot;&gt;BIPs implemented by Bitcoin Core&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Who decides the rules of Bitcoin? Developers, miners, exchanges, or the people who run a node?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;private--public-keys&quot;&gt;Private &amp;amp; Public Keys&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Custódio&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Not your keys, not your coins&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md&quot;&gt;Descriptors: how Core describes keys, scripts and addresses&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki&quot;&gt;BIP32: HD wallets&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/key.cpp&quot;&gt;Code: key generation (key.cpp)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;addresses--transactions&quot;&gt;Addresses &amp;amp; Transactions&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Custódio&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h&quot;&gt;Code: transaction structure (transaction.h)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp&quot;&gt;Code: validation and mempool (validation.cpp)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/net_processing.cpp&quot;&gt;Code: network propagation (net_processing.cpp)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/psbt.md&quot;&gt;PSBT: building and signing a transaction in parts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;closing--upcoming-events&quot;&gt;Closing &amp;amp; Upcoming Events&lt;/h4&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Angela&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Summary of the discussion&lt;/li&gt;
  &lt;li&gt;Next Socratic Seminar and community group&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><category term="event" /><summary type="html">Location</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="pt"><title type="html">Seminário Socrático 01: Quem manda realmente no Bitcoin?</title><link href="https://bitdevsmaputo.org/pt/2026-10-17-socratic-seminar-01" rel="alternate" type="text/html" title="Seminário Socrático 01: Quem manda realmente no Bitcoin?" /><published>2026-10-17T00:00:00+00:00</published><updated>2026-10-17T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/pt/socratic-seminar-01</id><content type="html" xml:base="https://bitdevsmaputo.org/pt/2026-10-17-socratic-seminar-01">&lt;h2 id=&quot;local&quot;&gt;Local&lt;/h2&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;O evento será no &lt;strong&gt;Hotel Onomo&lt;/strong&gt;, Maputo&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://maps.app.goo.gl/usnCTwnL3faNRdG29&quot;&gt;Mapa&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Data:&lt;/strong&gt; 17 de Outubro de 2026&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Horário:&lt;/strong&gt; 09:00 às 12:00&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;anúncios&quot;&gt;Anúncios&lt;/h2&gt;

&lt;p&gt;Junta-te a nós no primeiro &lt;a href=&quot;/about&quot;&gt;Seminário Socrático&lt;/a&gt; da BitDevs Maputo!
Vamos correr o Bitcoin Core nos nossos laptops e descobrir quem manda
realmente no Bitcoin. Um agradecimento especial ao nosso patrocinador
&lt;a href=&quot;https://www.btrust.tech/&quot;&gt;Btrust&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traz o teu laptop.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;lembretes&quot;&gt;Lembretes&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Preferimos sem fotos e sem vídeos durante o evento&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.chathamhouse.org/about-us/chatham-house-rule&quot;&gt;Regra de Chatham House&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Deixa o espaço tão limpo como o encontraste&lt;/li&gt;
  &lt;li&gt;Sugere temas para o próximo Seminário Socrático! &lt;a href=&quot;/about/find-topics&quot;&gt;Onde encontrar temas?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;temas&quot;&gt;Temas&lt;/h1&gt;

&lt;h3 id=&quot;abertura&quot;&gt;Abertura&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Angela&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Boas-vindas e apresentação do formato socrático&lt;/li&gt;
  &lt;li&gt;Apresentação da BitDevs Maputo e dos objectivos do seminário&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;apresentação&quot;&gt;Apresentação&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Daniel&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Apresentação do Bitcoin Famba&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;bitcoin-core&quot;&gt;Bitcoin Core&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Custódio&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://bitcoincore.org/en/download/&quot;&gt;Descarregar e correr um nó Bitcoin Core&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md&quot;&gt;Interface JSON-RPC: os comandos que vamos usar&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/bips.md&quot;&gt;BIPs implementados pelo Bitcoin Core&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Quem decide as regras do Bitcoin? Programadores, mineradores, exchanges ou quem corre um nó?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;chaves-privadas-e-públicas&quot;&gt;Chaves Privadas e Públicas&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Custódio&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Not your keys, not your coins&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md&quot;&gt;Descriptors: como o Core descreve chaves, scripts e endereços&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki&quot;&gt;BIP32: carteiras HD&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/key.cpp&quot;&gt;Código: geração de chaves (key.cpp)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;entropia&quot;&gt;Entropia&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Custódio&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Not your entropia, not your coins&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/random.cpp&quot;&gt;Código: fonte de aleatoriedade (random.cpp)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;O Core não usa BIP39: o que é realmente a tua seed?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;endereços-e-transações&quot;&gt;Endereços e Transações&lt;/h3&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Custódio&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h&quot;&gt;Código: estrutura de uma transação (transaction.h)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp&quot;&gt;Código: validação e mempool (validation.cpp)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/src/net_processing.cpp&quot;&gt;Código: propagação pela rede (net_processing.cpp)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bitcoin/bitcoin/blob/master/doc/psbt.md&quot;&gt;PSBT: construir e assinar uma transação por partes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;encerramento-e-próximos-eventos&quot;&gt;Encerramento e Próximos Eventos&lt;/h4&gt;

&lt;hr /&gt;

&lt;p&gt;MC: Angela&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Resumo da discussão&lt;/li&gt;
  &lt;li&gt;Próximo Seminário Socrático e grupo da comunidade&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><category term="event" /><summary type="html">Local</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="en"><title type="html">Protect Your Bitcoin Like Satoshi</title><link href="https://bitdevsmaputo.org/en/blog/protect-your-bitcoin-like-satoshi" rel="alternate" type="text/html" title="Protect Your Bitcoin Like Satoshi" /><published>2026-10-16T00:00:00+00:00</published><updated>2026-10-16T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/en/blog/secure-your-bitcoin-like-satoshi</id><content type="html" xml:base="https://bitdevsmaputo.org/en/blog/protect-your-bitcoin-like-satoshi">&lt;h2 id=&quot;protect-your-bitcoin-like-satoshi-a-guide-to-cold-storage-with-an-air-gapped-laptop&quot;&gt;Protect Your Bitcoin Like Satoshi: A Guide to Cold Storage with an Air-Gapped Laptop&lt;/h2&gt;

&lt;h3 id=&quot;introduction-and-philosophy&quot;&gt;Introduction and Philosophy&lt;/h3&gt;

&lt;p&gt;Bitcoin security depends on protecting the private keys that allow funds to be spent. Today, many users rely on hardware wallets such as Coldcard, Trezor, and Ledger. However, it is also possible to build a cold storage solution using a dedicated computer, auditable software, and a rigorous network isolation process.&lt;/p&gt;

&lt;p&gt;The idea is to turn an old laptop into an &lt;em&gt;air-gapped&lt;/em&gt; device: a computer kept physically isolated from the internet and other networks. This device is used exclusively to generate and protect private keys and sign Bitcoin transactions offline.&lt;/p&gt;

&lt;p&gt;This approach helps users better understand Bitcoin’s security mechanisms and reduces dependence on specialized devices. However, it requires technical knowledge, careful procedures, and thorough testing before storing significant funds.&lt;/p&gt;

&lt;h3 id=&quot;why-consider-an-air-gapped-laptop&quot;&gt;Why Consider an Air-Gapped Laptop?&lt;/h3&gt;

&lt;h4 id=&quot;1-control-over-software-and-hardware&quot;&gt;1. Control Over Software and Hardware&lt;/h4&gt;

&lt;p&gt;Hardware wallets offer convenience, but they also require trust in their firmware, manufacturing process, and random number generation mechanisms.&lt;/p&gt;

&lt;p&gt;With a dedicated computer, users can choose the operating system, verify installation files, inspect the software, and document the configuration process.&lt;/p&gt;

&lt;p&gt;This does not automatically make a laptop more secure. Security depends on implementation quality, software provenance, entropy generation, and backup protection.&lt;/p&gt;

&lt;h4 id=&quot;2-privacy&quot;&gt;2. Privacy&lt;/h4&gt;

&lt;p&gt;Purchasing specialized devices may create commercial records linking a person to a particular product. A generic laptop may reduce this direct association, although it does not guarantee anonymity or eliminate other privacy risks.&lt;/p&gt;

&lt;p&gt;Privacy also depends on how users manage transactions, communicate with Bitcoin nodes, and protect information associated with their wallets.&lt;/p&gt;

&lt;h4 id=&quot;3-technological-independence&quot;&gt;3. Technological Independence&lt;/h4&gt;

&lt;p&gt;A dedicated computer allows users to build a security process they understand and control without relying exclusively on a specific manufacturer.&lt;/p&gt;

&lt;p&gt;However, this independence comes with responsibility: users must maintain verified backups and understand how to recover their funds if the equipment fails.&lt;/p&gt;

&lt;h3 id=&quot;what-does-air-gapped-mean&quot;&gt;What Does Air-Gapped Mean?&lt;/h3&gt;

&lt;p&gt;An &lt;em&gt;air-gapped&lt;/em&gt; device is a computer kept isolated from external networks, including the internet. For a rigorous security setup, isolation must be planned and verified rather than simply assumed.&lt;/p&gt;

&lt;p&gt;The dedicated laptop serves two main purposes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Key generation:&lt;/strong&gt; Create private cryptographic material in a controlled environment.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Offline signing:&lt;/strong&gt; Sign transactions without exposing private keys to an internet-connected computer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The process can work as follows:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;An online computer prepares an unsigned Bitcoin transaction.&lt;/li&gt;
  &lt;li&gt;The transaction is transferred to the offline device using a controlled transfer method.&lt;/li&gt;
  &lt;li&gt;The offline device verifies the transaction data and signs it.&lt;/li&gt;
  &lt;li&gt;The signed transaction is returned to the online computer.&lt;/li&gt;
  &lt;li&gt;The online computer broadcasts the transaction to the Bitcoin network.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Private keys remain on the offline device throughout the process. Transferred files must be handled carefully because USB drives and memory cards can introduce security risks.&lt;/p&gt;

&lt;h3 id=&quot;implementation-roadmap-five-stages&quot;&gt;Implementation Roadmap: Five Stages&lt;/h3&gt;

&lt;h4 id=&quot;episode-1--hardware-and-security-philosophy&quot;&gt;Episode 1 — Hardware and Security Philosophy&lt;/h4&gt;

&lt;p&gt;Understand the principles of minimizing trust, isolation, private key protection, and long-term preservation.&lt;/p&gt;

&lt;h4 id=&quot;episode-2--communication-isolation&quot;&gt;Episode 2 — Communication Isolation&lt;/h4&gt;

&lt;p&gt;Identify and disable unnecessary communication interfaces, including Wi-Fi and Bluetooth. Physical component removal may be considered when appropriate, but only after understanding the equipment’s limitations.&lt;/p&gt;

&lt;h4 id=&quot;episode-3--operating-system-and-bitcoin-software&quot;&gt;Episode 3 — Operating System and Bitcoin Software&lt;/h4&gt;

&lt;p&gt;Install an appropriate operating system, obtain Bitcoin software from official sources, and verify the authenticity and integrity of installation files before use.&lt;/p&gt;

&lt;h4 id=&quot;episode-4--key-generation-and-offline-signing&quot;&gt;Episode 4 — Key Generation and Offline Signing&lt;/h4&gt;

&lt;p&gt;Understand entropy generation, wallet creation, and offline transaction signing. Test the entire process with small amounts before using real funds.&lt;/p&gt;

&lt;h4 id=&quot;episode-5--backups-and-long-term-preservation&quot;&gt;Episode 5 — Backups and Long-Term Preservation&lt;/h4&gt;

&lt;p&gt;Explore recovery methods, protection against physical damage, backup redundancy, and the procedures required to recover a wallet in the future.&lt;/p&gt;

&lt;h3 id=&quot;hardware-selection-lenovo-thinkpad-t530&quot;&gt;Hardware Selection: Lenovo ThinkPad T530&lt;/h3&gt;

&lt;p&gt;One example of hardware worth investigating for this project is the &lt;strong&gt;Lenovo ThinkPad T530&lt;/strong&gt;, a laptop released in 2012.&lt;/p&gt;

&lt;p&gt;Its maintainability and replaceable components make it a potential candidate for experimentation. However, its age also requires attention to the battery, storage, memory, and overall system condition.&lt;/p&gt;

&lt;p&gt;Before selecting a laptop, consider:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Whether communication interfaces can be disabled or removed.&lt;/li&gt;
  &lt;li&gt;Compatibility with a suitable operating system.&lt;/li&gt;
  &lt;li&gt;The ability to verify and maintain the software in use.&lt;/li&gt;
  &lt;li&gt;Firmware integrity and hardware-related risks.&lt;/li&gt;
  &lt;li&gt;The ease of creating and recovering backups.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Models such as the ThinkPad X220, X230, and T420 can also be investigated, particularly by users interested in alternative firmware. Compatibility with projects such as Coreboot or Libreboot must be verified for the exact hardware configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Keeping a computer offline reduces exposure to remote attacks, but it does not eliminate firmware vulnerabilities, implementation flaws, entropy problems, or physical tampering risks.&lt;/p&gt;

&lt;h3 id=&quot;security-what-you-should-never-ignore&quot;&gt;Security: What You Should Never Ignore&lt;/h3&gt;

&lt;p&gt;An &lt;em&gt;air-gapped&lt;/em&gt; system is not an absolute security guarantee. To reduce risks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Obtain software from official sources and verify applicable signatures or checksums.&lt;/li&gt;
  &lt;li&gt;Never introduce files or storage devices from unknown sources into the offline computer.&lt;/li&gt;
  &lt;li&gt;Never photograph recovery phrases or store them in cloud services.&lt;/li&gt;
  &lt;li&gt;Maintain protected backups and periodically verify that they can be recovered.&lt;/li&gt;
  &lt;li&gt;Test wallet recovery before storing significant amounts.&lt;/li&gt;
  &lt;li&gt;Consider a multisignature configuration when your security requirements and technical knowledge justify it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security also depends on recoverability. A highly isolated wallet is of little practical use if its recovery phrase is lost, potentially resulting in permanent loss of access to the bitcoins.&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Building a cold storage solution with a dedicated laptop is an opportunity to study cryptography, operational security, and how Bitcoin transactions work.&lt;/p&gt;

&lt;p&gt;The goal is not simply to replace a hardware wallet with an old computer. It is to understand the risks, verify the components being used, and establish a generation, signing, and recovery process that can be audited and tested.&lt;/p&gt;

&lt;p&gt;The best solution is one whose security you understand, whose procedures you can execute correctly, and whose recovery process you can demonstrate before trusting it with your bitcoins.&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">Protect Your Bitcoin Like Satoshi: A Guide to Cold Storage with an Air-Gapped Laptop</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="pt"><title type="html">Proteja o seu Bitcoin como Satoshi</title><link href="https://bitdevsmaputo.org/pt/blog/proteja-o-seu-bitcoin-como-satoshi" rel="alternate" type="text/html" title="Proteja o seu Bitcoin como Satoshi" /><published>2026-10-16T00:00:00+00:00</published><updated>2026-10-16T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/pt/blog/secure-your-bitcoin-like-satoshi</id><content type="html" xml:base="https://bitdevsmaputo.org/pt/blog/proteja-o-seu-bitcoin-como-satoshi">&lt;h2 id=&quot;proteja-o-seu-bitcoin-como-satoshi-guia-de-cold-storage-com-portátil-air-gapped&quot;&gt;Proteja o seu Bitcoin como Satoshi: Guia de Cold Storage com Portátil Air-Gapped&lt;/h2&gt;

&lt;h3 id=&quot;introdução-e-filosofia&quot;&gt;Introdução e filosofia&lt;/h3&gt;

&lt;p&gt;A segurança do Bitcoin depende da proteção das chaves privadas que permitem movimentar os fundos. Atualmente, muitos utilizadores recorrem a carteiras de hardware, como Coldcard, Trezor e Ledger. No entanto, também é possível construir uma solução de &lt;em&gt;cold storage&lt;/em&gt; utilizando um computador dedicado, software auditável e um processo rigoroso de isolamento de redes.&lt;/p&gt;

&lt;p&gt;A ideia é transformar um portátil antigo num dispositivo &lt;em&gt;air-gapped&lt;/em&gt;, ou seja, um computador mantido fisicamente isolado da internet e de outras redes. Este dispositivo é utilizado exclusivamente para gerar e proteger chaves privadas e assinar transações Bitcoin offline.&lt;/p&gt;

&lt;p&gt;Esta abordagem permite compreender melhor os mecanismos de segurança do Bitcoin e reduzir a dependência de dispositivos especializados. Contudo, exige conhecimentos técnicos, procedimentos cuidadosos e testes antes de guardar fundos significativos.&lt;/p&gt;

&lt;h3 id=&quot;por-que-considerar-um-portátil-air-gapped&quot;&gt;Por que considerar um portátil air-gapped?&lt;/h3&gt;

&lt;h4 id=&quot;1-controlo-sobre-o-software-e-o-hardware&quot;&gt;1. Controlo sobre o software e o hardware&lt;/h4&gt;

&lt;p&gt;Uma carteira de hardware oferece conveniência, mas também exige confiança no seu firmware, no processo de fabrico e nos mecanismos utilizados para gerar números aleatórios.&lt;/p&gt;

&lt;p&gt;Com um computador dedicado, o utilizador pode escolher o sistema operativo, verificar os ficheiros de instalação, analisar o software e documentar o processo de configuração.&lt;/p&gt;

&lt;p&gt;Isto não significa que um portátil seja automaticamente mais seguro. A segurança depende da qualidade da implementação, da origem do software, da geração de entropia e da proteção das cópias de segurança.&lt;/p&gt;

&lt;h4 id=&quot;2-privacidade&quot;&gt;2. Privacidade&lt;/h4&gt;

&lt;p&gt;A aquisição de dispositivos especializados pode criar registos comerciais que associam uma pessoa a determinado produto. Um portátil genérico pode reduzir essa associação direta, embora não garanta anonimato nem elimine outros riscos de privacidade.&lt;/p&gt;

&lt;p&gt;A privacidade também depende da forma como o utilizador gere as suas transações, comunica com nós Bitcoin e protege as informações relacionadas com a sua carteira.&lt;/p&gt;

&lt;h4 id=&quot;3-independência-tecnológica&quot;&gt;3. Independência tecnológica&lt;/h4&gt;

&lt;p&gt;Um computador dedicado permite construir um processo de segurança compreendido e controlado pelo próprio utilizador, sem depender exclusivamente de um fabricante específico.&lt;/p&gt;

&lt;p&gt;Esta independência exige, porém, responsabilidade: o utilizador deve manter cópias de segurança verificadas e compreender como recuperar os fundos em caso de falha do equipamento.&lt;/p&gt;

&lt;h3 id=&quot;o-que-significa-air-gapped&quot;&gt;O que significa air-gapped?&lt;/h3&gt;

&lt;p&gt;Um dispositivo &lt;em&gt;air-gapped&lt;/em&gt; é um computador mantido isolado de redes externas, incluindo a internet. Para uma configuração de segurança rigorosa, o isolamento deve ser planeado e verificado, não apenas presumido.&lt;/p&gt;

&lt;p&gt;O portátil dedicado desempenha duas funções principais:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Geração de chaves:&lt;/strong&gt; criar material criptográfico privado num ambiente controlado.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Assinatura offline:&lt;/strong&gt; assinar transações sem expor as chaves privadas a um computador ligado à internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;O processo pode funcionar da seguinte forma:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Um computador online prepara uma transação Bitcoin sem assinatura.&lt;/li&gt;
  &lt;li&gt;A transação é transferida para o dispositivo offline através de um meio de transferência controlado.&lt;/li&gt;
  &lt;li&gt;O dispositivo offline verifica os dados e assina a transação.&lt;/li&gt;
  &lt;li&gt;A transação assinada regressa ao computador online.&lt;/li&gt;
  &lt;li&gt;O computador online transmite a transação à rede Bitcoin.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As chaves privadas permanecem no dispositivo offline durante todo o processo. Os dados transferidos devem ser tratados com cuidado, porque um meio USB ou cartão de memória também pode introduzir riscos de segurança.&lt;/p&gt;

&lt;h3 id=&quot;roteiro-de-implementação-cinco-etapas&quot;&gt;Roteiro de implementação: cinco etapas&lt;/h3&gt;

&lt;h4 id=&quot;episódio-1--hardware-e-filosofia-de-segurança&quot;&gt;Episódio 1 — Hardware e filosofia de segurança&lt;/h4&gt;

&lt;p&gt;Compreender os princípios de minimização da confiança, isolamento, proteção das chaves privadas e preservação de longo prazo.&lt;/p&gt;

&lt;h4 id=&quot;episódio-2--isolamento-das-comunicações&quot;&gt;Episódio 2 — Isolamento das comunicações&lt;/h4&gt;

&lt;p&gt;Identificar e desativar as interfaces de comunicação desnecessárias, incluindo Wi-Fi e Bluetooth. A remoção física de componentes pode ser considerada, mas deve ser realizada apenas quando apropriada e depois de compreender as limitações do equipamento.&lt;/p&gt;

&lt;h4 id=&quot;episódio-3--sistema-operativo-e-software-bitcoin&quot;&gt;Episódio 3 — Sistema operativo e software Bitcoin&lt;/h4&gt;

&lt;p&gt;Instalar um sistema operativo apropriado, obter o software Bitcoin de fontes oficiais e verificar a autenticidade e integridade dos ficheiros antes de os utilizar.&lt;/p&gt;

&lt;h4 id=&quot;episódio-4--geração-de-chaves-e-assinatura-offline&quot;&gt;Episódio 4 — Geração de chaves e assinatura offline&lt;/h4&gt;

&lt;p&gt;Compreender a geração de entropia, a criação de carteiras e o processo de assinatura de transações offline. Antes de utilizar fundos reais, testar todo o fluxo com pequenas quantias.&lt;/p&gt;

&lt;h4 id=&quot;episódio-5--cópias-de-segurança-e-preservação-de-longo-prazo&quot;&gt;Episódio 5 — Cópias de segurança e preservação de longo prazo&lt;/h4&gt;

&lt;p&gt;Estudar os métodos de recuperação, a proteção contra danos físicos, a redundância das cópias de segurança e os procedimentos necessários para recuperar a carteira no futuro.&lt;/p&gt;

&lt;h3 id=&quot;escolha-do-hardware-lenovo-thinkpad-t530&quot;&gt;Escolha do hardware: Lenovo ThinkPad T530&lt;/h3&gt;

&lt;p&gt;Um exemplo de equipamento que pode ser estudado para este projeto é o &lt;strong&gt;Lenovo ThinkPad T530&lt;/strong&gt;, um portátil lançado em 2012.&lt;/p&gt;

&lt;p&gt;Entre as características relevantes estão a possibilidade de manutenção e a disponibilidade de componentes substituíveis. No entanto, a idade do equipamento também exige atenção à bateria, ao armazenamento, à memória e ao estado geral do sistema.&lt;/p&gt;

&lt;p&gt;Antes de escolher um portátil, é importante considerar:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A possibilidade de desativar ou remover interfaces de comunicação.&lt;/li&gt;
  &lt;li&gt;A compatibilidade com um sistema operativo adequado.&lt;/li&gt;
  &lt;li&gt;A capacidade de verificar e manter o software utilizado.&lt;/li&gt;
  &lt;li&gt;A integridade do firmware e os riscos associados ao hardware.&lt;/li&gt;
  &lt;li&gt;A facilidade de criar e recuperar cópias de segurança.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Modelos como o ThinkPad X220, X230 e T420 também podem ser investigados, especialmente por quem pretende estudar firmware alternativo. A compatibilidade com projetos como Coreboot ou Libreboot deve ser confirmada para a configuração exata do equipamento.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Importante:&lt;/strong&gt; manter um computador offline reduz a exposição a ataques remotos, mas não elimina vulnerabilidades de firmware, falhas de implementação, problemas de entropia ou riscos de manipulação física.&lt;/p&gt;

&lt;h3 id=&quot;segurança-o-que-não-deves-ignorar&quot;&gt;Segurança: o que não deves ignorar&lt;/h3&gt;

&lt;p&gt;Um sistema &lt;em&gt;air-gapped&lt;/em&gt; não é uma garantia absoluta de segurança. Para reduzir os riscos:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Obtém o software a partir de fontes oficiais e verifica as assinaturas ou somas de verificação aplicáveis.&lt;/li&gt;
  &lt;li&gt;Não introduzas no dispositivo offline ficheiros ou suportes de origem desconhecida.&lt;/li&gt;
  &lt;li&gt;Nunca fotografes nem guardes frases de recuperação em serviços na nuvem.&lt;/li&gt;
  &lt;li&gt;Mantém cópias de segurança protegidas e verifica periodicamente se podem ser recuperadas.&lt;/li&gt;
  &lt;li&gt;Testa a recuperação da carteira antes de guardar valores significativos.&lt;/li&gt;
  &lt;li&gt;Considera uma configuração multisig quando as necessidades de segurança e o nível de conhecimento o justificarem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A segurança também depende da capacidade de recuperar os fundos. Uma carteira muito bem isolada, mas cuja frase de recuperação se perde, pode resultar na perda definitiva do acesso aos bitcoins.&lt;/p&gt;

&lt;h3 id=&quot;conclusão&quot;&gt;Conclusão&lt;/h3&gt;

&lt;p&gt;Construir uma solução de &lt;em&gt;cold storage&lt;/em&gt; com um portátil dedicado é uma oportunidade para estudar criptografia, segurança operacional e o funcionamento das transações Bitcoin.&lt;/p&gt;

&lt;p&gt;O objetivo não é simplesmente substituir uma carteira de hardware por um computador antigo. É compreender os riscos, verificar os componentes utilizados e criar um processo de geração, assinatura e recuperação que possa ser auditado e testado.&lt;/p&gt;

&lt;p&gt;A melhor solução será aquela cuja segurança compreendes, cujos procedimentos consegues executar corretamente e cuja recuperação consegues demonstrar antes de confiar nela os teus bitcoins.&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">Proteja o seu Bitcoin como Satoshi: Guia de Cold Storage com Portátil Air-Gapped</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="en"><title type="html">The Magic of Key Multiplication: Understanding BIP32 in Bitcoin</title><link href="https://bitdevsmaputo.org/en/blog/bip32-key-derivation" rel="alternate" type="text/html" title="The Magic of Key Multiplication: Understanding BIP32 in Bitcoin" /><published>2026-10-15T00:00:00+00:00</published><updated>2026-10-15T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/en/blog/bip32-key-derivation</id><content type="html" xml:base="https://bitdevsmaputo.org/en/blog/bip32-key-derivation">&lt;h2 id=&quot;the-magic-of-key-multiplication-understanding-bip32-in-bitcoin&quot;&gt;The Magic of Key Multiplication: Understanding BIP32 in Bitcoin&lt;/h2&gt;

&lt;h3 id=&quot;introduction&quot;&gt;Introduction&lt;/h3&gt;

&lt;p&gt;Many Bitcoin users are familiar with the sequence of 12 or 24 English words used to back up digital wallets through &lt;strong&gt;BIP39&lt;/strong&gt;. However, to understand how these words can restore a wallet’s keys and addresses, it is important to take a step back and understand &lt;strong&gt;BIP32&lt;/strong&gt; (&lt;em&gt;Bitcoin Improvement Proposal 32&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Inspired by the technical lesson by Tiago Salem, titled &lt;em&gt;“A Magia da Multiplicação de Chaves — BIP32”&lt;/em&gt;, this article explores how elliptic curve mathematics enables the creation of &lt;strong&gt;Hierarchical Deterministic (HD) wallets&lt;/strong&gt;, eliminating the need to manage thousands of independent private keys.&lt;/p&gt;

&lt;h3 id=&quot;what-is-a-bitcoin-improvement-proposal-bip&quot;&gt;What Is a Bitcoin Improvement Proposal (BIP)?&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;Bitcoin Improvement Proposal (BIP)&lt;/strong&gt; is a document that describes a proposed standard, process, or improvement related to Bitcoin.&lt;/p&gt;

&lt;p&gt;Bitcoin development emphasizes careful review and community discussion. BIPs provide a structured way to document technical ideas, discuss their implications, and coordinate implementations.&lt;/p&gt;

&lt;p&gt;Introduced in 2012, BIP32 established a standard for deriving a hierarchy of cryptographic keys from a single master seed, making wallet management and backup significantly more practical.&lt;/p&gt;

&lt;h3 id=&quot;the-evolution-of-bitcoin-key-management&quot;&gt;The Evolution of Bitcoin Key Management&lt;/h3&gt;

&lt;h4 id=&quot;1-the-cryptographic-foundation&quot;&gt;1. The Cryptographic Foundation&lt;/h4&gt;

&lt;p&gt;Bitcoin uses elliptic curve cryptography based on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secp256k1&lt;/code&gt; curve to generate public and private keys.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Private key:&lt;/strong&gt; A secret integer represented using 32 bytes. It authorizes the signing of transactions that spend the associated funds.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Public key:&lt;/strong&gt; A point on the elliptic curve represented by coordinates ((x, y)).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Bitcoin address:&lt;/strong&gt; An encoded identifier derived through a specific process involving public key data, depending on the address type.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The public key is calculated from the private key using elliptic curve multiplication:&lt;/p&gt;

&lt;p&gt;[
P = kG
]&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;(k) is the private key.&lt;/li&gt;
  &lt;li&gt;(G) is the generator point of the curve.&lt;/li&gt;
  &lt;li&gt;(P) is the corresponding public key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Calculating (P) from (k) is computationally practical. Recovering (k) from (P), however, is considered computationally infeasible with current classical computing methods when secure parameters are used. This is the elliptic curve discrete logarithm problem.&lt;/p&gt;

&lt;h4 id=&quot;2-the-original-problem-address-reuse-and-endless-backups&quot;&gt;2. The Original Problem: Address Reuse and Endless Backups&lt;/h4&gt;

&lt;p&gt;Bitcoin users are encouraged to avoid address reuse to improve financial privacy.&lt;/p&gt;

&lt;p&gt;Before hierarchical deterministic wallets became widespread, wallet software could generate independent random private keys for new addresses. Managing these keys created several challenges:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Backup complexity:&lt;/strong&gt; Users needed to ensure that newly generated keys were included in their backups. A backup that did not contain a required key could result in permanent loss of access to funds.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Operational limitations:&lt;/strong&gt; Businesses and payment systems needed a way to generate new receiving addresses without exposing private keys to online servers.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Recovery difficulties:&lt;/strong&gt; Managing a growing collection of unrelated keys made wallet restoration more complicated.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;BIP32 addressed these problems by introducing a standardized hierarchy of related keys.&lt;/p&gt;

&lt;h3 id=&quot;the-bip32-solution-hierarchical-deterministic-wallets&quot;&gt;The BIP32 Solution: Hierarchical Deterministic Wallets&lt;/h3&gt;

&lt;p&gt;BIP32 introduced a system in which a master key and a chain code can be used to derive a hierarchy of child keys.&lt;/p&gt;

&lt;p&gt;Instead of independently generating and backing up every private key, a wallet can derive many related keys from a single master seed.&lt;/p&gt;

&lt;p&gt;This structure can be represented as a tree:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Master key:&lt;/strong&gt; The root of the hierarchy.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Child keys:&lt;/strong&gt; Keys derived from a parent key.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Grandchild keys:&lt;/strong&gt; Keys derived from child keys.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Branches:&lt;/strong&gt; Separate paths used for different accounts, addresses, or purposes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The derivation process is deterministic: given the same master seed and derivation path, a wallet can reproduce the same keys.&lt;/p&gt;

&lt;h3 id=&quot;the-mathematics-behind-public-key-derivation&quot;&gt;The Mathematics Behind Public Key Derivation&lt;/h3&gt;

&lt;p&gt;The key mathematical property comes from elliptic curve group operations.&lt;/p&gt;

&lt;p&gt;A public key is calculated as:&lt;/p&gt;

&lt;p&gt;[
P = kG
]&lt;/p&gt;

&lt;p&gt;Suppose a new private key is calculated by adding a scalar (t) to the original private key:&lt;/p&gt;

&lt;p&gt;[
k’ = k + t \pmod n
]&lt;/p&gt;

&lt;p&gt;The corresponding public key is:&lt;/p&gt;

&lt;p&gt;[
P’ = k’G
]&lt;/p&gt;

&lt;p&gt;Substituting the private key expression gives:&lt;/p&gt;

&lt;p&gt;[
P’ = (k+t)G
]&lt;/p&gt;

&lt;p&gt;Using the properties of elliptic curve group operations:&lt;/p&gt;

&lt;p&gt;[
P’ = kG+tG
]&lt;/p&gt;

&lt;p&gt;Since (P=kG), we obtain:&lt;/p&gt;

&lt;p&gt;[
\boxed{P’=P+tG}
]&lt;/p&gt;

&lt;p&gt;This means the new public key can be calculated using the original public key and the corresponding public derivation data, without revealing the original private key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An important distinction:&lt;/strong&gt; BIP32 does not simply multiply a private key by an arbitrary factor. It uses a cryptographic derivation function based on HMAC-SHA512, together with elliptic curve operations and a chain code.&lt;/p&gt;

&lt;p&gt;For a non-hardened child key, the simplified mathematical relationship is:&lt;/p&gt;

&lt;p&gt;[
k_i = (\operatorname{parse}&lt;em&gt;{256}(I_L)+k&lt;/em&gt;{\text{par}})\bmod n
]&lt;/p&gt;

&lt;p&gt;And the corresponding public key is:&lt;/p&gt;

&lt;p&gt;[
K_i = \operatorname{parse}&lt;em&gt;{256}(I_L)G+K&lt;/em&gt;{\text{par}}
]&lt;/p&gt;

&lt;p&gt;Here, (I_L) is derived from the HMAC-SHA512 output, (k_{\text{par}}) is the parent private key, (K_{\text{par}}) is the parent public key, and (n) is the order of the generator point.&lt;/p&gt;

&lt;p&gt;The chain code and derivation index determine the derivation data. This is what makes BIP32 derivation structured and reproducible rather than a simple arbitrary multiplication.&lt;/p&gt;

&lt;h3 id=&quot;a-practical-demonstration-in-python&quot;&gt;A Practical Demonstration in Python&lt;/h3&gt;

&lt;p&gt;A mathematical demonstration can help illustrate the relationship between private and public keys.&lt;/p&gt;

&lt;p&gt;Using a suitable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secp256k1&lt;/code&gt; library, the experiment can follow these steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Generate an initial private key (k).&lt;/li&gt;
  &lt;li&gt;Calculate its public key (P=kG).&lt;/li&gt;
  &lt;li&gt;Choose a valid scalar (t).&lt;/li&gt;
  &lt;li&gt;Calculate a new private key (k’=(k+t)\bmod n).&lt;/li&gt;
  &lt;li&gt;Calculate the new public key directly from (k’).&lt;/li&gt;
  &lt;li&gt;Independently calculate (P’=P+tG).&lt;/li&gt;
  &lt;li&gt;Compare both resulting public keys.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The two public keys should match, provided the scalar values are valid and the operations are implemented correctly.&lt;/p&gt;

&lt;p&gt;This experiment illustrates the mathematical property behind non-hardened public key derivation. It is not, by itself, a complete BIP32 implementation, because actual BIP32 derivation also requires HMAC-SHA512, chain codes, serialization, and derivation indexes.&lt;/p&gt;

&lt;p&gt;For real Bitcoin wallets, use established implementations rather than experimental code to generate or manage private keys.&lt;/p&gt;

&lt;h3 id=&quot;extended-keys-xprv-and-xpub&quot;&gt;Extended Keys: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;BIP32 defines serialized extended keys that combine key material with a chain code and metadata required for derivation.&lt;/p&gt;

&lt;h4 id=&quot;xprv--extended-private-key&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt; — Extended Private Key&lt;/h4&gt;

&lt;p&gt;An extended private key contains a private key and its associated chain code, together with derivation metadata.&lt;/p&gt;

&lt;p&gt;It can derive private and public descendants, subject to the derivation rules.&lt;/p&gt;

&lt;p&gt;Anyone who obtains an extended private key can generally derive the private keys within its corresponding subtree and spend the associated funds.&lt;/p&gt;

&lt;h4 id=&quot;xpub--extended-public-key&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; — Extended Public Key&lt;/h4&gt;

&lt;p&gt;An extended public key contains a public key and its chain code, along with derivation metadata.&lt;/p&gt;

&lt;p&gt;It allows the derivation of non-hardened public descendants without access to private keys. This makes it useful for watch-only wallets, payment systems, and online servers that need to generate receiving addresses without being able to sign transactions.&lt;/p&gt;

&lt;p&gt;However, an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; is not harmless public information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Privacy and security warning:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Sharing an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; can expose a substantial portion of a wallet’s address structure and transaction activity.&lt;/li&gt;
  &lt;li&gt;An &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; alone does not normally allow an attacker to spend funds.&lt;/li&gt;
  &lt;li&gt;Combining a parent extended public key with a corresponding non-hardened child private key can reveal the parent private key under the applicable BIP32 derivation conditions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For these reasons, extended public keys should be shared only when necessary and with a clear understanding of the privacy implications.&lt;/p&gt;

&lt;h3 id=&quot;bip32-and-bip39-understanding-the-difference&quot;&gt;BIP32 and BIP39: Understanding the Difference&lt;/h3&gt;

&lt;p&gt;BIP32 and BIP39 solve related but different problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BIP32&lt;/strong&gt; defines hierarchical deterministic key derivation: how a master key can produce a structured tree of child keys.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BIP39&lt;/strong&gt; defines a mnemonic system that converts computer-generated entropy into a sequence of words and uses that mnemonic, together with an optional passphrase, to derive a seed.&lt;/p&gt;

&lt;p&gt;The relationship can be summarized as follows:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Entropy is generated securely.&lt;/li&gt;
  &lt;li&gt;BIP39 converts the entropy into a mnemonic phrase.&lt;/li&gt;
  &lt;li&gt;The mnemonic and optional passphrase are processed to produce a seed.&lt;/li&gt;
  &lt;li&gt;BIP32 uses the seed to generate the master key and chain code.&lt;/li&gt;
  &lt;li&gt;Child keys are derived according to specified paths.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A recovery phrase is therefore not simply a readable version of an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt;. It is an input used to reconstruct the seed from which the wallet’s key hierarchy can be derived.&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;BIP32 is a foundational standard for modern deterministic Bitcoin wallets. By combining cryptographic derivation with the mathematical properties of elliptic curves, it makes key management more scalable and enables useful separation between public address generation and private transaction signing.&lt;/p&gt;

&lt;p&gt;Understanding the relationship between private keys, public keys, chain codes, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; is essential for anyone studying Bitcoin development, wallet architecture, or cryptographic security.&lt;/p&gt;

&lt;p&gt;The most important lesson is that &lt;strong&gt;BIP32 is not merely a trick involving key multiplication&lt;/strong&gt;. It is a carefully specified derivation system that makes deterministic wallet recovery and non-hardened public key derivation possible while preserving the secrecy of private keys under the intended security assumptions.&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">The Magic of Key Multiplication: Understanding BIP32 in Bitcoin</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="pt"><title type="html">A Magia da Multiplicação de Chaves: Entendendo a BIP32</title><link href="https://bitdevsmaputo.org/pt/blog/bip32-multiplicacao-chaves" rel="alternate" type="text/html" title="A Magia da Multiplicação de Chaves: Entendendo a BIP32" /><published>2026-10-15T00:00:00+00:00</published><updated>2026-10-15T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/pt/blog/bip32-multiplicacao-chaves</id><content type="html" xml:base="https://bitdevsmaputo.org/pt/blog/bip32-multiplicacao-chaves">&lt;h2 id=&quot;a-magia-da-multiplicação-de-chaves-entendendo-a-bip32-no-bitcoin&quot;&gt;A Magia da Multiplicação de Chaves: Entendendo a BIP32 no Bitcoin&lt;/h2&gt;

&lt;h3 id=&quot;introdução&quot;&gt;Introdução&lt;/h3&gt;

&lt;p&gt;Muitos utilizadores de Bitcoin estão familiarizados com a sequência de 12 ou 24 palavras utilizada para recuperar uma carteira digital através da &lt;strong&gt;BIP39&lt;/strong&gt;. Contudo, para compreender como essas palavras permitem recuperar as chaves e os endereços de uma carteira, é importante conhecer a &lt;strong&gt;BIP32&lt;/strong&gt; (&lt;em&gt;Bitcoin Improvement Proposal 32&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Inspirado na aula técnica de Tiago Salem, intitulada &lt;em&gt;“A Magia da Multiplicação de Chaves — BIP32”&lt;/em&gt;, este artigo explora como a matemática das curvas elípticas permite criar &lt;strong&gt;carteiras determinísticas hierárquicas&lt;/strong&gt; (&lt;em&gt;Hierarchical Deterministic Wallets&lt;/em&gt; ou HD Wallets), eliminando a necessidade de gerir milhares de chaves privadas independentes.&lt;/p&gt;

&lt;h3 id=&quot;o-que-é-uma-bip-bitcoin-improvement-proposal&quot;&gt;O que é uma BIP (&lt;em&gt;Bitcoin Improvement Proposal&lt;/em&gt;)?&lt;/h3&gt;

&lt;p&gt;Uma &lt;strong&gt;Bitcoin Improvement Proposal (BIP)&lt;/strong&gt; é um documento que descreve uma proposta de padrão, processo ou melhoria relacionada com o Bitcoin.&lt;/p&gt;

&lt;p&gt;O desenvolvimento do Bitcoin privilegia uma análise cuidadosa e a discussão comunitária. As BIPs permitem documentar ideias técnicas, discutir as suas implicações e coordenar as respetivas implementações.&lt;/p&gt;

&lt;p&gt;Proposta em 2012, a BIP32 estabeleceu um padrão para derivar uma hierarquia de chaves criptográficas a partir de uma única semente mestre, tornando a gestão e a recuperação de carteiras muito mais práticas.&lt;/p&gt;

&lt;h3 id=&quot;a-evolução-da-gestão-de-chaves-no-bitcoin&quot;&gt;A evolução da gestão de chaves no Bitcoin&lt;/h3&gt;

&lt;h4 id=&quot;1-a-base-criptográfica&quot;&gt;1. A base criptográfica&lt;/h4&gt;

&lt;p&gt;O Bitcoin utiliza criptografia de curvas elípticas baseada na curva &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secp256k1&lt;/code&gt; para gerar chaves públicas e privadas.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Chave privada:&lt;/strong&gt; Um número secreto representado por 32 bytes. Permite assinar transações que movimentam os fundos associados.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Chave pública:&lt;/strong&gt; Um ponto na curva elíptica, representado pelas coordenadas ((x, y)).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Endereço Bitcoin:&lt;/strong&gt; Um identificador codificado, derivado através de um processo específico que utiliza dados da chave pública, dependendo do tipo de endereço.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A chave pública é calculada a partir da chave privada através da multiplicação de pontos na curva elíptica:&lt;/p&gt;

&lt;p&gt;[
P = kG
]&lt;/p&gt;

&lt;p&gt;Em que:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;(k) é a chave privada.&lt;/li&gt;
  &lt;li&gt;(G) é o ponto gerador da curva.&lt;/li&gt;
  &lt;li&gt;(P) é a chave pública correspondente.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Calcular (P) a partir de (k) é computacionalmente viável. Recuperar (k) a partir de (P), por outro lado, é considerado computacionalmente inviável com os métodos clássicos atuais, quando são utilizados parâmetros seguros. Este problema é conhecido como o problema do logaritmo discreto em curvas elípticas.&lt;/p&gt;

&lt;h4 id=&quot;2-o-problema-original-reutilização-de-endereços-e-cópias-de-segurança-infinitas&quot;&gt;2. O problema original: reutilização de endereços e cópias de segurança infinitas&lt;/h4&gt;

&lt;p&gt;Os utilizadores de Bitcoin são incentivados a evitar a reutilização de endereços para melhorar a privacidade financeira.&lt;/p&gt;

&lt;p&gt;Antes da popularização das carteiras determinísticas hierárquicas, os programas de carteira podiam gerar chaves privadas aleatórias e independentes para novos endereços. A gestão dessas chaves apresentava vários desafios:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Complexidade das cópias de segurança:&lt;/strong&gt; Era necessário garantir que as novas chaves fossem incluídas nas cópias de segurança. Uma cópia que não contivesse uma chave necessária poderia provocar a perda definitiva do acesso aos fundos.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Limitações operacionais:&lt;/strong&gt; Empresas e sistemas de pagamento precisavam de uma forma de gerar novos endereços de recebimento sem expor as chaves privadas aos servidores online.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Dificuldades de recuperação:&lt;/strong&gt; A gestão de uma coleção crescente de chaves independentes tornava a recuperação da carteira mais complicada.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A BIP32 resolveu estes problemas ao introduzir um padrão para derivar chaves relacionadas de forma hierárquica.&lt;/p&gt;

&lt;h3 id=&quot;a-solução-bip32-carteiras-determinísticas-hierárquicas&quot;&gt;A solução BIP32: carteiras determinísticas hierárquicas&lt;/h3&gt;

&lt;p&gt;A BIP32 introduziu um sistema em que uma chave mestre e um código de cadeia (&lt;em&gt;chain code&lt;/em&gt;) permitem derivar uma hierarquia de chaves filhas.&lt;/p&gt;

&lt;p&gt;Em vez de gerar e guardar uma cópia de segurança independente para cada chave privada, uma carteira pode derivar muitas chaves relacionadas a partir de uma única semente mestre.&lt;/p&gt;

&lt;p&gt;Esta estrutura pode ser representada como uma árvore:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Chave mestre:&lt;/strong&gt; A raiz da hierarquia.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Chaves filhas:&lt;/strong&gt; Chaves derivadas de uma chave principal.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Chaves netas:&lt;/strong&gt; Chaves derivadas das chaves filhas.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Ramos:&lt;/strong&gt; Caminhos separados para diferentes contas, endereços ou finalidades.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;O processo de derivação é determinístico: utilizando a mesma semente mestre e o mesmo caminho de derivação, uma carteira consegue reproduzir as mesmas chaves.&lt;/p&gt;

&lt;h3 id=&quot;a-matemática-por-trás-da-derivação-de-chaves-públicas&quot;&gt;A matemática por trás da derivação de chaves públicas&lt;/h3&gt;

&lt;p&gt;A propriedade matemática central resulta das operações de grupo das curvas elípticas.&lt;/p&gt;

&lt;p&gt;Uma chave pública é calculada através da expressão:&lt;/p&gt;

&lt;p&gt;[
P = kG
]&lt;/p&gt;

&lt;p&gt;Suponhamos que uma nova chave privada é calculada adicionando um escalar (t) à chave privada original:&lt;/p&gt;

&lt;p&gt;[
k’ = (k+t)\bmod n
]&lt;/p&gt;

&lt;p&gt;A chave pública correspondente é:&lt;/p&gt;

&lt;p&gt;[
P’ = k’G
]&lt;/p&gt;

&lt;p&gt;Substituindo a expressão da chave privada:&lt;/p&gt;

&lt;p&gt;[
P’ = (k+t)G
]&lt;/p&gt;

&lt;p&gt;Aplicando as propriedades das operações de grupo das curvas elípticas:&lt;/p&gt;

&lt;p&gt;[
P’ = kG+tG
]&lt;/p&gt;

&lt;p&gt;Como (P=kG), obtemos:&lt;/p&gt;

&lt;p&gt;[
\boxed{P’=P+tG}
]&lt;/p&gt;

&lt;p&gt;Isto significa que a nova chave pública pode ser calculada utilizando a chave pública original e os dados correspondentes da derivação, sem revelar a chave privada original.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uma distinção importante:&lt;/strong&gt; a BIP32 não consiste simplesmente em multiplicar uma chave privada por um fator arbitrário. Utiliza uma função criptográfica baseada em HMAC-SHA512, juntamente com operações de curvas elípticas e um código de cadeia.&lt;/p&gt;

&lt;p&gt;Para uma chave filha não endurecida (&lt;em&gt;non-hardened&lt;/em&gt;), a relação matemática simplificada é:&lt;/p&gt;

&lt;p&gt;[
k_i=(\operatorname{parse}&lt;em&gt;{256}(I_L)+k&lt;/em&gt;{\text{par}})\bmod n
]&lt;/p&gt;

&lt;p&gt;A chave pública correspondente é:&lt;/p&gt;

&lt;p&gt;[
K_i=\operatorname{parse}&lt;em&gt;{256}(I_L)G+K&lt;/em&gt;{\text{par}}
]&lt;/p&gt;

&lt;p&gt;Neste contexto:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;(I_L) é derivado da saída de HMAC-SHA512.&lt;/li&gt;
  &lt;li&gt;(k_{\text{par}}) é a chave privada da chave principal.&lt;/li&gt;
  &lt;li&gt;(K_{\text{par}}) é a chave pública da chave principal.&lt;/li&gt;
  &lt;li&gt;(n) é a ordem do ponto gerador.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;O código de cadeia e o índice de derivação determinam os dados utilizados no processo. É isto que torna a derivação BIP32 estruturada e reproduzível, em vez de uma simples multiplicação arbitrária.&lt;/p&gt;

&lt;h3 id=&quot;demonstração-prática-em-python&quot;&gt;Demonstração prática em Python&lt;/h3&gt;

&lt;p&gt;Uma demonstração matemática pode ajudar a compreender a relação entre chaves privadas e públicas.&lt;/p&gt;

&lt;p&gt;Utilizando uma biblioteca apropriada para &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secp256k1&lt;/code&gt;, a experiência pode seguir estes passos:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Gerar uma chave privada inicial (k).&lt;/li&gt;
  &lt;li&gt;Calcular a respetiva chave pública (P=kG).&lt;/li&gt;
  &lt;li&gt;Escolher um escalar válido (t).&lt;/li&gt;
  &lt;li&gt;Calcular uma nova chave privada (k’=(k+t)\bmod n).&lt;/li&gt;
  &lt;li&gt;Calcular a nova chave pública diretamente a partir de (k’).&lt;/li&gt;
  &lt;li&gt;Calcular, de forma independente, (P’=P+tG).&lt;/li&gt;
  &lt;li&gt;Comparar as duas chaves públicas obtidas.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As duas chaves públicas devem coincidir, desde que os valores sejam válidos e as operações estejam corretamente implementadas.&lt;/p&gt;

&lt;p&gt;Esta experiência demonstra a propriedade matemática que permite a derivação pública não endurecida. Contudo, não constitui, por si só, uma implementação completa da BIP32, porque a derivação real também exige HMAC-SHA512, códigos de cadeia, serialização e índices de derivação.&lt;/p&gt;

&lt;p&gt;Para carteiras Bitcoin reais, utiliza implementações estabelecidas em vez de código experimental para gerar ou gerir chaves privadas.&lt;/p&gt;

&lt;h3 id=&quot;chaves-estendidas-xprv-e-xpub&quot;&gt;Chaves estendidas: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt; e &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;A BIP32 define chaves estendidas serializadas que combinam material criptográfico com um código de cadeia e metadados necessários à derivação.&lt;/p&gt;

&lt;h4 id=&quot;xprv--chave-privada-estendida&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt; — Chave privada estendida&lt;/h4&gt;

&lt;p&gt;Uma chave privada estendida contém uma chave privada e o respetivo código de cadeia, juntamente com metadados de derivação.&lt;/p&gt;

&lt;p&gt;Permite derivar chaves privadas e públicas descendentes, respeitando as regras de derivação.&lt;/p&gt;

&lt;p&gt;Quem obtiver uma chave privada estendida pode, em geral, derivar as chaves privadas da subárvore correspondente e movimentar os fundos associados.&lt;/p&gt;

&lt;h4 id=&quot;xpub--chave-pública-estendida&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; — Chave pública estendida&lt;/h4&gt;

&lt;p&gt;Uma chave pública estendida contém uma chave pública e o respetivo código de cadeia, além dos metadados de derivação.&lt;/p&gt;

&lt;p&gt;Permite derivar chaves públicas descendentes não endurecidas sem acesso às chaves privadas. Esta funcionalidade é útil para carteiras de consulta (&lt;em&gt;watch-only&lt;/em&gt;), sistemas de pagamento e servidores online que precisam de gerar endereços de recebimento sem poder assinar transações.&lt;/p&gt;

&lt;p&gt;No entanto, uma &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; não deve ser considerada informação pública inofensiva.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Aviso de privacidade e segurança:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Partilhar uma &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; pode expor uma parte significativa da estrutura de endereços e da atividade financeira de uma carteira.&lt;/li&gt;
  &lt;li&gt;Uma &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt;, por si só, normalmente não permite movimentar fundos.&lt;/li&gt;
  &lt;li&gt;Combinar uma chave pública estendida principal com a chave privada de uma filha não endurecida correspondente pode permitir recuperar a chave privada principal, nas condições de derivação aplicáveis da BIP32.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Por estes motivos, as chaves públicas estendidas devem ser partilhadas apenas quando necessário e com plena compreensão das implicações para a privacidade.&lt;/p&gt;

&lt;h3 id=&quot;bip32-e-bip39-qual-é-a-diferença&quot;&gt;BIP32 e BIP39: qual é a diferença?&lt;/h3&gt;

&lt;p&gt;A BIP32 e a BIP39 resolvem problemas relacionados, mas diferentes.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;BIP32&lt;/strong&gt; define a derivação hierárquica determinística de chaves: como uma chave mestre pode produzir uma árvore estruturada de chaves filhas.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;BIP39&lt;/strong&gt; define um sistema mnemónico que converte entropia gerada por computador numa sequência de palavras e utiliza essa sequência, juntamente com uma eventual frase-passe, para derivar uma semente.&lt;/p&gt;

&lt;p&gt;A relação entre ambas pode ser resumida da seguinte forma:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;A entropia é gerada de forma segura.&lt;/li&gt;
  &lt;li&gt;A BIP39 converte essa entropia numa frase mnemónica.&lt;/li&gt;
  &lt;li&gt;A frase mnemónica e a eventual frase-passe são processadas para produzir uma semente.&lt;/li&gt;
  &lt;li&gt;A BIP32 utiliza a semente para gerar a chave mestre e o código de cadeia.&lt;/li&gt;
  &lt;li&gt;As chaves filhas são derivadas de acordo com os caminhos especificados.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Uma frase de recuperação não é simplesmente uma versão legível de uma &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt;. É uma entrada utilizada para reconstruir a semente a partir da qual a hierarquia de chaves da carteira pode ser derivada.&lt;/p&gt;

&lt;h3 id=&quot;conclusão&quot;&gt;Conclusão&lt;/h3&gt;

&lt;p&gt;A BIP32 é um padrão fundamental para as carteiras determinísticas modernas de Bitcoin. Ao combinar derivação criptográfica com as propriedades matemáticas das curvas elípticas, torna a gestão de chaves mais escalável e permite separar a geração de endereços públicos da assinatura privada de transações.&lt;/p&gt;

&lt;p&gt;Compreender a relação entre chaves privadas, chaves públicas, códigos de cadeia, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xprv&lt;/code&gt; e &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xpub&lt;/code&gt; é essencial para quem estuda desenvolvimento Bitcoin, arquitetura de carteiras ou segurança criptográfica.&lt;/p&gt;

&lt;p&gt;A principal lição é que &lt;strong&gt;a BIP32 não é apenas um truque de multiplicação de chaves&lt;/strong&gt;. É um sistema de derivação cuidadosamente especificado que permite recuperar carteiras determinísticas e derivar chaves públicas não endurecidas, preservando o segredo das chaves privadas sob as condições de segurança previstas.&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">A Magia da Multiplicação de Chaves: Entendendo a BIP32 no Bitcoin</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="en"><title type="html">Advanced Transfers and Security in Bitcoin</title><link href="https://bitdevsmaputo.org/en/blog/advanced-transfers" rel="alternate" type="text/html" title="Advanced Transfers and Security in Bitcoin" /><published>2026-10-14T00:00:00+00:00</published><updated>2026-10-14T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/en/blog/advanced-transfers</id><content type="html" xml:base="https://bitdevsmaputo.org/en/blog/advanced-transfers">&lt;h2 id=&quot;advanced-transfers-and-security&quot;&gt;Advanced Transfers and Security&lt;/h2&gt;

&lt;p&gt;In the three previous articles of the &lt;strong&gt;Bitcoin Transfers&lt;/strong&gt; series, we explored everything from the basic anatomy of a transaction to more efficient sending strategies, always with a practical emphasis on using Bitcoin Core on test networks. Now we move forward: beyond moving bitcoin correctly and cheaply, it is time to think about &lt;strong&gt;how to strengthen the security of every transfer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This step is essential because, in the Bitcoin ecosystem, protection does not depend only on safeguarding the private key. The concept of defense in depth shows that real security emerges when we build several barriers: from key generation to the very way we structure transactions. Features such as &lt;strong&gt;multisig&lt;/strong&gt; and &lt;strong&gt;timelocks&lt;/strong&gt; allow us to create operations that resist loss, theft, or unauthorized access, offering resilience even in failure scenarios.&lt;/p&gt;

&lt;p&gt;In this article, we will see how to apply each of these techniques, combining theory and practice so that your transfers not only happen, but are more robust and versatile. First, let’s understand &lt;strong&gt;PSBTs (Partially Signed Bitcoin Transactions)&lt;/strong&gt;, which are fundamental for using these advanced features.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;psbt--partially-signed-transactions&quot;&gt;PSBT – Partially Signed Transactions&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;PSBT&lt;/strong&gt; is a standard defined in &lt;a href=&quot;https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki&quot;&gt;BIP174&lt;/a&gt; that allows transactions to be created, shared, and signed collaboratively.&lt;/p&gt;

&lt;p&gt;It clearly separates the stages:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Raw transaction creation:&lt;/strong&gt; whoever selects the UTXOs and defines the destinations.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Signing:&lt;/strong&gt; each participant signs only their part, on their own device.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Finalization/Broadcast:&lt;/strong&gt; final assembly and submission to the network.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This ensures that &lt;strong&gt;no single device needs all the keys&lt;/strong&gt; or full internet access, which is essential for &lt;strong&gt;multisig&lt;/strong&gt;, &lt;strong&gt;hardware wallets&lt;/strong&gt;, or &lt;strong&gt;air-gapped setups&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic commands in Bitcoin Core:&lt;/strong&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Step&lt;/th&gt;
      &lt;th&gt;Command&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Create a PSBT with defined inputs/outputs&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletcreatefundedpsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Sign partially&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletprocesspsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Combine several PSBTs (multiple signers)&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;combinepsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Finalize (produces broadcastable hex)&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Send&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendrawtransaction&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;A PSBT is useful even with a single signer&lt;/strong&gt; when you separate environments: create the transaction on one machine and sign it on another (secure/offline).&lt;/p&gt;

&lt;p&gt;Let’s go through an example in Bitcoin Core.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;0) Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You already have a wallet with a balance on signet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1) Create the PSBT (selects UTXOs and defines outputs)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; walletcreatefundedpsbt &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;[]&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;tb1q2tygw0rd24cgrrj9dajqrh398clxucnhdwlxew&quot;:0.0001}]&apos;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  0 &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;subtractFeeFromOutputs&quot;:[0]}&apos;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAHECAAAAAXT7uaRFVyzfv8vbDqsOc4AWZzxAoX0S...(shortened, same as the original)...AAAAA=&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00001410,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2) Sign partially (in the same wallet)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAHECAAAAAXT7uaRFVyzfv8vbDqsOc4AWZzxAoX0S...(shortened)...&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAHECAAAAAXT7uaRFVyzfv8vbDqsOc4AWZzxAoX0S...(shortened)...&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000000010174fbb9a445572cdfbfcbdb0eab0e738016673c...(shortened)...00000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletprocesspsbt&lt;/code&gt; adds the signatures that the wallet is able to produce. In a regular (non-multisig) wallet, this leaves &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete=true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Explaining the fields the command returns:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;psbt&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;This is the &lt;strong&gt;partially signed transaction&lt;/strong&gt; (still in &lt;em&gt;PSBT format&lt;/em&gt;, base64).&lt;/li&gt;
  &lt;li&gt;It is useful if you were going to &lt;strong&gt;pass it to another signer&lt;/strong&gt; or wanted to store the file.&lt;/li&gt;
  &lt;li&gt;If &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; were &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt;, this would be the value to send to the next participant or to use in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; means that &lt;em&gt;all&lt;/em&gt; required signatures have already been added.&lt;/li&gt;
  &lt;li&gt;If it were &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt;, you would keep circulating the PSBT among the parties or run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;combinepsbt&lt;/code&gt;, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hex&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;This is the &lt;strong&gt;final Bitcoin transaction&lt;/strong&gt;, already serialized (raw hex) and ready for the network.&lt;/li&gt;
  &lt;li&gt;When &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt;, Core already hands you this hex, which can be broadcast right away.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3) Finalize and broadcast&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Since &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete = true&lt;/code&gt;&lt;/strong&gt;, there is no need to call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;. Just take the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hex&lt;/code&gt; value and broadcast it:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000000010174fbb9a445572cdfbfcbdb0eab0e738016673c...(shortened)...00000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# a1a93c02cfb449040677950d1abf33f57c923273d5f091c942c08d229e638ce4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;If &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; = false&lt;/strong&gt;, we would use the returned &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;psbt&quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; finalizepsbt &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;SIGNED_PSBT&amp;gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command would produce the final hex to be broadcast.&lt;/p&gt;

&lt;h3 id=&quot;multisig&quot;&gt;Multisig&lt;/h3&gt;

&lt;p&gt;Multisig is a custody scheme in Bitcoin in which a spend is only valid when a predefined minimum number of keys, among several participants, sign the transaction, such as “2-of-3” or “3-of-5”, increasing security and allowing shared control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Resistance to theft/loss:&lt;/strong&gt; 1 compromised key cannot spend the funds (in 2-of-3); losing 1 key still allows recovery.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Inheritance/backup:&lt;/strong&gt; keys distributed among different people/vaults.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Governance:&lt;/strong&gt; approval policies (m-of-n) for companies/DAOs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s look at a practical example in Bitcoin Core:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) Create three wallets (participants)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira1 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true
&lt;/span&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira2 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true
&lt;/span&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira3 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We create wallets &lt;strong&gt;with private keys&lt;/strong&gt; and &lt;strong&gt;with descriptors&lt;/strong&gt;. Avoid &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blank=true&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;disable_private_keys=true&lt;/code&gt; so you don’t end up with “empty” wallets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) Get the xpubs (with fingerprint/derivation)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For each wallet, list the public descriptors and copy the &lt;strong&gt;receiving (…/0/*)&lt;/strong&gt; and &lt;strong&gt;change (…/1/*)&lt;/strong&gt; lines:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira1 listdescriptors
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;wallet_name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira1&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;descriptors&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    ...,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/0/*)#jr2a4z9x&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650612,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/1/*)#rh0ugh47&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650613,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira2 listdescriptors
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 ...,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/0/*)#k32vf2uu&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650639,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/1/*)#890d5lvy&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650640,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira3 listdescriptors
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;wallet_name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira3&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;descriptors&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    ...,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/0/*)#5szljz27&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650645,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/1/*)#9y870h6x&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650645,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What to copy:&lt;/strong&gt; the public descriptors for receiving (…/0/*) and change (…/1/*). They carry the fingerprint + path (e.g., &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[ba39c771/84h/1h/0h]tpub.../0/*&lt;/code&gt;), which is essential for building the multisig correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Address standard:&lt;/strong&gt; the examples use the 84h/1h/0h derivation (Bech32, P2WPKH for singlesig). In multisig, we will combine them into P2WSH (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wsh(sortedmulti(...))&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) Create the multisig wallet (watch-only) and import the multisig descriptors (receiving and change)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why “watch-only”?&lt;/strong&gt; This wallet &lt;strong&gt;sees&lt;/strong&gt; UTXOs, &lt;strong&gt;generates addresses&lt;/strong&gt;, and &lt;strong&gt;creates PSBTs&lt;/strong&gt;, but it has &lt;strong&gt;no&lt;/strong&gt; private keys; the signatures happen in the participant wallets (carteira1, 2, and 3).&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet multisig-2of3 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;multisig-2of3&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;warnings&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;Empty string given as passphrase, wallet will not be encrypted.&quot;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;multisig-2of3 importdescriptors &lt;span class=&quot;o&quot;&gt;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;desc&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;:&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;wsh&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sortedmulti&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;2,[ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/0/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;,[1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/0/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;,[fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/0/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;#ed8gy0hl\&quot;,\&quot;active\&quot;:true,\&quot;timestamp\&quot;:\&quot;now\&quot;},{\&quot;desc\&quot;:\&quot;wsh(sortedmulti(2,[ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/1/*,[1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/1/*,[fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/1/*))#tcmu8qku\&quot;,\&quot;active\&quot;:true,\&quot;internal\&quot;:true,\&quot;timestamp\&quot;:\&quot;now\&quot;}]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;warnings&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;Range not given, using default keypool range&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;warnings&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;Range not given, using default keypool range&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sortedmulti&lt;/code&gt;&lt;/strong&gt;: guarantees a deterministic ordering of the keys (regardless of input order), avoiding different addresses for the same set of keys.
The &lt;strong&gt;“Range not given”&lt;/strong&gt; warning only tells you that Core will use the &lt;strong&gt;default range 0–999&lt;/strong&gt; to generate addresses. For most cases, that is fine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4) Receive funds into the multisig&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generate a new address for this new multisig wallet:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;multisig-2of3 getnewaddress
&lt;span class=&quot;c&quot;&gt;# tb1qrlwt49k9hqgj7m3rlc4elfj3fxe96l93zz9ez5209z8uskrqg7yqhl3v88&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Send some sats to the generated address (via a signet faucet). Wait for 1+ confirmations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5) Create the spending PSBT (in the multisig wallet)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;multisig-2of3 walletcreatefundedpsbt &lt;span class=&quot;s2&quot;&gt;&quot;[]&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tb1qqu7d6zmh5mpf07xd7t9aehe0re63hfqk2wh2ew6045zc5svshphq7j4eek&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0.00001}]&quot;&lt;/span&gt; 0 &lt;span class=&quot;s2&quot;&gt;&quot;{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;subtractFeeFromOutputs&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:[0]}&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZ...(shortened, same as the original)...AAAAAA==&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000201,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 0
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletcreatefundedpsbt&lt;/code&gt; &lt;strong&gt;selects UTXOs&lt;/strong&gt;, builds the transaction, &lt;strong&gt;calculates the fee&lt;/strong&gt;, and returns a &lt;strong&gt;PSBT&lt;/strong&gt; with the metadata needed for signing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractFeeFromOutputs&lt;/code&gt;&lt;/strong&gt;: if set to output index 0, the fee is “deducted” from that output (useful for sending “whatever is left” without adjusting manually).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6) Sign in two wallets (Carteira1 and Carteira2, separately)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira1 walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZ...(shortened, the original PSBT from step 5)...&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZ...(shortened, PSBT with carteira1&apos;s signature)...&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira2 walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZ...(shortened, the original PSBT from step 5)...&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZ...(shortened, PSBT with carteira2&apos;s signature)...&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Each participant &lt;strong&gt;signs&lt;/strong&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletprocesspsbt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sequential vs. parallel:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;Sequential:&lt;/em&gt; the output of carteira1 (a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;psbt&lt;/code&gt; already holding 1 signature) goes into carteira2 → it usually comes back with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete: true&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Parallel (the one we used in this example):&lt;/em&gt; each signer signs the &lt;strong&gt;same original PSBT&lt;/strong&gt;, and then you &lt;strong&gt;combine&lt;/strong&gt; them (next step).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7) Combine the 2 signed PSBTs&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; combinepsbt &lt;span class=&quot;s2&quot;&gt;&quot;[&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;lt;PSBT_SIGNED_BY_CARTEIRA1&amp;gt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;lt;PSBT_SIGNED_BY_CARTEIRA2&amp;gt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;]&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZ...(shortened, combined PSBT)...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt; if the signers signed &lt;strong&gt;in parallel&lt;/strong&gt; (each took the original PSBT).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; the combined PSBT should already contain the &lt;strong&gt;2 required signatures&lt;/strong&gt; (2-of-3).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8) Finalize and broadcast&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; finalizepsbt &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;COMBINED_PSBT&amp;gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b00b0c0982cda2e99862ccdc7a2c5ceba8769d37067cd9...(shortened)...53ae00000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;&lt;/strong&gt;: validates the script, assembles the witness, and returns the &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hex&lt;/code&gt;&lt;/strong&gt; ready for broadcast.&lt;/p&gt;

&lt;p&gt;Finally, the &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendrawtransaction&lt;/code&gt;&lt;/strong&gt; command publishes the transaction to the network.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b00b0c0982cda2e99862ccdc7a2c5ceba8769d37067cd9...(shortened)...53ae00000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# af5f0813b622d6a21389af6cecbe9d5098d71cdee814e7ba70fcbe0a7d1ce407&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice, in the mempool, that this is a 2-of-3 multisig transaction:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;../assets/artigo10-img1.webp&quot; alt=&quot;mempool1.png&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;timelocks&quot;&gt;Timelocks&lt;/h2&gt;

&lt;p&gt;In Bitcoin, &lt;strong&gt;timelock&lt;/strong&gt; is the generic name for mechanisms that determine &lt;strong&gt;when&lt;/strong&gt; a transaction or a given UTXO can be spent. Instead of merely requiring a valid signature, the protocol also checks &lt;strong&gt;time or block height&lt;/strong&gt;, creating “mandatory waiting” conditions.&lt;/p&gt;

&lt;p&gt;There are two main forms.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;nLockTime:&lt;/strong&gt; a field inside the &lt;strong&gt;transaction&lt;/strong&gt; itself that defines the &lt;strong&gt;minimum block&lt;/strong&gt; (or a timestamp) from which the network accepts including it in a block. It is simple and useful for “scheduling” payments, but whoever holds the keys can discard that transaction and create another one without the lock.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;CheckLockTimeVerify (CLTV):&lt;/strong&gt; a &lt;strong&gt;script operation&lt;/strong&gt; that writes the restriction directly into the &lt;strong&gt;UTXO&lt;/strong&gt;. In this case, the money “inherits” the lock: no spending is possible before the defined height/time, even if all the key holders want to change it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also the &lt;strong&gt;CheckSequenceVerify (CSV)&lt;/strong&gt; variant, which works similarly but is based on a relative interval of confirmations (e.g., “can be spent 144 blocks after this UTXO is confirmed”).&lt;/p&gt;

&lt;p&gt;These features make it possible to create contracts such as vaults with a recovery period, inheritances with future unlocking, or scheduled payments that only become valid after a certain date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a) nLockTime in practice&lt;/strong&gt;
&lt;strong&gt;Goal:&lt;/strong&gt; create a transaction that &lt;strong&gt;can only be mined&lt;/strong&gt; after a target block.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Choose the target block&lt;/strong&gt; (e.g., current height + 2):&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
&lt;span class=&quot;c&quot;&gt;# 271141&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getblockcount&lt;/code&gt; command returns the current blockchain height. We can choose, for example, that the transaction can only be included from block &lt;strong&gt;271145&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Create the transaction:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;demo-signet&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;[]&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tb1q4asvsg6hhv6vwxzq5uy05wf6zzusp8me5xmlzv&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0.0001}&quot;&lt;/span&gt; 271145
0200000000011027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7929230400
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Fund the transaction:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;demo-signet fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000000011027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7929230400&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000001e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c29230400&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000141,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Sign the transaction:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;demo-signet&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000001e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c29230400&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c0247304402205e358ba9097c1f7efe67093fae52c4664cf17648f75185ae47a95a875db8fccb0220691d79b3eb4dc54b3c095e167340f084057b1f803f0375460ecfdc4c4af2dfa1012102ce170948697b4e2d96f3c85be5841c99a5deb2318855f9f041f23db9af7f62e829230400&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Send the transaction:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Notice that if we try to broadcast the transaction before the defined block height, we get an error:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271143

bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c0247304402205e358ba9097c1f7efe67093fae52c4664cf17648f75185ae47a95a875db8fccb0220691d79b3eb4dc54b3c095e167340f084057b1f803f0375460ecfdc4c4af2dfa1012102ce170948697b4e2d96f3c85be5841c99a5deb2318855f9f041f23db9af7f62e829230400&quot;&lt;/span&gt;
error code: &lt;span class=&quot;nt&quot;&gt;-26&lt;/span&gt;
error message:
non-final
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In Bitcoin, the &lt;strong&gt;nLockTime&lt;/strong&gt; field works only as a &lt;strong&gt;block validity rule&lt;/strong&gt;, not as an automatic scheduler. It defines the lowest block height (or timestamp) at which the transaction &lt;strong&gt;can be included&lt;/strong&gt; in the blockchain, but the network does not “hold” it until then. If you try to broadcast it before the limit is reached, nodes reject it with the &lt;em&gt;non-final&lt;/em&gt; error and nothing stays pending. That is why the software or script that creates the transaction must track the current height (for example, via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getblockcount&lt;/code&gt;) and only &lt;strong&gt;broadcast&lt;/strong&gt; when &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;current_height&lt;/code&gt; is greater than or equal to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nLockTime&lt;/code&gt; value. This differs from a script timelock (such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OP_CHECKLOCKTIMEVERIFY&lt;/code&gt;), which writes the restriction into the &lt;strong&gt;output&lt;/strong&gt; and lets you send the funding transaction today, guaranteeing it can only be spent after the deadline, without depending on external monitoring.
When we send it after the target, it works:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271145

bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c0247304402205e358ba9097c1f7efe67093fae52c4664cf17648f75185ae47a95a875db8fccb0220691d79b3eb4dc54b3c095e167340f084057b1f803f0375460ecfdc4c4af2dfa1012102ce170948697b4e2d96f3c85be5841c99a5deb2318855f9f041f23db9af7f62e829230400&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 2c91cbd4e8bccacb42020eb88a1df0816d99fae7e2ee12ff6a8c996ca282374b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b) CLTV with Miniscript (a “strong” timelock on the UTXO)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; create a &lt;strong&gt;P2WSH address&lt;/strong&gt; whose script requires a &lt;strong&gt;minimum block height&lt;/strong&gt; to spend.&lt;/p&gt;

&lt;p&gt;Let’s go step by step.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Create a new wallet&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will create a new wallet so as not to mix it with other examples.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira_cltv
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Create a new address and get its information&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With the new wallet, we can generate a new address.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# tb1q84ysz0zng7m8yad6zrps3uyn6reu977v85x0ga&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, we can get the information for this new address (we will use it below):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; getaddressinfo tb1q84ysz0zng7m8yad6zrps3uyn6reu977v85x0ga
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;tb1q84ysz0zng7m8yad6zrps3uyn6reu977v85x0ga&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00143d49013c5347b67275ba10c308f093d0f3c2fbcc&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;ismine&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([261430f9/84h/1h/0h/0/0]03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79)#l4tsyqsx&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;parent_desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([261430f9/84h/1h/0h]tpubDDEKB1hKK8aCiLLPE35AqyEnRSbRTWgo27VVfG1iF8mdsJnYvuss736NutifM2NWnH78AVjW4hvHaDg3CzW7ZAHXVBMgPvoiYuYrZ5RgJii/0/*)#2hke87n4&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;iswatchonly&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;isscript&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;iswitness&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;witness_version&quot;&lt;/span&gt;: 0,
  &lt;span class=&quot;s2&quot;&gt;&quot;witness_program&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;3d49013c5347b67275ba10c308f093d0f3c2fbcc&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;pubkey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;ischange&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758845787,
  &lt;span class=&quot;s2&quot;&gt;&quot;hdkeypath&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;m/84h/1h/0h/0/0&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hdseedid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0000000000000000000000000000000000000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hdmasterfingerprint&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;261430f9&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;labels&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;From the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pubkey&lt;/code&gt;, we can build a new, specific descriptor that produces addresses with a block-height restriction (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;after(271220)&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; getdescriptorinfo &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;descriptor&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;checksum&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;gk4hzcry&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;isrange&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;issolvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hasprivatekeys&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command returns a descriptor already with its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CHECKSUM&lt;/code&gt; (in the example, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#gk4hzcry&lt;/code&gt;).&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Derive a new address from the descriptor&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With the descriptor above, we can derive addresses that already carry the block-height restriction in their script.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; deriveaddresses &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Any UTXO associated with the address &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&lt;/code&gt; can only be spent from block &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;271220&lt;/code&gt; onward.&lt;/p&gt;

&lt;p&gt;We can check the current block:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271211
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Send funds to the timelock address&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can send some funds to this newly created address so that we can then test whether we are able to make transactions before the defined block height. We can use a faucet or send BTC from another wallet, as in the example below:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;demo-signet&quot;&lt;/span&gt; sendtoaddress &lt;span class=&quot;s2&quot;&gt;&quot;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&quot;&lt;/span&gt; 0.0001
&lt;span class=&quot;c&quot;&gt;# 8cc8b2a47bff4a4b146f16ca2656bfb341bb95040ace91b4d6698e3c34d00c3a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In fact, that is all there is to using a script timelock (CLTV); it is already in place. The next steps only serve to demonstrate that we will need to wait until the specific block height to be able to spend this UTXO.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Create a watch-only wallet&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember that, when Bitcoin Core creates a wallet, it creates it with those 8 default descriptors. In the previous steps, we generated a new address for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;carteira_cltv&lt;/code&gt; wallet from a new descriptor. However, by default Core does not automatically associate all UTXOs of this new descriptor with the wallet. Therefore, if we run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listunspent&lt;/code&gt; on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;carteira_cltv&lt;/code&gt; wallet, it will not show the UTXO from the transaction above (the one that funded the address). To fix this, we will create a new watch-only wallet:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira_cltv_wo &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv_wo&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And right after, we will use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;importdescriptors&lt;/code&gt; command so that this new wallet sees the UTXOs associated with the addresses generated by the new descriptor:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo importdescriptors &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;timestamp&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;cltv-271220&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;}]&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command may take a few minutes, since it scans all existing UTXOs.&lt;/p&gt;

&lt;p&gt;Once the transaction that sent funds to this address is confirmed, we will be able to see the UTXO:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;8cc8b2a47bff4a4b146f16ca2656bfb341bb95040ace91b4d6698e3c34d00c3a&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cltv-271220&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;witnessScript&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;2103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b1&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;002092d6f062c222e0e4293d550de1f35c9cf9fbad6d7c8c750bd249f216168eb01c&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.00010000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk([3d49013c]03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#dz9nuz04&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Create a transaction and try to send it&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let’s create a PSBT transaction to try to spend the locked UTXO.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo createpsbt &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;txid&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;8cc8b2a47bff4a4b146f16ca2656bfb341bb95040ace91b4d6698e3c34d00c3a&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vout&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:1,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;sequence&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:4294967293}]&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tb1q3hhxstxlemumvsw2v8cgxwf860f6hxyk7p0d6v&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0.00009800}]&quot;&lt;/span&gt; 271220
cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAAA
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To be able to spend, I need to build a transaction in the expected format, so that the unlocking script is correct. Thus, we need to create the PSBT with the transaction’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TXID&lt;/code&gt; (with its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout&lt;/code&gt;), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sequence&lt;/code&gt;, the destination address, the amount, and the unlock block height.&lt;/p&gt;

&lt;p&gt;Each input of a transaction has a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Sequence&lt;/code&gt; field.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If it stays at the maximum value (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0xffffffff&lt;/code&gt;), the transaction’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nLockTime&lt;/code&gt; is &lt;strong&gt;ignored&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;If you use a smaller value (e.g., &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0xfffffffd&lt;/code&gt;), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nLockTime&lt;/code&gt; takes effect.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our case, the real &lt;em&gt;timelock&lt;/em&gt; is in the &lt;strong&gt;UTXO’s script&lt;/strong&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OP_CHECKLOCKTIMEVERIFY&lt;/code&gt; generated by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;after(...)&lt;/code&gt;). &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nSequence&lt;/code&gt; only ensures that the transaction &lt;strong&gt;respects&lt;/strong&gt; this timelock; it cannot “unlock” the UTXO early. Even if someone tries to change &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nSequence&lt;/code&gt; to get around it, the network will keep requiring that the minimum block height be reached before spending.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAAA&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiM...(shortened)...&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We complete/sign the PSBT transaction with the watch-only wallet. And then with the original wallet (which has the private keys):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiM...(shortened)...&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiM...(shortened)...&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We finalize the PSBT:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; finalizepsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiM...(shortened)...&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And we send it:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;
error code: &lt;span class=&quot;nt&quot;&gt;-26&lt;/span&gt;
error message:
non-final
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that it errors out. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;non-final&lt;/code&gt; message indicates that this transaction cannot yet be accepted into the mempool.&lt;/p&gt;

&lt;p&gt;We wait for the block height to pass &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;271220&lt;/code&gt; and send it again:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271227

bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;
e2b64a372d5bab18658f5ce14bc27cd6c502c7026b8bc5853462c254638603b1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Throughout this article, we saw how to move beyond the basic “send and sign” to build &lt;strong&gt;well-structured and more secure&lt;/strong&gt; transactions in Bitcoin Core.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PSBT&lt;/strong&gt; separates responsibilities (create, sign, finalize), enabling collaborative workflows and offline environments; &lt;strong&gt;multisig (m-of-n)&lt;/strong&gt; adds resilience against key loss and compromise; and &lt;strong&gt;timelocks&lt;/strong&gt;, both &lt;strong&gt;nLockTime&lt;/strong&gt; (in the transaction) and &lt;strong&gt;CLTV/CSV&lt;/strong&gt; (in the script, via Miniscript), let you enforce &lt;strong&gt;when&lt;/strong&gt; a UTXO can be spent. Together, these features form complementary layers: key policy (multisig), time policy (timelocks), and a secure transport format (PSBT). The result is a sending process that is &lt;strong&gt;auditable, reproducible, and resistant to operational failures&lt;/strong&gt;, ready to evolve from the signet lab to professional day-to-day practice.&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">Advanced Transfers and Security</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="pt"><title type="html">Transferências Avançadas e Segurança no Bitcoin</title><link href="https://bitdevsmaputo.org/pt/blog/transferencias-avancadas" rel="alternate" type="text/html" title="Transferências Avançadas e Segurança no Bitcoin" /><published>2026-10-14T00:00:00+00:00</published><updated>2026-10-14T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/pt/blog/transferencias-avancadas</id><content type="html" xml:base="https://bitdevsmaputo.org/pt/blog/transferencias-avancadas">&lt;h2 id=&quot;transferências-avançadas-e-segurança&quot;&gt;Transferências Avançadas e Segurança&lt;/h2&gt;

&lt;p&gt;Nos três artigos anteriores da série &lt;strong&gt;Transferências no Bitcoin&lt;/strong&gt;, exploramos desde a anatomia básica de uma transação até estratégias mais eficientes de envio, sempre com ênfase prática no uso do Bitcoin Core em redes de teste. Agora, avançamos: além de movimentar bitcoins de forma correta e econômica, é hora de pensar em &lt;strong&gt;como fortalecer a segurança de cada transferência&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Esse passo é essencial porque, no ecossistema Bitcoin, a proteção não depende apenas de guardar bem a chave privada. O conceito de defesa em camadas mostra que a segurança verdadeira surge quando criamos várias barreiras: desde a geração das chaves até a própria forma como estruturamos as transações. Recursos como &lt;strong&gt;multisig&lt;/strong&gt; e &lt;strong&gt;timelocks&lt;/strong&gt; permitem criar operações que resistem a perdas, roubos ou acessos não autorizados, oferecendo resiliência mesmo em cenários de falha.&lt;/p&gt;

&lt;p&gt;Neste artigo, vamos ver como aplicar cada uma dessas técnicas, combinando teoria e prática para que suas transferências não apenas aconteçam, mas sejam mais robustas e versáteis. Antes, vamos entender as &lt;strong&gt;PSBT (Partially Signed Bitcoin Transaction)&lt;/strong&gt;, que são fundamentais para utilização desses recursos avançados.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;psbt--transações-parcialmente-assinadas&quot;&gt;PSBT – Transações Parcialmente Assinadas&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;PSBT&lt;/strong&gt; é um padrão definido na &lt;a href=&quot;https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki&quot;&gt;BIP174&lt;/a&gt; que permite criar, compartilhar e assinar transações de forma colaborativa.&lt;/p&gt;

&lt;p&gt;Ela separa nitidamente as etapas:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Criação da transação bruta:&lt;/strong&gt; quem seleciona UTXOs e define os destinos.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Assinatura:&lt;/strong&gt; cada participante assina apenas sua parte, em seu próprio dispositivo.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Finalização/Broadcast:&lt;/strong&gt; montagem final e envio à rede.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Isso garante que &lt;strong&gt;nenhum dispositivo precisa de todas as chaves&lt;/strong&gt; nem de acesso total à internet, o que é essencial para &lt;strong&gt;multisig&lt;/strong&gt;, &lt;strong&gt;hardware wallets&lt;/strong&gt; ou &lt;strong&gt;setups air-gapped&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comandos básicos no Bitcoin Core:&lt;/strong&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Etapa&lt;/th&gt;
      &lt;th&gt;Comando&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Criar PSBT com inputs/outputs definidos&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletcreatefundedpsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Assinar parcialmente&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletprocesspsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Combinar várias PSBTs (vários signatários)&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;combinepsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Finalizar (gera hex transmitível)&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Enviar&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendrawtransaction&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;PSBT é útil mesmo com 1 assinante&lt;/strong&gt; quando você separa ambientes: cria a transação em uma máquina e assina em outra (segura/offline).&lt;/p&gt;

&lt;p&gt;Vamos a um exemplo no Bitcoin Core.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;0) Pré-requisitos&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Você já tem uma carteira com saldo em signet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1) Criar a PSBT (seleciona UTXOs e define saídas)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; walletcreatefundedpsbt &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;[]&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;tb1q2tygw0rd24cgrrj9dajqrh398clxucnhdwlxew&quot;:0.0001}]&apos;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  0 &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;subtractFeeFromOutputs&quot;:[0]}&apos;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAHECAAAAAXT7uaRFVyzfv8vbDqsOc4AWZzxAoX0SgXzlK63dkuV+AAAAAAD9////Ao4hAAAAAAAAFgAUUsiHPG1VcIGORW9kAd4lPj5uYnf+WQEAAAAAABYAFO7wQWnkgYcWv54ru1f5kZA+PWOTAAAAAAABAHECAAAAAS0mLffRUqI69eSsvc7Kr1Gcvn0FbSfYGqHxIdrYytV9AAAAAAD9////Ag6BAQAAAAAAFgAULfNI+6HV8XwNm6k215opak1NIUOEAwAAAAAAABYAFFWyh7v5Wliw/eMsyvIhdIjcFcOWAAAAAAEBHw6BAQAAAAAAFgAULfNI+6HV8XwNm6k215opak1NIUMiBgMtyDX9uzN8sBoE/EgnwKqA1165uji362cmhOoaNApSshh3Rt53VAAAgAEAAIAAAACAAQAAAAQAAAAAIgID3LDPfRo5Dnqny9PwT9gVhlm4NpBIJxhHkpOqHJuWGA8Yd0bed1QAAIABAACAAAAAgAAAAAAHAAAAACICAibyHkvhAx+N5YcfQp9R5xJa97neDE4nHzBDceWY5iIsGHdG3ndUAACAAQAAgAAAAIABAAAABQAAAAA=&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00001410,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2) Assinar parcialmente (na mesma carteira)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAHECAAAAAXT7uaRFVyzfv8vbDqsOc4AWZzxAoX0SgXzlK63dkuV+AAAAAAD9////Av5ZAQAAAAAAFgAUPB1NRWTdgyzRoZFlsIIWnyBXUe6OIQAAAAAAABYAFFLIhzxtVXCBjkVvZAHeJT4+bmJ3AAAAAAABAHECAAAAAS0mLffRUqI69eSsvc7Kr1Gcvn0FbSfYGqHxIdrYytV9AAAAAAD9////Ag6BAQAAAAAAFgAULfNI+6HV8XwNm6k215opak1NIUOEAwAAAAAAABYAFFWyh7v5Wliw/eMsyvIhdIjcFcOWAAAAAAEBHw6BAQAAAAAAFgAULfNI+6HV8XwNm6k215opak1NIUMiBgMtyDX9uzN8sBoE/EgnwKqA1165uji362cmhOoaNApSshh3Rt53VAAAgAEAAIAAAACAAQAAAAQAAAAAIgICzhcJSGl7Ti2W88hb5YQcmaXesjGIVfnwQfI9ua9/YugYd0bed1QAAIABAACAAAAAgAEAAAAGAAAAACICA9ywz30aOQ56p8vT8E/YFYZZuDaQSCcYR5KTqhyblhgPGHdG3ndUAACAAQAAgAAAAIAAAAAABwAAAAA=&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAHECAAAAAXT7uaRFVyzfv8vbDqsOc4AWZzxAoX0SgXzlK63dkuV+AAAAAAD9////Av5ZAQAAAAAAFgAUPB1NRWTdgyzRoZFlsIIWnyBXUe6OIQAAAAAAABYAFFLIhzxtVXCBjkVvZAHeJT4+bmJ3AAAAAAABAHECAAAAAS0mLffRUqI69eSsvc7Kr1Gcvn0FbSfYGqHxIdrYytV9AAAAAAD9////Ag6BAQAAAAAAFgAULfNI+6HV8XwNm6k215opak1NIUOEAwAAAAAAABYAFFWyh7v5Wliw/eMsyvIhdIjcFcOWAAAAAAEBHw6BAQAAAAAAFgAULfNI+6HV8XwNm6k215opak1NIUMBCGsCRzBEAiAr3JNj8Wi53EJXvNDkCsKxxJsMImD936VKE6qyh5aJCwIgMcro3u7lcRSAF7PQrOBZVSv2eTPY9n/yJke8FqcMbxgBIQMtyDX9uzN8sBoE/EgnwKqA1165uji362cmhOoaNApSsgAiAgLOFwlIaXtOLZbzyFvlhByZpd6yMYhV+fBB8j25r39i6Bh3Rt53VAAAgAEAAIAAAACAAQAAAAYAAAAAIgID3LDPfRo5Dnqny9PwT9gVhlm4NpBIJxhHkpOqHJuWGA8Yd0bed1QAAIABAACAAAAAgAAAAAAHAAAAAA==&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000000010174fbb9a445572cdfbfcbdb0eab0e738016673c40a17d12817ce52baddd92e57e0000000000fdffffff02fe590100000000001600143c1d4d4564dd832cd1a19165b082169f205751ee8e2100000000000016001452c8873c6d5570818e456f6401de253e3e6e62770247304402202bdc9363f168b9dc4257bcd0e40ac2b1c49b0c2260fddfa54a13aab28796890b022031cae8deeee571148017b3d0ace059552bf67933d8f67ff22647bc16a70c6f180121032dc835fdbb337cb01a04fc4827c0aa80d75eb9ba38b7eb672684ea1a340a52b200000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletprocesspsbt&lt;/code&gt; adiciona as assinaturas que a carteira consegue fazer. Em uma carteira comum (não multisig), isso deixa &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete=true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Explicando os campos que o comando retorna:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;psbt&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;É a &lt;strong&gt;transação parcialmente assinada&lt;/strong&gt; (ainda em &lt;em&gt;formato PSBT&lt;/em&gt;, base64).&lt;/li&gt;
  &lt;li&gt;Serve se você &lt;strong&gt;ainda fosse passar para outro signatário&lt;/strong&gt; ou quisesse guardar o arquivo.&lt;/li&gt;
  &lt;li&gt;Caso &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; fosse &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt;, esse seria o valor a enviar para o próximo participante ou para usar em &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; significa que &lt;em&gt;todas&lt;/em&gt; as assinaturas necessárias já foram adicionadas.&lt;/li&gt;
  &lt;li&gt;Se fosse &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt;, você continuaria circulando o PSBT entre as partes ou rodaria &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;combinepsbt&lt;/code&gt; etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hex&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;É a &lt;strong&gt;transação Bitcoin final&lt;/strong&gt; já serializada (raw hex) pronta para a rede.&lt;/li&gt;
  &lt;li&gt;Quando &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; é &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt;, o Core já te entrega esse hex, que já pode ser transmitido.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3) Finalizar e transmitir&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Como &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete = true&lt;/code&gt;&lt;/strong&gt;, &lt;em&gt;**&lt;/em&gt;não precisa chamar &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;. Basta pegar o valor de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hex&lt;/code&gt; e transmitir:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000000010174fbb9a445572cdfbfcbdb0eab0e738016673c40a17d12817ce52baddd92e57e0000000000fdffffff02fe590100000000001600143c1d4d4564dd832cd1a19165b082169f205751ee8e2100000000000016001452c8873c6d5570818e456f6401de253e3e6e62770247304402202bdc9363f168b9dc4257bcd0e40ac2b1c49b0c2260fddfa54a13aab28796890b022031cae8deeee571148017b3d0ace059552bf67933d8f67ff22647bc16a70c6f180121032dc835fdbb337cb01a04fc4827c0aa80d75eb9ba38b7eb672684ea1a340a52b200000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# a1a93c02cfb449040677950d1abf33f57c923273d5f091c942c08d229e638ce4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Se &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; = false&lt;/strong&gt;, &lt;em&gt;**&lt;/em&gt;usaríamos o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;psbt&quot;&lt;/code&gt; retornado:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; finalizepsbt &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;PSBT_ASSINADA&amp;gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Esse comando geraria o hex final a ser transmitido.&lt;/p&gt;

&lt;h3 id=&quot;multisig&quot;&gt;Multisig&lt;/h3&gt;

&lt;p&gt;Multisig é um esquema de custódia no Bitcoin em que um gasto só é válido quando um número mínimo pré-definido de chaves entre várias participantes assina a transação, como “2-de-3” ou “3-de-5”, aumentando a segurança e permitindo controle compartilhado.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vantagens:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Resistência a roubo/perda:&lt;/strong&gt; 1 chave comprometida não gasta os fundos (em 2-de-3); perda de 1 chave ainda permite recuperação.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Herança/backup:&lt;/strong&gt; distribuição de chaves entre pessoas/cofres diferentes.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Governança:&lt;/strong&gt; políticas de aprovação (m-de-n) para empresas/DAOs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vamos ver um exemplo prático no Bitcoin Core:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) Criar três carteiras (participantes)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira1 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true
&lt;/span&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira2 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true
&lt;/span&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira3 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Criamos carteiras &lt;strong&gt;com chaves privadas&lt;/strong&gt; e &lt;strong&gt;com descriptors&lt;/strong&gt;. Evite &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blank=true&lt;/code&gt; e &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;disable_private_keys=true&lt;/code&gt; para não obter carteiras “vazias”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) Obter os xpubs (com fingerprint/derivação)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Para cada carteira, liste os descriptors públicos e copie as linhas de &lt;strong&gt;recebimento (…/0/&lt;em&gt;)** e **troco (…/1/&lt;/em&gt;)&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira1 listdescriptors
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;wallet_name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira1&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;descriptors&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    ...,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/0/*)#jr2a4z9x&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650612,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/1/*)#rh0ugh47&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650613,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira2 listdescriptors
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 ...,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/0/*)#k32vf2uu&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650639,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/1/*)#890d5lvy&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650640,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira3 listdescriptors
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;wallet_name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira3&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;descriptors&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    ...,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/0/*)#5szljz27&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650645,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/1/*)#9y870h6x&quot;&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758650645,
      &lt;span class=&quot;s2&quot;&gt;&quot;active&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;internal&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;range&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        0,
        999
      &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
      &lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;: 0,
      &lt;span class=&quot;s2&quot;&gt;&quot;next_index&quot;&lt;/span&gt;: 0
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;O que copiar:&lt;/strong&gt; os descriptors públicos de recebimento (…/0/&lt;em&gt;) e troco (…/1/&lt;/em&gt;), eles trazem fingerprint + caminho (ex.: [ba39c771/84h/1h/0h]tpub…/0/*), que é essencial para montar o multisig corretamente.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Padrão de endereço:&lt;/strong&gt; os exemplos usam a derivação 84h/1h/0h (Bech32, P2WPKH para singlesig). No multisig, vamos combiná-los em P2WSH (wsh(sortedmulti(…))).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) Criar carteira multisig (watch-only) e importar os descriptors multisig (recebimento e troco)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Por que “watch-only”?&lt;/strong&gt; Essa carteira &lt;strong&gt;vê&lt;/strong&gt; UTXOs, &lt;strong&gt;gera endereços&lt;/strong&gt; e &lt;strong&gt;cria PSBTs&lt;/strong&gt;, mas &lt;strong&gt;não&lt;/strong&gt; tem chaves privadas, as assinaturas acontecem nas carteiras participantes (carteira1, 2 e 3).&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet multisig-2of3 &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;multisig-2of3&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;warnings&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;Empty string given as passphrase, wallet will not be encrypted.&quot;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;multisig-2of3 importdescriptors &lt;span class=&quot;o&quot;&gt;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;desc&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;:&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;wsh&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sortedmulti&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;2,[ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/0/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;,[1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/0/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;,[fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/0/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;#ed8gy0hl\&quot;,\&quot;active\&quot;:true,\&quot;timestamp\&quot;:\&quot;now\&quot;},{\&quot;desc\&quot;:\&quot;wsh(sortedmulti(2,[ba39c771/84h/1h/0h]tpubDCYmREHcMiWLvGJ4goQeYcvNARJtp8Bcuf2wSo5NZKHLHiu91xoH1135ngN3MmHHB9L6bYabHiFkBamEavcVeEoKGDWj7op1atN6xeCotwk/1/*,[1b69360a/84h/1h/0h]tpubDD2gr2TXupxDBjtLUnFkWVsNMYNNcPeLrRmR4M9Eo7NEShdCnJRcsccxRtzAKDT1F2cXGdSKPTerBX2FsYRUcDZtRNzd7rPeS9Fg3HMBC4x/1/*,[fd4d4620/84h/1h/0h]tpubDDnWDjzpV82Wxdr7woANyPdKnSvQvEERPnzxoK2iPLUf8M8HA6Dr1rKw5FqnUFabN5zbQjexYNTCW8QC16NUpd6m1JogodyjLe5fRYvQ5KT/1/*))#tcmu8qku\&quot;,\&quot;active\&quot;:true,\&quot;internal\&quot;:true,\&quot;timestamp\&quot;:\&quot;now\&quot;}]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;warnings&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;Range not given, using default keypool range&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;warnings&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;Range not given, using default keypool range&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sortedmulti&lt;/code&gt;&lt;/strong&gt;: garante uma ordem determinística das chaves (independente da ordem de entrada), evitando endereços diferentes para o mesmo conjunto de chaves.
O aviso &lt;strong&gt;“Range not given”&lt;/strong&gt; apenas informa que o Core usará o &lt;strong&gt;range padrão 0–999&lt;/strong&gt; para geração dos endereços. Para a maioria dos casos, está ótimo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4) Receber fundos na multisig&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gere um novo endereço para essa nova carteira multisig:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;multisig-2of3 getnewaddress
&lt;span class=&quot;c&quot;&gt;# tb1qrlwt49k9hqgj7m3rlc4elfj3fxe96l93zz9ez5209z8uskrqg7yqhl3v88&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Envie alguns sats para o endereço gerado (via faucet de signet). Aguarde 1+ confirmações.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5) Criar a PSBT de gasto (na multisig)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;multisig-2of3 walletcreatefundedpsbt &lt;span class=&quot;s2&quot;&gt;&quot;[]&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tb1qqu7d6zmh5mpf07xd7t9aehe0re63hfqk2wh2ew6045zc5svshphq7j4eek&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0.00001}]&quot;&lt;/span&gt; 0 &lt;span class=&quot;s2&quot;&gt;&quot;{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;subtractFeeFromOutputs&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:[0]}&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4gBBWlSIQJZjBpYnPp6gdya1bvpPkXwErQ424X7Eiqj25upzqIeRiEDXhdQEgTlTkaejfQ1dFMTZEcN56pqAbHKe7hrZOQjfgEhA/h1maO3qpfAcR3j68mMdveJY46+KcNozEIdX8xytq37U64iBgJZjBpYnPp6gdya1bvpPkXwErQ424X7Eiqj25upzqIeRhj9TUYgVAAAgAEAAIAAAACAAAAAAAEAAAAiBgNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+ARi6OcdxVAAAgAEAAIAAAACAAAAAAAEAAAAiBgP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+xgbaTYKVAAAgAEAAIAAAACAAAAAAAEAAAAAAQFpUiECjYva6pgqf1d8DDVoN46EoRuaU/qy/weRiONtVRAjuO8hAsfmbKsHsX6XD/JKtSyCDfVpqoBK24GX0KrsYlua0qUnIQPpfknswuv25jK/T415iSz2HURL0M5AO45/HVN838DnFFOuIgICjYva6pgqf1d8DDVoN46EoRuaU/qy/weRiONtVRAjuO8YujnHcVQAAIABAACAAAAAgAEAAAAAAAAAIgICx+ZsqwexfpcP8kq1LIIN9WmqgErbgZfQquxiW5rSpScY/U1GIFQAAIABAACAAAAAgAEAAAAAAAAAIgID6X5J7MLr9uYyv0+NeYks9h1ES9DOQDuOfx1TfN/A5xQYG2k2ClQAAIABAACAAAAAgAEAAAAAAAAAAAEBaVIhAmSJnfRCGOGV1xlR7Y3ztT9wWc8rwk31GPiTREter5uLIQLb8uQENPCaP1PBJb+37VoM/h9QC/rL5HETeXZ1bhFU6iED2aAhSuk7nRvKrQpHwj4Po30ARRPTPidVjaiVIjjwJrFTriICAmSJnfRCGOGV1xlR7Y3ztT9wWc8rwk31GPiTREter5uLGLo5x3FUAACAAQAAgAAAAIAAAAAAAgAAACICAtvy5AQ08Jo/U8Elv7ftWgz+H1AL+svkcRN5dnVuEVTqGBtpNgpUAACAAQAAgAAAAIAAAAAAAgAAACICA9mgIUrpO50byq0KR8I+D6N9AEUT0z4nVY2olSI48CaxGP1NRiBUAACAAQAAgAAAAIAAAAAAAgAAAAA=&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000201,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 0
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletcreatefundedpsbt&lt;/code&gt; &lt;strong&gt;seleciona UTXOs&lt;/strong&gt;, monta a transação, &lt;strong&gt;calcula a taxa&lt;/strong&gt; e devolve uma&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PSBT&lt;/strong&gt; com os metadados para assinatura.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractFeeFromOutputs&lt;/code&gt;&lt;/strong&gt;: se ligado para o índice 0, a taxa é “debitada” daquela saída (útil para enviar “o que sobrar” sem ficar ajustando manualmente).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6) Assinar em duas carteiras (Carteira1 e Carteira2, separadamente)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira1 walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4gBBWlSIQJZjBpYnPp6gdya1bvpPkXwErQ424X7Eiqj25upzqIeRiEDXhdQEgTlTkaejfQ1dFMTZEcN56pqAbHKe7hrZOQjfgEhA/h1maO3qpfAcR3j68mMdveJY46+KcNozEIdX8xytq37U64iBgJZjBpYnPp6gdya1bvpPkXwErQ424X7Eiqj25upzqIeRhj9TUYgVAAAgAEAAIAAAACAAAAAAAEAAAAiBgNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+ARi6OcdxVAAAgAEAAIAAAACAAAAAAAEAAAAiBgP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+xgbaTYKVAAAgAEAAIAAAACAAAAAAAEAAAAAAQFpUiECjYva6pgqf1d8DDVoN46EoRuaU/qy/weRiONtVRAjuO8hAsfmbKsHsX6XD/JKtSyCDfVpqoBK24GX0KrsYlua0qUnIQPpfknswuv25jK/T415iSz2HURL0M5AO45/HVN838DnFFOuIgICjYva6pgqf1d8DDVoN46EoRuaU/qy/weRiONtVRAjuO8YujnHcVQAAIABAACAAAAAgAEAAAAAAAAAIgICx+ZsqwexfpcP8kq1LIIN9WmqgErbgZfQquxiW5rSpScY/U1GIFQAAIABAACAAAAAgAEAAAAAAAAAIgID6X5J7MLr9uYyv0+NeYks9h1ES9DOQDuOfx1TfN/A5xQYG2k2ClQAAIABAACAAAAAgAEAAAAAAAAAAAEBaVIhAmSJnfRCGOGV1xlR7Y3ztT9wWc8rwk31GPiTREter5uLIQLb8uQENPCaP1PBJb+37VoM/h9QC/rL5HETeXZ1bhFU6iED2aAhSuk7nRvKrQpHwj4Po30ARRPTPidVjaiVIjjwJrFTriICAmSJnfRCGOGV1xlR7Y3ztT9wWc8rwk31GPiTREter5uLGLo5x3FUAACAAQAAgAAAAIAAAAAAAgAAACICAtvy5AQ08Jo/U8Elv7ftWgz+H1AL+svkcRN5dnVuEVTqGBtpNgpUAACAAQAAgAAAAIAAAAAAAgAAACICA9mgIUrpO50byq0KR8I+D6N9AEUT0z4nVY2olSI48CaxGP1NRiBUAACAAQAAgAAAAIAAAAAAAgAAAAA=&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4giAgNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+AUcwRAIgB6mBfdUF86oq5i2Uonky/z62osyDgVh5Co3mXz3Ro+YCIFW8tuPErWsSQiI+T5yhPH/vDUmg+pdOB0hlyBSSj6jVAQEFaVIhAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GIQNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+ASED+HWZo7eql8BxHePryYx294ljjr4pw2jMQh1fzHK2rftTriIGAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GGP1NRiBUAACAAQAAgAAAAIAAAAAAAQAAACIGA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BGLo5x3FUAACAAQAAgAAAAIAAAAAAAQAAACIGA/h1maO3qpfAcR3j68mMdveJY46+KcNozEIdX8xytq37GBtpNgpUAACAAQAAgAAAAIAAAAAAAQAAAAABAWlSIQKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47yECx+ZsqwexfpcP8kq1LIIN9WmqgErbgZfQquxiW5rSpSchA+l+SezC6/bmMr9PjXmJLPYdREvQzkA7jn8dU3zfwOcUU64iAgKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47xi6OcdxVAAAgAEAAIAAAACAAQAAAAAAAAAiAgLH5myrB7F+lw/ySrUsgg31aaqAStuBl9Cq7GJbmtKlJxj9TUYgVAAAgAEAAIAAAACAAQAAAAAAAAAiAgPpfknswuv25jK/T415iSz2HURL0M5AO45/HVN838DnFBgbaTYKVAAAgAEAAIAAAACAAQAAAAAAAAAAAQFpUiECZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4shAtvy5AQ08Jo/U8Elv7ftWgz+H1AL+svkcRN5dnVuEVTqIQPZoCFK6TudG8qtCkfCPg+jfQBFE9M+J1WNqJUiOPAmsVOuIgICZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4sYujnHcVQAAIABAACAAAAAgAAAAAACAAAAIgIC2/LkBDTwmj9TwSW/t+1aDP4fUAv6y+RxE3l2dW4RVOoYG2k2ClQAAIABAACAAAAAgAAAAAACAAAAIgID2aAhSuk7nRvKrQpHwj4Po30ARRPTPidVjaiVIjjwJrEY/U1GIFQAAIABAACAAAAAgAAAAAACAAAAAA==&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira2 walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4gBBWlSIQJZjBpYnPp6gdya1bvpPkXwErQ424X7Eiqj25upzqIeRiEDXhdQEgTlTkaejfQ1dFMTZEcN56pqAbHKe7hrZOQjfgEhA/h1maO3qpfAcR3j68mMdveJY46+KcNozEIdX8xytq37U64iBgJZjBpYnPp6gdya1bvpPkXwErQ424X7Eiqj25upzqIeRhj9TUYgVAAAgAEAAIAAAACAAAAAAAEAAAAiBgNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+ARi6OcdxVAAAgAEAAIAAAACAAAAAAAEAAAAiBgP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+xgbaTYKVAAAgAEAAIAAAACAAAAAAAEAAAAAAQFpUiECjYva6pgqf1d8DDVoN46EoRuaU/qy/weRiONtVRAjuO8hAsfmbKsHsX6XD/JKtSyCDfVpqoBK24GX0KrsYlua0qUnIQPpfknswuv25jK/T415iSz2HURL0M5AO45/HVN838DnFFOuIgICjYva6pgqf1d8DDVoN46EoRuaU/qy/weRiONtVRAjuO8YujnHcVQAAIABAACAAAAAgAEAAAAAAAAAIgICx+ZsqwexfpcP8kq1LIIN9WmqgErbgZfQquxiW5rSpScY/U1GIFQAAIABAACAAAAAgAEAAAAAAAAAIgID6X5J7MLr9uYyv0+NeYks9h1ES9DOQDuOfx1TfN/A5xQYG2k2ClQAAIABAACAAAAAgAEAAAAAAAAAAAEBaVIhAmSJnfRCGOGV1xlR7Y3ztT9wWc8rwk31GPiTREter5uLIQLb8uQENPCaP1PBJb+37VoM/h9QC/rL5HETeXZ1bhFU6iED2aAhSuk7nRvKrQpHwj4Po30ARRPTPidVjaiVIjjwJrFTriICAmSJnfRCGOGV1xlR7Y3ztT9wWc8rwk31GPiTREter5uLGLo5x3FUAACAAQAAgAAAAIAAAAAAAgAAACICAtvy5AQ08Jo/U8Elv7ftWgz+H1AL+svkcRN5dnVuEVTqGBtpNgpUAACAAQAAgAAAAIAAAAAAAgAAACICA9mgIUrpO50byq0KR8I+D6N9AEUT0z4nVY2olSI48CaxGP1NRiBUAACAAQAAgAAAAIAAAAAAAgAAAAA=&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4giAgP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+0cwRAIgC/OAYLP2UKZwKDp7ig54A070T7BuMmtmosw2Er4L3JMCIHc9wACs5v3Ap8iDl9t9YXJjYfsOceBXXH6ur+Ug/mONAQEFaVIhAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GIQNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+ASED+HWZo7eql8BxHePryYx294ljjr4pw2jMQh1fzHK2rftTriIGAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GGP1NRiBUAACAAQAAgAAAAIAAAAAAAQAAACIGA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BGLo5x3FUAACAAQAAgAAAAIAAAAAAAQAAACIGA/h1maO3qpfAcR3j68mMdveJY46+KcNozEIdX8xytq37GBtpNgpUAACAAQAAgAAAAIAAAAAAAQAAAAABAWlSIQKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47yECx+ZsqwexfpcP8kq1LIIN9WmqgErbgZfQquxiW5rSpSchA+l+SezC6/bmMr9PjXmJLPYdREvQzkA7jn8dU3zfwOcUU64iAgKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47xi6OcdxVAAAgAEAAIAAAACAAQAAAAAAAAAiAgLH5myrB7F+lw/ySrUsgg31aaqAStuBl9Cq7GJbmtKlJxj9TUYgVAAAgAEAAIAAAACAAQAAAAAAAAAiAgPpfknswuv25jK/T415iSz2HURL0M5AO45/HVN838DnFBgbaTYKVAAAgAEAAIAAAACAAQAAAAAAAAAAAQFpUiECZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4shAtvy5AQ08Jo/U8Elv7ftWgz+H1AL+svkcRN5dnVuEVTqIQPZoCFK6TudG8qtCkfCPg+jfQBFE9M+J1WNqJUiOPAmsVOuIgICZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4sYujnHcVQAAIABAACAAAAAgAAAAAACAAAAIgIC2/LkBDTwmj9TwSW/t+1aDP4fUAv6y+RxE3l2dW4RVOoYG2k2ClQAAIABAACAAAAAgAAAAAACAAAAIgID2aAhSuk7nRvKrQpHwj4Po30ARRPTPidVjaiVIjjwJrEY/U1GIFQAAIABAACAAAAAgAAAAAACAAAAAA==&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Cada participante &lt;strong&gt;assina&lt;/strong&gt; com &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;walletprocesspsbt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sequencial vs. paralelo:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;Sequencial:&lt;/em&gt; saída da carteira1 (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;psbt&lt;/code&gt; já com 1 assinatura) entra na carteira2 → geralmente já volta &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete: true&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Paralelo (a que usamos nesse exemplo):&lt;/em&gt; cada um assina a &lt;strong&gt;mesma PSBT original&lt;/strong&gt; e depois você &lt;strong&gt;combina&lt;/strong&gt; (próximo passo).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7) Combine os 2 PSBT assinados&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; combinepsbt &lt;span class=&quot;s2&quot;&gt;&quot;[&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4giAgNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+AUcwRAIgB6mBfdUF86oq5i2Uonky/z62osyDgVh5Co3mXz3Ro+YCIFW8tuPErWsSQiI+T5yhPH/vDUmg+pdOB0hlyBSSj6jVAQEFaVIhAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GIQNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+ASED+HWZo7eql8BxHePryYx294ljjr4pw2jMQh1fzHK2rftTriIGAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GGP1NRiBUAACAAQAAgAAAAIAAAAAAAQAAACIGA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BGLo5x3FUAACAAQAAgAAAAIAAAAAAAQAAACIGA/h1maO3qpfAcR3j68mMdveJY46+KcNozEIdX8xytq37GBtpNgpUAACAAQAAgAAAAIAAAAAAAQAAAAABAWlSIQKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47yECx+ZsqwexfpcP8kq1LIIN9WmqgErbgZfQquxiW5rSpSchA+l+SezC6/bmMr9PjXmJLPYdREvQzkA7jn8dU3zfwOcUU64iAgKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47xi6OcdxVAAAgAEAAIAAAACAAQAAAAAAAAAiAgLH5myrB7F+lw/ySrUsgg31aaqAStuBl9Cq7GJbmtKlJxj9TUYgVAAAgAEAAIAAAACAAQAAAAAAAAAiAgPpfknswuv25jK/T415iSz2HURL0M5AO45/HVN838DnFBgbaTYKVAAAgAEAAIAAAACAAQAAAAAAAAAAAQFpUiECZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4shAtvy5AQ08Jo/U8Elv7ftWgz+H1AL+svkcRN5dnVuEVTqIQPZoCFK6TudG8qtCkfCPg+jfQBFE9M+J1WNqJUiOPAmsVOuIgICZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4sYujnHcVQAAIABAACAAAAAgAAAAAACAAAAIgIC2/LkBDTwmj9TwSW/t+1aDP4fUAv6y+RxE3l2dW4RVOoYG2k2ClQAAIABAACAAAAAgAAAAAACAAAAIgID2aAhSuk7nRvKrQpHwj4Po30ARRPTPidVjaiVIjjwJrEY/U1GIFQAAIABAACAAAAAgAAAAAACAAAAAA==&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4giAgP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+0cwRAIgC/OAYLP2UKZwKDp7ig54A070T7BuMmtmosw2Er4L3JMCIHc9wACs5v3Ap8iDl9t9YXJjYfsOceBXXH6ur+Ug/mONAQEFaVIhAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GIQNeF1ASBOVORp6N9DV0UxNkRw3nqmoBscp7uGtk5CN+ASED+HWZo7eql8BxHePryYx294ljjr4pw2jMQh1fzHK2rftTriIGAlmMGlic+nqB3JrVu+k+RfAStDjbhfsSKqPbm6nOoh5GGP1NRiBUAACAAQAAgAAAAIAAAAAAAQAAACIGA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BGLo5x3FUAACAAQAAgAAAAIAAAAAAAQAAACIGA/h1maO3qpfAcR3j68mMdveJY46+KcNozEIdX8xytq37GBtpNgpUAACAAQAAgAAAAIAAAAAAAQAAAAABAWlSIQKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47yECx+ZsqwexfpcP8kq1LIIN9WmqgErbgZfQquxiW5rSpSchA+l+SezC6/bmMr9PjXmJLPYdREvQzkA7jn8dU3zfwOcUU64iAgKNi9rqmCp/V3wMNWg3joShG5pT+rL/B5GI421VECO47xi6OcdxVAAAgAEAAIAAAACAAQAAAAAAAAAiAgLH5myrB7F+lw/ySrUsgg31aaqAStuBl9Cq7GJbmtKlJxj9TUYgVAAAgAEAAIAAAACAAQAAAAAAAAAiAgPpfknswuv25jK/T415iSz2HURL0M5AO45/HVN838DnFBgbaTYKVAAAgAEAAIAAAACAAQAAAAAAAAAAAQFpUiECZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4shAtvy5AQ08Jo/U8Elv7ftWgz+H1AL+svkcRN5dnVuEVTqIQPZoCFK6TudG8qtCkfCPg+jfQBFE9M+J1WNqJUiOPAmsVOuIgICZImd9EIY4ZXXGVHtjfO1P3BZzyvCTfUY+JNES16vm4sYujnHcVQAAIABAACAAAAAgAAAAAACAAAAIgIC2/LkBDTwmj9TwSW/t+1aDP4fUAv6y+RxE3l2dW4RVOoYG2k2ClQAAIABAACAAAAAgAAAAAACAAAAIgID2aAhSuk7nRvKrQpHwj4Po30ARRPTPidVjaiVIjjwJrEY/U1GIFQAAIABAACAAAAAgAAAAAACAAAAAA==&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;]&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4giAgP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+0cwRAIgC/OAYLP2UKZwKDp7ig54A070T7BuMmtmosw2Er4L3JMCIHc9wACs5v3Ap8iDl9t9YXJjYfsOceBXXH6ur+Ug/mONASICA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BRzBEAiAHqYF91QXzqirmLZSieTL/PraizIOBWHkKjeZfPdGj5gIgVby248StaxJCIj5PnKE8f+8NSaD6l04HSGXIFJKPqNUBAQVpUiECWYwaWJz6eoHcmtW76T5F8BK0ONuF+xIqo9ubqc6iHkYhA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BIQP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+1OuIgYCWYwaWJz6eoHcmtW76T5F8BK0ONuF+xIqo9ubqc6iHkYY/U1GIFQAAIABAACAAAAAgAAAAAABAAAAIgYDXhdQEgTlTkaejfQ1dFMTZEcN56pqAbHKe7hrZOQjfgEYujnHcVQAAIABAACAAAAAgAAAAAABAAAAIgYD+HWZo7eql8BxHePryYx294ljjr4pw2jMQh1fzHK2rfsYG2k2ClQAAIABAACAAAAAgAAAAAABAAAAAAEBaVIhAo2L2uqYKn9XfAw1aDeOhKEbmlP6sv8HkYjjbVUQI7jvIQLH5myrB7F+lw/ySrUsgg31aaqAStuBl9Cq7GJbmtKlJyED6X5J7MLr9uYyv0+NeYks9h1ES9DOQDuOfx1TfN/A5xRTriICAo2L2uqYKn9XfAw1aDeOhKEbmlP6sv8HkYjjbVUQI7jvGLo5x3FUAACAAQAAgAAAAIABAAAAAAAAACICAsfmbKsHsX6XD/JKtSyCDfVpqoBK24GX0KrsYlua0qUnGP1NRiBUAACAAQAAgAAAAIABAAAAAAAAACICA+l+SezC6/bmMr9PjXmJLPYdREvQzkA7jn8dU3zfwOcUGBtpNgpUAACAAQAAgAAAAIABAAAAAAAAAAABAWlSIQJkiZ30QhjhldcZUe2N87U/cFnPK8JN9Rj4k0RLXq+biyEC2/LkBDTwmj9TwSW/t+1aDP4fUAv6y+RxE3l2dW4RVOohA9mgIUrpO50byq0KR8I+D6N9AEUT0z4nVY2olSI48CaxU64iAgJkiZ30QhjhldcZUe2N87U/cFnPK8JN9Rj4k0RLXq+bixi6OcdxVAAAgAEAAIAAAACAAAAAAAIAAAAiAgLb8uQENPCaP1PBJb+37VoM/h9QC/rL5HETeXZ1bhFU6hgbaTYKVAAAgAEAAIAAAACAAAAAAAIAAAAiAgPZoCFK6TudG8qtCkfCPg+jfQBFE9M+J1WNqJUiOPAmsRj9TUYgVAAAgAEAAIAAAACAAAAAAAIAAAAA&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quando usar:&lt;/strong&gt; se os signatários assinaram &lt;strong&gt;em paralelo&lt;/strong&gt; (cada um pegou a PSBT original).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resultado esperado:&lt;/strong&gt; a PSBT combinada já deve conter as &lt;strong&gt;2 assinaturas&lt;/strong&gt; exigidas (2-de-3).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8) Finalizar e transmitir&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; finalizepsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAIkCAAAAAbALDAmCzaLpmGLM3HosXOuodp03BnzZOWlsWzDBGdb6AQAAAAD9////AigjAAAAAAAAIgAgffrg1wuWTLU//NFkDdFKcLTiMQqIGXRBJYuZFOVjxmMfAwAAAAAAACIAIAc83Qt3psKX+M3yy9zfLx51G6QWU66su0+tBYpBkLhuAAAAAAABAIkCAAAAAVAByKT0ARhfFgU643lMMBY/UOnTo7PBxfKqTH7IFf1ZAAAAAAD9////An0DOwAAAAAAIlEgEOILQOfM8jum+vwMWifdS7i6Aexaov0TSmGb2+hRcQsQJwAAAAAAACIAIB/cupbFuBEvbiP+K5+mUUmyXXyxEIuRUU8oj8hYYEeIQiIEAAEBKxAnAAAAAAAAIgAgH9y6lsW4ES9uI/4rn6ZRSbJdfLEQi5FRTyiPyFhgR4giAgP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+0cwRAIgC/OAYLP2UKZwKDp7ig54A070T7BuMmtmosw2Er4L3JMCIHc9wACs5v3Ap8iDl9t9YXJjYfsOceBXXH6ur+Ug/mONASICA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BRzBEAiAHqYF91QXzqirmLZSieTL/PraizIOBWHkKjeZfPdGj5gIgVby248StaxJCIj5PnKE8f+8NSaD6l04HSGXIFJKPqNUBAQVpUiECWYwaWJz6eoHcmtW76T5F8BK0ONuF+xIqo9ubqc6iHkYhA14XUBIE5U5Gno30NXRTE2RHDeeqagGxynu4a2TkI34BIQP4dZmjt6qXwHEd4+vJjHb3iWOOvinDaMxCHV/Mcrat+1OuIgYCWYwaWJz6eoHcmtW76T5F8BK0ONuF+xIqo9ubqc6iHkYY/U1GIFQAAIABAACAAAAAgAAAAAABAAAAIgYDXhdQEgTlTkaejfQ1dFMTZEcN56pqAbHKe7hrZOQjfgEYujnHcVQAAIABAACAAAAAgAAAAAABAAAAIgYD+HWZo7eql8BxHePryYx294ljjr4pw2jMQh1fzHK2rfsYG2k2ClQAAIABAACAAAAAgAAAAAABAAAAAAEBaVIhAo2L2uqYKn9XfAw1aDeOhKEbmlP6sv8HkYjjbVUQI7jvIQLH5myrB7F+lw/ySrUsgg31aaqAStuBl9Cq7GJbmtKlJyED6X5J7MLr9uYyv0+NeYks9h1ES9DOQDuOfx1TfN/A5xRTriICAo2L2uqYKn9XfAw1aDeOhKEbmlP6sv8HkYjjbVUQI7jvGLo5x3FUAACAAQAAgAAAAIABAAAAAAAAACICAsfmbKsHsX6XD/JKtSyCDfVpqoBK24GX0KrsYlua0qUnGP1NRiBUAACAAQAAgAAAAIABAAAAAAAAACICA+l+SezC6/bmMr9PjXmJLPYdREvQzkA7jn8dU3zfwOcUGBtpNgpUAACAAQAAgAAAAIABAAAAAAAAAAABAWlSIQJkiZ30QhjhldcZUe2N87U/cFnPK8JN9Rj4k0RLXq+biyEC2/LkBDTwmj9TwSW/t+1aDP4fUAv6y+RxE3l2dW4RVOohA9mgIUrpO50byq0KR8I+D6N9AEUT0z4nVY2olSI48CaxU64iAgJkiZ30QhjhldcZUe2N87U/cFnPK8JN9Rj4k0RLXq+bixi6OcdxVAAAgAEAAIAAAACAAAAAAAIAAAAiAgLb8uQENPCaP1PBJb+37VoM/h9QC/rL5HETeXZ1bhFU6hgbaTYKVAAAgAEAAIAAAACAAAAAAAIAAAAiAgPZoCFK6TudG8qtCkfCPg+jfQBFE9M+J1WNqJUiOPAmsRj9TUYgVAAAgAEAAIAAAACAAAAAAAIAAAAA&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b00b0c0982cda2e99862ccdc7a2c5ceba8769d37067cd939696c5b30c119d6fa0100000000fdffffff0228230000000000002200207dfae0d70b964cb53ffcd1640dd14a70b4e2310a88197441258b9914e563c6631f03000000000000220020073cdd0b77a6c297f8cdf2cbdcdf2f1e751ba41653aeacbb4fad058a4190b86e0400473044022007a9817dd505f3aa2ae62d94a27932ff3eb6a2cc838158790a8de65f3dd1a3e6022055bcb6e3c4ad6b1242223e4f9ca13c7fef0d49a0fa974e074865c814928fa8d50147304402200bf38060b3f650a670283a7b8a0e78034ef44fb06e326b66a2cc3612be0bdc930220773dc000ace6fdc0a7c88397db7d61726361fb0e71e0575c7eaeafe520fe638d0169522102598c1a589cfa7a81dc9ad5bbe93e45f012b438db85fb122aa3db9ba9cea21e4621035e17501204e54e469e8df43574531364470de7aa6a01b1ca7bb86b64e4237e012103f87599a3b7aa97c0711de3ebc98c76f789638ebe29c368cc421d5fcc72b6adfb53ae00000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;finalizepsbt&lt;/code&gt;&lt;/strong&gt;: valida o script, monta os witness e devolve o &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hex&lt;/code&gt;&lt;/strong&gt; pronto para broadcast.&lt;/p&gt;

&lt;p&gt;Por fim, o comando &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendrawtransaction&lt;/code&gt;&lt;/strong&gt; publica a transação na rede.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b00b0c0982cda2e99862ccdc7a2c5ceba8769d37067cd939696c5b30c119d6fa0100000000fdffffff0228230000000000002200207dfae0d70b964cb53ffcd1640dd14a70b4e2310a88197441258b9914e563c6631f03000000000000220020073cdd0b77a6c297f8cdf2cbdcdf2f1e751ba41653aeacbb4fad058a4190b86e0400473044022007a9817dd505f3aa2ae62d94a27932ff3eb6a2cc838158790a8de65f3dd1a3e6022055bcb6e3c4ad6b1242223e4f9ca13c7fef0d49a0fa974e074865c814928fa8d50147304402200bf38060b3f650a670283a7b8a0e78034ef44fb06e326b66a2cc3612be0bdc930220773dc000ace6fdc0a7c88397db7d61726361fb0e71e0575c7eaeafe520fe638d0169522102598c1a589cfa7a81dc9ad5bbe93e45f012b438db85fb122aa3db9ba9cea21e4621035e17501204e54e469e8df43574531364470de7aa6a01b1ca7bb86b64e4237e012103f87599a3b7aa97c0711de3ebc98c76f789638ebe29c368cc421d5fcc72b6adfb53ae00000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# af5f0813b622d6a21389af6cecbe9d5098d71cdee814e7ba70fcbe0a7d1ce407&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perceba, pela mempool, que é uma transação multisig 2 de 3:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;../assets/artigo10-img1.webp&quot; alt=&quot;mempool1.png&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;timelocks&quot;&gt;Timelocks&lt;/h2&gt;

&lt;p&gt;No Bitcoin, &lt;strong&gt;timelock&lt;/strong&gt; é o nome genérico para mecanismos que determinam &lt;strong&gt;quando&lt;/strong&gt; uma transação ou um determinado UTXO pode ser gasto. Em vez de apenas exigir uma assinatura válida, o protocolo também verifica &lt;strong&gt;tempo ou altura de bloco&lt;/strong&gt;, criando condições de “espera obrigatória”.&lt;/p&gt;

&lt;p&gt;Existem duas formas principais.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;nLockTime:&lt;/strong&gt; um campo dentro da própria &lt;strong&gt;transação&lt;/strong&gt; que define o &lt;strong&gt;bloco mínimo&lt;/strong&gt; (ou um timestamp) a partir do qual a rede aceita incluí-la em um bloco. É simples e útil para “agendar” pagamentos, mas quem possui as chaves pode descartar essa transação e criar outra sem o bloqueio.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;CheckLockTimeVerify (CLTV):&lt;/strong&gt; uma &lt;strong&gt;operação de script&lt;/strong&gt; que grava a restrição diretamente no &lt;strong&gt;UTXO&lt;/strong&gt;. Nesse caso, o dinheiro “herda” a trava: nenhum gasto é possível antes da altura/tempo definido, mesmo que todos os donos das chaves queiram mudar.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Há ainda a variação &lt;strong&gt;CheckSequenceVerify (CSV)&lt;/strong&gt;, que funciona de forma parecida, mas com base em um intervalo relativo de confirmações (ex.: “pode gastar 144 blocos depois que este UTXO for confirmado”).&lt;/p&gt;

&lt;p&gt;Esses recursos permitem criar contratos como cofres com período de resgate, heranças com desbloqueio futuro, ou pagamentos programados que só se tornam válidos depois de certa data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a) nLockTime na prática&lt;/strong&gt;
&lt;strong&gt;Objetivo:&lt;/strong&gt; criar uma transação que &lt;strong&gt;só pode ser minerada&lt;/strong&gt; após um bloco-alvo.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Escolha o bloco-alvo&lt;/strong&gt; (ex.: altura atual + 2):&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
&lt;span class=&quot;c&quot;&gt;# 271141&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O comando &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getblockcount&lt;/code&gt; retorna a altura atual da blockchain. Podemos escolher, por exemplo, que a transação só poderá ser incluída a partir do bloco &lt;strong&gt;271145.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Crie a transação:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;demo-signet&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;[]&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tb1q4asvsg6hhv6vwxzq5uy05wf6zzusp8me5xmlzv&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0.0001}&quot;&lt;/span&gt; 271145
0200000000011027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7929230400
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Complete a transação:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;demo-signet fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000000011027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7929230400&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000001e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c29230400&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000141,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Assine a transação:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;demo-signet&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000001e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c29230400&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c0247304402205e358ba9097c1f7efe67093fae52c4664cf17648f75185ae47a95a875db8fccb0220691d79b3eb4dc54b3c095e167340f084057b1f803f0375460ecfdc4c4af2dfa1012102ce170948697b4e2d96f3c85be5841c99a5deb2318855f9f041f23db9af7f62e829230400&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Envie a transação:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Perceba que se tentarmos transmitir a transação antes da altura de bloco definida, obtemos um erro:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271143

bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c0247304402205e358ba9097c1f7efe67093fae52c4664cf17648f75185ae47a95a875db8fccb0220691d79b3eb4dc54b3c095e167340f084057b1f803f0375460ecfdc4c4af2dfa1012102ce170948697b4e2d96f3c85be5841c99a5deb2318855f9f041f23db9af7f62e829230400&quot;&lt;/span&gt;
error code: &lt;span class=&quot;nt&quot;&gt;-26&lt;/span&gt;
error message:
non-final
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;No Bitcoin, o campo &lt;strong&gt;nLockTime&lt;/strong&gt; funciona apenas como uma &lt;strong&gt;regra de validade de bloco&lt;/strong&gt;, não como um agendamento automático. Ele define a menor altura de bloco (ou timestamp) em que a transação &lt;strong&gt;pode ser incluída&lt;/strong&gt; na blockchain, mas a rede não a “guarda” até lá. Se você tentar transmiti-la antes de o limite ser atingido, os nós rejeitam com o erro &lt;em&gt;non-final&lt;/em&gt; e nada fica pendente. Por isso, o software ou script que cria a transação precisa acompanhar a altura atual (por exemplo, via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getblockcount&lt;/code&gt;) e só &lt;strong&gt;transmitir&lt;/strong&gt; quando &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;current_height&lt;/code&gt; for maior ou igual ao valor de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nLockTime&lt;/code&gt;. É diferente de um timelock em script (como &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OP_CHECKLOCKTIMEVERIFY&lt;/code&gt;), que grava a restrição na &lt;strong&gt;saída&lt;/strong&gt; e permite enviar a transação de funding hoje, garantindo que ela só possa ser gasta após o prazo, sem depender de monitoramento externo.
Ao enviarmos após o alvo, conseguimos:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271145

bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101e48c639e228dc042c991f0d57332927cf533bf1a0d9577060449b4cf023ca9a10000000000fdffffff021027000000000000160014af60c82357bb34c71840a708fa393a10b9009f7961320100000000001600143c7fa3189d4e5c9e6ca96eba73a525c94bf8ff9c0247304402205e358ba9097c1f7efe67093fae52c4664cf17648f75185ae47a95a875db8fccb0220691d79b3eb4dc54b3c095e167340f084057b1f803f0375460ecfdc4c4af2dfa1012102ce170948697b4e2d96f3c85be5841c99a5deb2318855f9f041f23db9af7f62e829230400&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 2c91cbd4e8bccacb42020eb88a1df0816d99fae7e2ee12ff6a8c996ca282374b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b) CLTV com Miniscript (timelock “forte” no UTXO)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objetivo:&lt;/strong&gt; criar um &lt;strong&gt;endereço P2WSH&lt;/strong&gt; cujo script exige &lt;strong&gt;altura mínima de bloco&lt;/strong&gt; para gastar.&lt;/p&gt;

&lt;p&gt;Vamos ver um passo a passo.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Criar uma nova carteira&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Vamos criar uma nova carteira para não misturar com outros exemplo.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira_cltv
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Criar um novo endereço e obter informações&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Como a nova carteira, podemos gerar um novo endereço.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# tb1q84ysz0zng7m8yad6zrps3uyn6reu977v85x0ga&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Em seguida podemos obter as informações desse novo endereço (utilizaremos a seguir):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; getaddressinfo tb1q84ysz0zng7m8yad6zrps3uyn6reu977v85x0ga
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;tb1q84ysz0zng7m8yad6zrps3uyn6reu977v85x0ga&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00143d49013c5347b67275ba10c308f093d0f3c2fbcc&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;ismine&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([261430f9/84h/1h/0h/0/0]03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79)#l4tsyqsx&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;parent_desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([261430f9/84h/1h/0h]tpubDDEKB1hKK8aCiLLPE35AqyEnRSbRTWgo27VVfG1iF8mdsJnYvuss736NutifM2NWnH78AVjW4hvHaDg3CzW7ZAHXVBMgPvoiYuYrZ5RgJii/0/*)#2hke87n4&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;iswatchonly&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;isscript&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;iswitness&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;witness_version&quot;&lt;/span&gt;: 0,
  &lt;span class=&quot;s2&quot;&gt;&quot;witness_program&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;3d49013c5347b67275ba10c308f093d0f3c2fbcc&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;pubkey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;ischange&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;: 1758845787,
  &lt;span class=&quot;s2&quot;&gt;&quot;hdkeypath&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;m/84h/1h/0h/0/0&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hdseedid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0000000000000000000000000000000000000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hdmasterfingerprint&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;261430f9&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;labels&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A partir da &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pubkey&lt;/code&gt;, podemos obter as informações para um novo descritor específico que produza endereços com restrição de altura do bloco (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;after(271220)&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; getdescriptorinfo &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;descriptor&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;checksum&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;gk4hzcry&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;isrange&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;issolvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hasprivatekeys&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Esse comando irá retornar um descritor já com seu &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CHECKSUM&lt;/code&gt; (no exemplo, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#gk4hzcry&lt;/code&gt;).&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Derivar um novo endereço a partir do descritor&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Com o descritor acima, podemos derivar endereços que já tenham em seu script a restrição da altura do bloco.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv&quot;&lt;/span&gt; deriveaddresses &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Qualquer UTXO associada ao endereço &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&lt;/code&gt; só poderá ser gasta a partir do bloco &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;271220&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Podemos ver qual o bloco atual:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271211
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Enviar saldo para o endereço timelock&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Podemos enviar algum saldo para este endereço criado para que possamos testar em seguida se conseguiremos fazer transações antes da altura de bloco definida. Podemos usar um faucet ou mandar BTCs de outra carteira, como no exemplo abaixo:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;demo-signet&quot;&lt;/span&gt; sendtoaddress &lt;span class=&quot;s2&quot;&gt;&quot;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&quot;&lt;/span&gt; 0.0001
&lt;span class=&quot;c&quot;&gt;# 8cc8b2a47bff4a4b146f16ca2656bfb341bb95040ace91b4d6698e3c34d00c3a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;De fato, usar timelock por script (CLTV) é isso, já está pronto. Os próximos passos servirão apenas para demonstrar que precisaremos esperar até a altura do bloco específica para poder gastar esse UTXO.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Criar uma carteira Watch Only&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Lembre-se que, quando o Bitcoin Core cria uma carteira, ele cria com aqueles 8 descritores padrões. Nas etapas anteriores, geramos um novo endereço pra carteira &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;carteira_cltv&lt;/code&gt; a partir de um novo descritor. No entanto, o Core não tem por padrão associar todos UTXO desse novo descritor à carteira automaticamente. Logo, se usarmos um &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listunspent&lt;/code&gt; na carteira &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;carteira_cltv&lt;/code&gt;, ele não irá mostrar o UTXO da transação acima (a que colocou saldo ao endereço). Para isso, criaremos uma nova carteira Watch Only:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createwallet carteira_cltv_wo &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;carteira_cltv_wo&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;E logo a seguir, usaremos o comando &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;importdescriptors&lt;/code&gt; para que essa nova carteira enxergue os UTXO associados aos endereços gerados pelo novo descritor:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo importdescriptors &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;timestamp&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;cltv-271220&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;}]&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Esse comando pode demorar uns minutinhos, pois ele faz uma varredura em todos UTXOs existentes.&lt;/p&gt;

&lt;p&gt;Assim que a transação que enviou saldo para esse endereço for confirmada, poderemos ver o UTXO:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;8cc8b2a47bff4a4b146f16ca2656bfb341bb95040ace91b4d6698e3c34d00c3a&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;tb1qjtt0qckzytswg2fa25x7ru6unnulhttd0jx82z7jf8epv95wkqwqcq3ave&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cltv-271220&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;witnessScript&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;2103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b1&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;002092d6f062c222e0e4293d550de1f35c9cf9fbad6d7c8c750bd249f216168eb01c&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.00010000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk([3d49013c]03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#dz9nuz04&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wsh(and_v(v:pk(03a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79),after(271220)))#gk4hzcry&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Criar uma transação e tentar enviar&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Agora vamos criar uma transação PSBT para tentar gastar a UTXO travada.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo createpsbt &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;txid&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;8cc8b2a47bff4a4b146f16ca2656bfb341bb95040ace91b4d6698e3c34d00c3a&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vout&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:1,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;sequence&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:4294967293}]&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;[{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tb1q3hhxstxlemumvsw2v8cgxwf860f6hxyk7p0d6v&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:0.00009800}]&quot;&lt;/span&gt; 271220
cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAAA
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Para poder gastar, eu preciso montar uma transação com o formato esperado, de forma que o script de liberação seja o correto. Assim, precisamos criar a PSBT com o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TXID&lt;/code&gt; da transação (com seu &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout&lt;/code&gt;), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sequence&lt;/code&gt;, o endereço de destino, o valor e a altura do bloco de liberação.&lt;/p&gt;

&lt;p&gt;Cada input de uma transação tem um campo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Sequence&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Se ele ficar no valor máximo (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0xffffffff&lt;/code&gt;), o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nLockTime&lt;/code&gt; da transação é &lt;strong&gt;ignorado&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;Se você usa um valor menor (ex.: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0xfffffffd&lt;/code&gt;), o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nLockTime&lt;/code&gt; passa a valer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No nosso caso o &lt;em&gt;timelock&lt;/em&gt; verdadeiro está no &lt;strong&gt;script do UTXO&lt;/strong&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OP_CHECKLOCKTIMEVERIFY&lt;/code&gt; gerado pelo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;after(...)&lt;/code&gt;). O &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nSequence&lt;/code&gt; só garante que a transação &lt;strong&gt;respeite&lt;/strong&gt; esse timelock; ele não consegue “destravar” o UTXO antes. Mesmo que alguém tente mudar &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nSequence&lt;/code&gt; para burlar, a rede continuará exigindo que a altura mínima do bloco seja atingida para gastar.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv_wo walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAAA&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAEAiQIAAAABLSYt99FSojr15Ky9zsqvUZy+fQVtJ9gaofEh2tjK1X0BAAAAAP3///8Cq/QFAAAAAAAiUSBBvNiOQzRikrFtQZ+SOr2H//vtnfnW1k0VJIOSi2uCvBAnAAAAAAAAIgAgktbwYsIi4OQpPVUN4fNcnPn7rW18jHUL0knyFhaOsBxoIwQAAQErECcAAAAAAAAiACCS1vBiwiLg5Ck9VQ3h81yc+futbXyMdQvSSfIWFo6wHAEFKCEDpj/gRUOo4soBlLqBGuB26zUMBwj14Ikl2wIKWbu+z3mtA3QjBLEiBgOmP+BFQ6jiygGUuoEa4HbrNQwHCPXgiSXbAgpZu77PeQQ9SQE8AAA=&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Completamos/assinamos a transação PSBT com a carteira Watch Only. E depois com a carteira original (que tem as chaves privadas):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rpcwallet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;carteira_cltv walletprocesspsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAEAiQIAAAABLSYt99FSojr15Ky9zsqvUZy+fQVtJ9gaofEh2tjK1X0BAAAAAP3///8Cq/QFAAAAAAAiUSBBvNiOQzRikrFtQZ+SOr2H//vtnfnW1k0VJIOSi2uCvBAnAAAAAAAAIgAgktbwYsIi4OQpPVUN4fNcnPn7rW18jHUL0knyFhaOsBxoIwQAAQErECcAAAAAAAAiACCS1vBiwiLg5Ck9VQ3h81yc+futbXyMdQvSSfIWFo6wHAEFKCEDpj/gRUOo4soBlLqBGuB26zUMBwj14Ikl2wIKWbu+z3mtA3QjBLEiBgOmP+BFQ6jiygGUuoEa4HbrNQwHCPXgiSXbAgpZu77PeQQ9SQE8AAA=&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;psbt&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAEAiQIAAAABLSYt99FSojr15Ky9zsqvUZy+fQVtJ9gaofEh2tjK1X0BAAAAAP3///8Cq/QFAAAAAAAiUSBBvNiOQzRikrFtQZ+SOr2H//vtnfnW1k0VJIOSi2uCvBAnAAAAAAAAIgAgktbwYsIi4OQpPVUN4fNcnPn7rW18jHUL0knyFhaOsBxoIwQAAQErECcAAAAAAAAiACCS1vBiwiLg5Ck9VQ3h81yc+futbXyMdQvSSfIWFo6wHAEIcgJHMEQCIHCL9BRnPQaDcCSzgwBSftiSQ1BOmPtGRbdr64yfjWKYAiAQGFxUhGPD+r9HXcdY5iDcRrg9b+KP5sNLgM8Q891y+wEoIQOmP+BFQ6jiygGUuoEa4HbrNQwHCPXgiSXbAgpZu77Pea0DdCMEsQAiAgKHsm3A/+yikYib3IwO6JLyqBKBd8XEGjer7kaAi2NKURgmFDD5VAAAgAEAAIAAAACAAAAAAAEAAAAA&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finalizamos a PSBT:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; finalizepsbt &lt;span class=&quot;s2&quot;&gt;&quot;cHNidP8BAFICAAAAAToM0DQ8jmnWtJHOCgSVu0Gzv1YmyhZvFEtK/3ukssiMAQAAAAD9////AUgmAAAAAAAAFgAUje5oLN/O+bZBymHwgzkn09OrmJZ0IwQAAAEAiQIAAAABLSYt99FSojr15Ky9zsqvUZy+fQVtJ9gaofEh2tjK1X0BAAAAAP3///8Cq/QFAAAAAAAiUSBBvNiOQzRikrFtQZ+SOr2H//vtnfnW1k0VJIOSi2uCvBAnAAAAAAAAIgAgktbwYsIi4OQpPVUN4fNcnPn7rW18jHUL0knyFhaOsBxoIwQAAQErECcAAAAAAAAiACCS1vBiwiLg5Ck9VQ3h81yc+futbXyMdQvSSfIWFo6wHAEIcgJHMEQCIHCL9BRnPQaDcCSzgwBSftiSQ1BOmPtGRbdr64yfjWKYAiAQGFxUhGPD+r9HXcdY5iDcRrg9b+KP5sNLgM8Q891y+wEoIQOmP+BFQ6jiygGUuoEa4HbrNQwHCPXgiSXbAgpZu77Pea0DdCMEsQAiAgKHsm3A/+yikYib3IwO6JLyqBKBd8XEGjer7kaAi2NKURgmFDD5VAAAgAEAAIAAAACAAAAAAAEAAAAA&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;E a enviamos:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;
error code: &lt;span class=&quot;nt&quot;&gt;-26&lt;/span&gt;
error message:
non-final
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perceba que dá erro. A mensagem &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;non-final&lt;/code&gt; indica que essa transação ainda não pode ser aceita na mempool.&lt;/p&gt;

&lt;p&gt;Esperamos a altura do bloco passar de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;271220&lt;/code&gt; e enviamos novamente:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getblockcount
271227

bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;020000000001013a0cd0343c8e69d6b491ce0a0495bb41b3bf5626ca166f144b4aff7ba4b2c88c0100000000fdffffff0148260000000000001600148dee682cdfcef9b641ca61f0833927d3d3ab9896024730440220708bf414673d06837024b38300527ed89243504e98fb4645b76beb8c9f8d6298022010185c548463c3fabf475dc758e620dc46b83d6fe28fe6c34b80cf10f3dd72fb01282103a63fe04543a8e2ca0194ba811ae076eb350c0708f5e08925db020a59bbbecf79ad03742304b174230400&quot;&lt;/span&gt;
e2b64a372d5bab18658f5ce14bc27cd6c502c7026b8bc5853462c254638603b1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Ao longo deste artigo, vimos como sair do “envia e assina” básico para montar transações &lt;strong&gt;bem estruturadas e mais seguras&lt;/strong&gt; no Bitcoin Core.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;PSBT&lt;/strong&gt; separa funções (criar, assinar, finalizar), permitindo fluxos colaborativos e ambientes offline; o &lt;strong&gt;multisig (m-de-n)&lt;/strong&gt; adiciona resiliência contra perda e comprometimento de chaves; e os &lt;strong&gt;timelocks,&lt;/strong&gt; tanto o &lt;strong&gt;nLockTime&lt;/strong&gt; (na transação) quanto o &lt;strong&gt;CLTV/CSV&lt;/strong&gt; (no script, via Miniscript), permitem impor &lt;strong&gt;quando&lt;/strong&gt; um UTXO pode ser gasto. Juntos, esses recursos formam camadas complementares: política de chaves (multisig), política de tempo (timelocks) e um formato de transporte seguro (PSBT). O resultado é um processo de envio &lt;strong&gt;auditável, reproduzível e resistente a falhas operacionais&lt;/strong&gt;, pronto para evoluir do laboratório em signet para práticas profissionais no dia a dia. &lt;em&gt;**&lt;/em&gt;&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">Transferências Avançadas e Segurança</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="en"><title type="html">Building Transactions in Bitcoin Core</title><link href="https://bitdevsmaputo.org/en/blog/building-transactions" rel="alternate" type="text/html" title="Building Transactions in Bitcoin Core" /><published>2026-10-12T00:00:00+00:00</published><updated>2026-10-12T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/en/blog/building-transactions</id><content type="html" xml:base="https://bitdevsmaputo.org/en/blog/building-transactions">&lt;h2 id=&quot;building-transactions-in-bitcoin-core&quot;&gt;Building Transactions in Bitcoin Core&lt;/h2&gt;

&lt;p&gt;by Rafael Santos&lt;/p&gt;

&lt;p&gt;In the previous article, we explored the anatomy of a Bitcoin transaction, understanding how inputs and outputs connect to the UTXO model and how Bitcoin Core can handle different levels of automation, from fully automatic creation to assembling raw transaction hex. That foundation was essential for understanding the protocol’s internal logic and seeing how each component of a transaction plays a vital role in network validation.&lt;/p&gt;

&lt;p&gt;Now, we take things a step further: the goal of this article is to &lt;strong&gt;learn how to create transactions across different types and scenarios&lt;/strong&gt;, putting manual transaction construction with Bitcoin Core into practice. We will start with simple examples and explore real-world situations, such as sending to multiple recipients (batching), creating transactions with change, consolidating UTXOs, and manually controlling fees.&lt;/p&gt;

&lt;p&gt;To master transaction creation in Bitcoin Core, it is important to go beyond the simplest case and experiment with different scenarios that reflect real-world usage. Each of these scenarios teaches us something specific about how the protocol works and how we can achieve greater control over our UTXOs and fees.&lt;/p&gt;

&lt;p&gt;In this article, we will use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regtest&lt;/code&gt; network—do not forget to configure your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bitcoin.conf&lt;/code&gt; file. You can also use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;signet&lt;/code&gt;, though you will need to wait for sBTC to arrive after requesting from a faucet.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;simple-transactions-and-the-role-of-change&quot;&gt;Simple Transactions and the Role of Change&lt;/h2&gt;

&lt;p&gt;This is the most basic example: spending a single UTXO to send funds to a single recipient. Yet even in a “simple transaction,” there are critical nuances to consider. If you do not have any UTXOs, create an address for your wallet and mine 101 blocks (to make coinbase rewards spendable):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 101 bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;First, let’s list the available UTXOs in the wallet:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;c3fef1a9764c57262ef70c2f11eb5bf548cbbcaeb7d900a77ae9ac25cb3954de&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f4d71c42d89f7c185c7c2d56a86968484c026ff6&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 50.00000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 101,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/0]024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba7)#ah5fng3d&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In this case, we have a UTXO with 50 BTC to spend. Let’s look at a few scenarios.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Sending partial funds, letting Core handle change&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose we want to send &lt;strong&gt;0.5 BTC&lt;/strong&gt; and let Core calculate the fee and generate a change address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Create the raw hex without fee or change&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction   &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;c3fef1a9764c57262ef70c2f11eb5bf548cbbcaeb7d900a77ae9ac25cb3954de&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt;   &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qkqp9xzkre29gl7kl7d3s264nstysw7fqjj5pqf&quot;:0.5}&apos;&lt;/span&gt;
0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0180f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c907792000000000

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b. Fund with automatic fee and change&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The hex generated above is passed to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fundrawtransaction&lt;/code&gt; command, which completes the transaction by adding a fee and a change output.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0180f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c907792000000000&quot;&lt;/span&gt;  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;feeRate&quot;:0.00001000}&apos;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a472700000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000141,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A new hex string is generated, now representing the complete funded transaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Sign and send&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a472700000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a4727024730440220139015403f1787b993f84616a737c4a51ac93976cae845e1bc3949a8245a21c702200fa867025026dd8a624896265bf9c44130d87c49845a4251f3917e79a042f87b0121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;signrawtransactionwithwallet&lt;/code&gt; signs the transaction, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendrawtransaction&lt;/code&gt; broadcasts it to the network.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a4727024730440220139015403f1787b993f84616a737c4a51ac93976cae845e1bc3949a8245a21c702200fa867025026dd8a624896265bf9c44130d87c49845a4251f3917e79a042f87b0121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;
1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, we mine one more block to confirm the broadcast transaction.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then we can inspect our UTXOs once again.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b260fe7dd4eac4dca8b70d58e8cff68fb3f5753a61dc0856e658bbe731736c90&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f4d71c42d89f7c185c7c2d56a86968484c026ff6&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 50.00000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 101,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/0]024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba7)#ah5fng3d&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qkqp9xzkre29gl7kl7d3s264nstysw7fqjj5pqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014b002530ac3ca8a8ffadff363056ab382c9077920&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.50000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/1]0238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d9)#8q3llhqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qln0za67dgh2ws55s0kx7wpg7t20f53e8envezx&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014fcde2eebcd45d4e852907d8de7051e5a9e9a4727&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 49.49999859,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/1/0]03f032737bcfe1ccb7cf642458916102c22386727a2e3be2f36cdc4cb6ab37c3b9)#nyyqzwmx&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/1/*)#jtyys78l&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that we now have 3 UTXOs. The first corresponds to the block reward from the mining step we just performed, so we can ignore it here. The second UTXO belongs to the address we sent the transaction to. The third is the change address generated by the transaction, containing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;49.49999859 BTC&lt;/code&gt; (the original 50 BTC minus 0.5 BTC sent minus the mining fee).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Spending the entire amount, subtracting the fee automatically&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, we want to &lt;strong&gt;send the entire UTXO balance to a single address&lt;/strong&gt; without generating a change address.&lt;/p&gt;

&lt;p&gt;Bitcoin Core allows the transaction fee to be &lt;strong&gt;deducted directly from the send amount&lt;/strong&gt;, so that the final output already accounts for the mining fee.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Create destination address&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1qkyrgk8wkau455lytvggyp5wwtds2rr2m0f5kfg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b. Send full balance, subtracting the fee&lt;/strong&gt;
We can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendtoaddress&lt;/code&gt; command with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount=true&lt;/code&gt; parameter to sweep the entire balance of a UTXO:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendtoaddress &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  bcrt1qkyrgk8wkau455lytvggyp5wwtds2rr2m0f5kfg &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  49.49999859 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 828ec7cedc36f9517bd44a8e2a813be906698125c7c80b9a71a3202f2c09438c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;The amount of &lt;strong&gt;49.49999859 BTC&lt;/strong&gt; corresponds to the &lt;strong&gt;change UTXO&lt;/strong&gt; we received in the previous scenario.&lt;/li&gt;
  &lt;li&gt;The final argument &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; deducts the mining fee from this amount, preventing Core from creating a change address.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The command output returns the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid&lt;/code&gt; of the new transaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Confirm in a block&lt;/strong&gt;
Next, we mine another block to confirm the transaction.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;d. Check the resulting UTXO&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally, we can verify with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listunspent&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;828ec7cedc36f9517bd44a8e2a813be906698125c7c80b9a71a3202f2c09438c&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qkyrgk8wkau455lytvggyp5wwtds2rr2m0f5kfg&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014b1068b1dd6ef2b4a7c8b621040d1ce5b60a18d5b&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 49.49998759,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/3]02759296d087fc8a6746c5949ccf44fb8c1ec84fd2898f0b3d636a1fb861f279e8)#grjvnzy9&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that we now have a new UTXO/txid with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;49.49998759&lt;/code&gt; BTC (49.49999859 BTC from the original UTXO minus 0.000011 BTC in fees).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Spending the entire amount with manual fee control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this case, we want to send the &lt;strong&gt;entire UTXO balance&lt;/strong&gt; to a single address &lt;strong&gt;without creating change&lt;/strong&gt;, but &lt;strong&gt;setting the fee ourselves&lt;/strong&gt; rather than having Core deduct it automatically.&lt;/p&gt;

&lt;p&gt;The logic is simple: &lt;strong&gt;output value = input value - desired fee&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Thus, the difference between input and output is precisely the fee, and no change address is needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Prepare destination address&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1qnpsadfag5mupmjyq3j8ksrr7rzxz6uawmpfuyk&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b. Calculate the send amount&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose the available UTXO has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;49.49998759&lt;/code&gt; &lt;strong&gt;BTC&lt;/strong&gt; (the UTXO from Scenario 2) and we want to pay a fee of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.0001&lt;/code&gt; &lt;strong&gt;BTC&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;VALUE -&amp;gt; 49.49998759 - 0.0001
&lt;span class=&quot;c&quot;&gt;# 49.49988759&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;c. Create the raw transaction with the fee already deducted&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;828ec7cedc36f9517bd44a8e2a813be906698125c7c80b9a71a3202f2c09438c&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qnpsadfag5mupmjyq3j8ksrr7rzxz6uawmpfuyk&quot;:49.49988759}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 02000000018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae00000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The command returns a &lt;strong&gt;raw hex&lt;/strong&gt; that leaves no room for change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d. Sign&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;02000000018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae00000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;020000000001018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae0247304402200a243753e4417acd396221ef6461adf023b2c6b29a3fde1c87311c6bfc2863140220322ab5d37b10cf336c6f9ef4d504dfa7a7b1b5280680b790d0be42e7662ca1de012102759296d087fc8a6746c5949ccf44fb8c1ec84fd2898f0b3d636a1fb861f279e800000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;e. Send and confirm&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;020000000001018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae0247304402200a243753e4417acd396221ef6461adf023b2c6b29a3fde1c87311c6bfc2863140220322ab5d37b10cf336c6f9ef4d504dfa7a7b1b5280680b790d0be42e7662ca1de012102759296d087fc8a6746c5949ccf44fb8c1ec84fd2898f0b3d636a1fb861f279e800000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 647c2b177ddeeb222e339e69a3237bdaca71aad881a6a81d74591c6a120934b4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;f. Verify the new UTXO&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;647c2b177ddeeb222e339e69a3237bdaca71aad881a6a81d74591c6a120934b4&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qnpsadfag5mupmjyq3j8ksrr7rzxz6uawmpfuyk&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 49.49988759,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/4]03df6d57b8af03faf7ff2aeee55347c397ea08756403d88d5d2981e546529939e8)#9xz6j0nm&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Throughout these three scenarios, we have seen that even in a “simple” transaction, &lt;strong&gt;change&lt;/strong&gt; is the crucial detail separating a safe operation from a costly mistake:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Scenario 1&lt;/strong&gt; — Partial spend: Core automatically creates a change address and calculates the fee.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Scenario 2&lt;/strong&gt; — Full sweep with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount&lt;/code&gt;: Core deducts the fee directly from the output, avoiding change.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Scenario 3&lt;/strong&gt; — Full sweep with manual fee: you explicitly set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;input - output = fee&lt;/code&gt;, with no change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;If you ignore change&lt;/strong&gt;—for example, by calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createrawtransaction&lt;/code&gt; where the sum of outputs is less than the sum of inputs and &lt;strong&gt;you neither add a change output nor use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount&lt;/code&gt;—the entire difference becomes the miner fee&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;On mainnet, this could mean losing a significant number of satoshis (or entire bitcoins) in a single transaction.&lt;/p&gt;

&lt;p&gt;Therefore, always ask yourself before signing and broadcasting:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Do the &lt;strong&gt;outputs add up to exactly what I expect?&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Am I letting Core handle the change, or did I manually adjust the output to account for the intended fee?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this simple check, you ensure that every single satoshi goes to the right destination and avoid accidentally handing over the remainder to miners as an unintended fee.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;multi-output-transactions-batching&quot;&gt;&lt;strong&gt;Multi-Output Transactions (Batching)&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;A standard best practice for saving on fees and block space is sending funds to &lt;strong&gt;multiple recipients within a single transaction&lt;/strong&gt;. This technique is known as &lt;strong&gt;batching&lt;/strong&gt; and is widely adopted by exchanges and payment processors.&lt;/p&gt;

&lt;p&gt;Instead of broadcasting separate transactions for each payout, we combine all outputs into a single raw transaction. The result is a &lt;strong&gt;single input&lt;/strong&gt; (or a few selected inputs) funding &lt;strong&gt;multiple outputs&lt;/strong&gt;, drastically lowering the overall fee because Bitcoin fees depend on transaction weight in virtual bytes (vbytes), not the monetary value transferred.&lt;/p&gt;

&lt;p&gt;Let’s look at a practical walkthrough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Prepare destination addresses&lt;/strong&gt;
Let’s generate two addresses to simulate different recipients:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n (Kaká)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks (Carol)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Suppose we have a UTXO of &lt;strong&gt;49.49988759 BTC&lt;/strong&gt; (the output from the previous scenario).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. Create the raw transaction with multiple outputs&lt;/strong&gt;
We assign an amount for each recipient, for example:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Kaká: &lt;strong&gt;0.7 BTC&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Carol: &lt;strong&gt;1.2 BTC&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction   &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;647c2b177ddeeb222e339e69a3237bdaca71aad881a6a81d74591c6a120934b4&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n&quot;:0.7,
    &quot;bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks&quot;:1.2}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff02801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command creates the &lt;strong&gt;raw hex&lt;/strong&gt; with &lt;strong&gt;two outputs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Fund with fee and change&lt;/strong&gt;
Since we are sending only 1.9 BTC out of the total, we need Core to calculate the fee and create a change address for the remaining balance.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff02801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;&apos;{&quot;feeRate&quot;:0.00001000}&apos;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000172,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;d. Sign and send&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6402473044022070655be3c7e287e70b81a4e928abd20d02fc5fc264f9111a52c0094c392c4dc802203920cb46a11bbe08d8dcc9de5b8412b5556a62cd6ead46ca0786d78d31ee6e63012103df6d57b8af03faf7ff2aeee55347c397ea08756403d88d5d2981e546529939e800000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6402473044022070655be3c7e287e70b81a4e928abd20d02fc5fc264f9111a52c0094c392c4dc802203920cb46a11bbe08d8dcc9de5b8412b5556a62cd6ead46ca0786d78d31ee6e63012103df6d57b8af03faf7ff2aeee55347c397ea08756403d88d5d2981e546529939e800000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;e. Confirm and inspect&lt;/strong&gt;
Mine a block to confirm:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;List the UTXOs:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.70000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/5]039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f2)#duqx02j9&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q5udtjs5h2u7pxrtw5tu65fgy0ypl2au8rkfg62&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014a71ab94297573c130d6ea2f9aa25047903f57787&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 47.59988587,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/1/3]022a3cae7145dcfe74772d35b16fdb40e5fe0cf8fc3950eb5b9048a2b70d271e6f)#7uhj7gdg&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/1/*)#jtyys78l&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 2,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba64&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 1.20000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/6]037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f)#ax5l0vfn&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You will see &lt;strong&gt;three outputs&lt;/strong&gt; (in addition to others not relevant here):&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;0.7 BTC&lt;/strong&gt; to Kaká&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1.2 BTC&lt;/strong&gt; to Carol&lt;/li&gt;
  &lt;li&gt;The &lt;strong&gt;change&lt;/strong&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;47.59988587&lt;/code&gt;) back to your wallet.&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Why does batching save fees?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you created two separate transactions—one for 0.7 BTC and another for 1.2 BTC—you would pay base transaction overhead &lt;strong&gt;twice&lt;/strong&gt;, including two transaction headers, input signatures, and separate change outputs.&lt;/p&gt;

&lt;p&gt;In transaction batching, the majority of transaction size comes from inputs; adding extra outputs has a much lower marginal byte cost.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;utxo-consolidation&quot;&gt;&lt;strong&gt;UTXO Consolidation&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Consolidation&lt;/strong&gt; means combining multiple smaller UTXOs into a single, larger UTXO.
&lt;strong&gt;Advantages:&lt;/strong&gt; Future transactions will require fewer inputs (making them cheaper) and wallet state remains cleaner.
&lt;strong&gt;Caution:&lt;/strong&gt; Consolidation links those UTXOs together on-chain, creating a direct privacy impact (common-input ownership heuristic). Avoid co-mingling KYC and non-KYC funds, and schedule consolidations during periods of low mempool fee rates.&lt;/p&gt;

&lt;p&gt;Let’s walk through a step-by-step guide to consolidating UTXOs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a) Identify small UTXOs&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.70000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/5]039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f2)#duqx02j9&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 2,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba64&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 1.20000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/6]037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f)#ax5l0vfn&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qkqp9xzkre29gl7kl7d3s264nstysw7fqjj5pqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014b002530ac3ca8a8ffadff363056ab382c9077920&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.50000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 4,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/1]0238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d9)#8q3llhqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  ...
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Suppose we select these &lt;strong&gt;three UTXOs&lt;/strong&gt; from the previous examples:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout:0&lt;/code&gt;, &lt;strong&gt;0.70000000 BTC&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;B: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout:2&lt;/code&gt;, &lt;strong&gt;1.20000000 BTC&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;C: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid 1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout:0&lt;/code&gt;, &lt;strong&gt;0.50000000 BTC&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;&lt;strong&gt;Total = 2.40000000 BTC&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;b) Generate a wallet address to receive the consolidated funds&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Option 1 — Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fundrawtransaction&lt;/code&gt; (no change via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractFeeFromOutputs&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Simpler approach: you specify the &lt;strong&gt;total&lt;/strong&gt; on the output and instruct Core to &lt;strong&gt;deduct the fee from that output&lt;/strong&gt;, avoiding any change creation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create the raw hex with 3 inputs and 1 output (2.4 BTC)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;,&quot;vout&quot;:0},{&quot;txid&quot;:&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;,&quot;vout&quot;:2},{&quot;txid&quot;:&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;:2.4}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff01001c4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Fund: fee and no change&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff01001c4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;add_inputs&quot;:false, &quot;feeRate&quot;:0.00001000, &quot;subtractFeeFromOutputs&quot;:[0]}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000245,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: &lt;span class=&quot;nt&quot;&gt;-1&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A &lt;strong&gt;changepos&lt;/strong&gt; value of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-1&lt;/code&gt; indicates that no change output was created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Sign and send&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402203664d96a5f91c916e213e9a6adabda0c4a2031abe9db7e1a8f2f996f9fdbad91022070ea8353ce9281456776f5e723c48c1aa022a4adb35a207f9644c0338d95c6310121039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f20247304402203c350e5bd7a9a69fde895df1ae95d6935383c7ac7554f53ac10437391d45d3fd02202fbfc490b365afe774bb4771650ec9bb81e813a6df547e523ed9bacf4fa1d6f50121037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f0247304402206e422304d7a85fb96a9624c532cabd2ae0354711554410b7360cff55df14a57e02202bdbd8fb1983d5d3f24f859f735c11b174bfea9a5b813e77e8a9734047620a7001210238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d900000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402203664d96a5f91c916e213e9a6adabda0c4a2031abe9db7e1a8f2f996f9fdbad91022070ea8353ce9281456776f5e723c48c1aa022a4adb35a207f9644c0338d95c6310121039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f20247304402203c350e5bd7a9a69fde895df1ae95d6935383c7ac7554f53ac10437391d45d3fd02202fbfc490b365afe774bb4771650ec9bb81e813a6df547e523ed9bacf4fa1d6f50121037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f0247304402206e422304d7a85fb96a9624c532cabd2ae0354711554410b7360cff55df14a57e02202bdbd8fb1983d5d3f24f859f735c11b174bfea9a5b813e77e8a9734047620a7001210238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d900000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 61db943161c00e8cf797cb8d4e3d896e88f52c8e39490e735d70abaa6a74ce73&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;4. Confirm and inspect the single consolidated UTXO&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;61db943161c00e8cf797cb8d4e3d896e88f52c8e39490e735d70abaa6a74ce73&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c1&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 2.39999755,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/7]02b1f28fe1718cb0d19d63ca8f00f1da97a9ca6a2f2fe58ea38dc8764271fd9bb9)#v6xev5z7&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that we now have a single UTXO containing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.39999755&lt;/code&gt; BTC (2.4 consolidated BTC minus the mining fee).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 2 — Full manual control (without &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fundrawtransaction&lt;/code&gt;)&lt;/strong&gt;
We can specify our own fee directly and set the output value as &lt;strong&gt;sum(inputs) - fee&lt;/strong&gt; (leaving no change). In this scenario, we will consolidate 3 UTXOs received from mining rewards in previous examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Calculate the output amount&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;VALUE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;150-&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.0001&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;VALUE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;149.9999
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Create the raw transaction with no change output&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;347775cd427f4e7b88906ce5ca8c11570822063c76280cc2e63879e6ed956323&quot;,&quot;vout&quot;:0},{&quot;txid&quot;:&quot;cebd41bfe9964f604f7247ee0c27a1bec23a55880c5be1c91b3889f4e2277808&quot;,&quot;vout&quot;:0},{&quot;txid&quot;:&quot;1a2c538fb7b78a8898ddc82b79dd593922d402153c7ff97491e539a91b57fde7&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;:149.9999}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 0200000003236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. Sign, send, and confirm&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000003236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402204aa694a69c037ab059f75affd9db353cc2d54438c2d22d0a69f5996ae4e3b4d302205ea15356e49c0ae44ba9e110e3e0ff1f83b76943ace7d62171e6fa7e70154b190121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202ceef57fb7564c5108dfcadb719b6dfc34747ec30b13fe2c306bb76ee73902c30220349cbc0e130f446bc0313afe0502850e792d3e0edc08d198f89091b04607d4b90121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202c56c84d7bc2bdac40cfb9d3baea64e23193fb9145cd1da9737795c4553991e002205d7ec73eff147ac9903057abe1ff78fe54cdcc63f8270a52810dd3c44d86ab390121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402204aa694a69c037ab059f75affd9db353cc2d54438c2d22d0a69f5996ae4e3b4d302205ea15356e49c0ae44ba9e110e3e0ff1f83b76943ace7d62171e6fa7e70154b190121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202ceef57fb7564c5108dfcadb719b6dfc34747ec30b13fe2c306bb76ee73902c30220349cbc0e130f446bc0313afe0502850e792d3e0edc08d198f89091b04607d4b90121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202c56c84d7bc2bdac40cfb9d3baea64e23193fb9145cd1da9737795c4553991e002205d7ec73eff147ac9903057abe1ff78fe54cdcc63f8270a52810dd3c44d86ab390121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402204aa694a69c037ab059f75affd9db353cc2d54438c2d22d0a69f5996ae4e3b4d302205ea15356e49c0ae44ba9e110e3e0ff1f83b76943ace7d62171e6fa7e70154b190121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202ceef57fb7564c5108dfcadb719b6dfc34747ec30b13fe2c306bb76ee73902c30220349cbc0e130f446bc0313afe0502850e792d3e0edc08d198f89091b04607d4b90121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202c56c84d7bc2bdac40cfb9d3baea64e23193fb9145cd1da9737795c4553991e002205d7ec73eff147ac9903057abe1ff78fe54cdcc63f8270a52810dd3c44d86ab390121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 2c668e312971983fc465d8c79f5813732f288331cda23dd86fd73fc5339e2984&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can list our UTXOs to verify the consolidation.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;2c668e312971983fc465d8c79f5813732f288331cda23dd86fd73fc5339e2984&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c1&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 149.99990000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/7]02b1f28fe1718cb0d19d63ca8f00f1da97a9ca6a2f2fe58ea38dc8764271fd9bb9)#v6xev5z7&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that we now have a single UTXO containing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;149.99990000&lt;/code&gt; BTC.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Constructing transactions manually in Bitcoin Core is far more than an intellectual exercise: it is a &lt;strong&gt;hands-on laboratory for understanding the protocol&lt;/strong&gt;. Throughout this article, we covered scenarios ranging from basic sends with automatic change handling to more advanced strategies such as &lt;strong&gt;batching&lt;/strong&gt; and &lt;strong&gt;UTXO consolidation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These examples highlight several essential truths:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Every satoshi matters&lt;/strong&gt; — neglecting fee calculations or change output definitions can turn an oversight into an exorbitant miner fee.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Control is power&lt;/strong&gt; — manually selecting inputs, determining fee rates, and deciding when to consolidate UTXOs allows you to minimize on-chain expenses and keep your wallet orderly.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Privacy requires deliberate planning&lt;/strong&gt; — consolidating or co-spending UTXOs reveals common-ownership links across addresses. In production environments, always pair these techniques with solid privacy practices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Practicing these commands on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regtest&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;signet&lt;/code&gt; provides the safety of a sandbox, but the knowledge translates directly to &lt;strong&gt;mainnet&lt;/strong&gt;. Before broadcasting transactions with real funds, always verify:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Sum of outputs vs. inputs&lt;/strong&gt; — ensure the discrepancy equals your intended mining fee.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Change destination&lt;/strong&gt; — verify the change address is under your control, or use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount&lt;/code&gt; when sweeping outputs.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Mempool fee rates&lt;/strong&gt; — adjust fees according to current network congestion to balance cost and confirmation priority.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Mastering these workflows gives you not only the confidence to operate directly on the Bitcoin network, but also a &lt;strong&gt;profound understanding of the UTXO model&lt;/strong&gt; that powers it.&lt;/p&gt;

&lt;p&gt;In subsequent articles, we will explore advanced transaction techniques including &lt;strong&gt;Partially Signed Bitcoin Transactions (PSBTs)&lt;/strong&gt;, &lt;strong&gt;multisig wallets&lt;/strong&gt;, and &lt;strong&gt;timelocks&lt;/strong&gt;.&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">Building Transactions in Bitcoin Core</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="pt"><title type="html">Construindo Transações no Bitcoin Core</title><link href="https://bitdevsmaputo.org/pt/blog/construindo-transacoes" rel="alternate" type="text/html" title="Construindo Transações no Bitcoin Core" /><published>2026-10-12T00:00:00+00:00</published><updated>2026-10-12T00:00:00+00:00</updated><id>https://bitdevsmaputo.org/pt/blog/construindo-transacoes</id><content type="html" xml:base="https://bitdevsmaputo.org/pt/blog/construindo-transacoes">&lt;h2 id=&quot;construindo-transações-no-bitcoin-core&quot;&gt;Construindo Transações no Bitcoin Core&lt;/h2&gt;

&lt;p&gt;por Rafael Santos&lt;/p&gt;

&lt;p&gt;No artigo anterior exploramos a anatomia de uma transação no Bitcoin, entendendo como os inputs e outputs se conectam ao modelo UTXO e como o Bitcoin Core pode lidar com diferentes níveis de automação, desde a criação totalmente automática até a montagem bruta de um hex. Essa visão foi essencial para compreender a lógica interna do protocolo e perceber como cada parte da transação tem um papel fundamental na validação pela rede.&lt;/p&gt;

&lt;p&gt;Agora, daremos um passo além: o objetivo deste artigo é &lt;strong&gt;aprender a criar transações de diferentes tipos e cenários&lt;/strong&gt;, colocando em prática a construção manual com o Bitcoin Core. Vamos começar com exemplos simples e explorar situações reais, como o envio para múltiplos destinatários (batching), a criação de transações com troco, a consolidação de UTXOs e o controle manual das taxas.&lt;/p&gt;

&lt;p&gt;Para dominar a criação de transações no Bitcoin Core, é importante ir além do caso mais simples e experimentar diferentes cenários que refletem situações reais de uso. Cada um deles pode nos ensinar algo específico sobre como o protocolo funciona e como podemos ter maior controle sobre nossos UTXOs e taxas.&lt;/p&gt;

&lt;p&gt;Utilizaremos nesse artigo a rede &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regtest&lt;/code&gt;, nao esqueça de configurar o arquivo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bitcoin.conf&lt;/code&gt;. Você pode usar a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;signet&lt;/code&gt; também, apenas vai ter que esperar os sBTC entrarem depois de solicitar no faucet.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;transação-simples-e-o-papel-do-troco&quot;&gt;Transação simples e o papel do troco&lt;/h2&gt;

&lt;p&gt;Esse é o exemplo mais básico: gastar um único UTXO para enviar fundos a apenas um destinatário. Mas mesmo na “transação simples”, temos nuances importantes a considerar. Caso não tenha nenhum UTXO, crie um endereço para sua carteira e minere 101 blocos (pra tornar gastável):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 101 bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Agora, em primeiro lugar, listamos os UTXOs disponíveis na carteira:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;c3fef1a9764c57262ef70c2f11eb5bf548cbbcaeb7d900a77ae9ac25cb3954de&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f4d71c42d89f7c185c7c2d56a86968484c026ff6&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 50.00000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 101,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/0]024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba7)#ah5fng3d&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Neste caso, temos um UTXO com 50 BTCs para gastar. Vamos ver alguns cenários.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Enviar parte do valor, deixando o Core criar troco&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Aqui vamos supor que queremos mandar &lt;strong&gt;0.5 BTC&lt;/strong&gt; e deixar o Core calcular taxa e gerar endereço de troco.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Criar o hex bruto sem taxa nem troco&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction   &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;c3fef1a9764c57262ef70c2f11eb5bf548cbbcaeb7d900a77ae9ac25cb3954de&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt;   &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qkqp9xzkre29gl7kl7d3s264nstysw7fqjj5pqf&quot;:0.5}&apos;&lt;/span&gt;
0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0180f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c907792000000000

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b. Completar com taxa e troco automático&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Esse Hex gerado acima é utilizado no comando fundrawtransaction, que completa a transação com a taxa e o troco.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0180f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c907792000000000&quot;&lt;/span&gt;  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;feeRate&quot;:0.00001000}&apos;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a472700000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000141,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Um novo valor Hex é gerado, agora representado a transação completa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Assinar e enviar&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000001de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a472700000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a4727024730440220139015403f1787b993f84616a737c4a51ac93976cae845e1bc3949a8245a21c702200fa867025026dd8a624896265bf9c44130d87c49845a4251f3917e79a042f87b0121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;signrawtransactionwithwallet&lt;/code&gt; assina a transação e o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendrawtransaction&lt;/code&gt; envia para a rede.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101de5439cb25ace97aa700d9b7aebccb48f55beb112f0cf72e26574c76a9f1fec30000000000fdffffff0280f0fa0200000000160014b002530ac3ca8a8ffadff363056ab382c9077920f3000b2701000000160014fcde2eebcd45d4e852907d8de7051e5a9e9a4727024730440220139015403f1787b993f84616a737c4a51ac93976cae845e1bc3949a8245a21c702200fa867025026dd8a624896265bf9c44130d87c49845a4251f3917e79a042f87b0121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;
1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Logo após, mineramos mais um bloco para confirmar a transação enviada.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Então podemos observar nosso UTXO mais uma vez.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b260fe7dd4eac4dca8b70d58e8cff68fb3f5753a61dc0856e658bbe731736c90&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7nt3cskcna7pshru94t2s6tgfpxqymlkp0eh6p&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f4d71c42d89f7c185c7c2d56a86968484c026ff6&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 50.00000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 101,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/0]024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba7)#ah5fng3d&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qkqp9xzkre29gl7kl7d3s264nstysw7fqjj5pqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014b002530ac3ca8a8ffadff363056ab382c9077920&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.50000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/1]0238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d9)#8q3llhqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qln0za67dgh2ws55s0kx7wpg7t20f53e8envezx&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014fcde2eebcd45d4e852907d8de7051e5a9e9a4727&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 49.49999859,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/1/0]03f032737bcfe1ccb7cf642458916102c22386727a2e3be2f36cdc4cb6ab37c3b9)#nyyqzwmx&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/1/*)#jtyys78l&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perceba que temos 3 UTXO, o primeiro é referente a recompensa dessa nova mineração que acabamos de fazer, então podemos ignorar aqui. O segundo UTXO é referente ao endereço pra qual mandamos a transação. Já o terceiro, é o endereço de troco gerado na transação, e possui &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;49.49999859 BTC&lt;/code&gt; (50 dos BTC originais - 0,5 enviados - taxa).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Gastar todo o valor, subtraindo a taxa automaticamente&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Neste caso, queremos &lt;strong&gt;enviar todo o saldo do UTXO para um único endereço&lt;/strong&gt;, sem gerar endereço de troco.&lt;/p&gt;

&lt;p&gt;O Bitcoin Core permite que a própria taxa seja &lt;strong&gt;descontada do valor de envio&lt;/strong&gt;, de forma que o output final já considere a taxa de mineração.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Criar endereço de destino&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;#bcrt1qkyrgk8wkau455lytvggyp5wwtds2rr2m0f5kfg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b. Enviar todo o saldo, subtraindo a taxa&lt;/strong&gt;
Podemos usar o comando &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendtoaddress&lt;/code&gt; com o parâmetro &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount=true&lt;/code&gt; para enviar todo saldo de um UTXO:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendtoaddress &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  bcrt1qkyrgk8wkau455lytvggyp5wwtds2rr2m0f5kfg &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  49.49999859 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#828ec7cedc36f9517bd44a8e2a813be906698125c7c80b9a71a3202f2c09438c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;O valor de &lt;strong&gt;49.49999859 BTC&lt;/strong&gt; corresponde ao &lt;strong&gt;UTXO de troco&lt;/strong&gt; que recebemos no cenário anterior.&lt;/li&gt;
  &lt;li&gt;O último argumento &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; faz com que a taxa de mineração seja descontada desse valor, evitando que o Core crie um endereço de troco.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A saída do comando já retorna o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid&lt;/code&gt; da nova transação.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d. Confirmar em bloco&lt;/strong&gt;
Em seguida podemos minerar novamente para confirmar em um bloco.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;e. Checar UTXO resultante&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Por fim, podemos conferir com o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listunspent&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;828ec7cedc36f9517bd44a8e2a813be906698125c7c80b9a71a3202f2c09438c&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qkyrgk8wkau455lytvggyp5wwtds2rr2m0f5kfg&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014b1068b1dd6ef2b4a7c8b621040d1ce5b60a18d5b&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 49.49998759,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/3]02759296d087fc8a6746c5949ccf44fb8c1ec84fd2898f0b3d636a1fb861f279e8)#grjvnzy9&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note que agora temos um novo UTXO/txid com &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;49.49998759&lt;/code&gt; BTC (49.49999859 BTC do UTXO Original - 0,000011 BTC da taxa).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Gastar todo o valor ajustando a taxa manualmente&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Neste caso, queremos enviar &lt;strong&gt;todo o saldo de um UTXO&lt;/strong&gt; para um único endereço &lt;strong&gt;sem gerar troco&lt;/strong&gt;, mas &lt;strong&gt;definindo nós mesmos a taxa&lt;/strong&gt; em vez de deixar o Core subtrair automaticamente.&lt;/p&gt;

&lt;p&gt;A lógica é simples: &lt;strong&gt;valor do output = valor do input – taxa desejada&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Assim, a diferença entre entrada e saída é exatamente a taxa, e nenhum endereço de troco é necessário.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Preparar o endereço de destino&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1qnpsadfag5mupmjyq3j8ksrr7rzxz6uawmpfuyk&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;b. Calcular o valor de envio&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suponha que o UTXO disponível seja de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;49.49998759&lt;/code&gt; &lt;strong&gt;BTC&lt;/strong&gt; (UTXO do cenário 2) e queremos pagar uma taxa de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.0001&lt;/code&gt; &lt;strong&gt;BTC&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;VALOR -&amp;gt; 49.49998759 - 0.0001
&lt;span class=&quot;c&quot;&gt;# 49.49988759&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;c. Criar a transação bruta com valor já descontado&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;828ec7cedc36f9517bd44a8e2a813be906698125c7c80b9a71a3202f2c09438c&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qnpsadfag5mupmjyq3j8ksrr7rzxz6uawmpfuyk&quot;:49.49988759}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 02000000018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae00000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O comando retorna um &lt;strong&gt;hex bruto&lt;/strong&gt; que já não terá espaço para troco.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d. Assinar&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;02000000018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae00000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;020000000001018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae0247304402200a243753e4417acd396221ef6461adf023b2c6b29a3fde1c87311c6bfc2863140220322ab5d37b10cf336c6f9ef4d504dfa7a7b1b5280680b790d0be42e7662ca1de012102759296d087fc8a6746c5949ccf44fb8c1ec84fd2898f0b3d636a1fb861f279e800000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;e. Enviar e confirmar&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;020000000001018c43092c2f20a3719a0bc8c725816906e93b812a8e4ad47b51f936dccec78e820000000000fdffffff0197d50a27010000001600149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae0247304402200a243753e4417acd396221ef6461adf023b2c6b29a3fde1c87311c6bfc2863140220322ab5d37b10cf336c6f9ef4d504dfa7a7b1b5280680b790d0be42e7662ca1de012102759296d087fc8a6746c5949ccf44fb8c1ec84fd2898f0b3d636a1fb861f279e800000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 647c2b177ddeeb222e339e69a3237bdaca71aad881a6a81d74591c6a120934b4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;f. Conferir o novo UTXO&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;647c2b177ddeeb222e339e69a3237bdaca71aad881a6a81d74591c6a120934b4&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qnpsadfag5mupmjyq3j8ksrr7rzxz6uawmpfuyk&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00149861d6a7a8a6f81dc8808c8f680c7e188c2d73ae&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 49.49988759,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/4]03df6d57b8af03faf7ff2aeee55347c397ea08756403d88d5d2981e546529939e8)#9xz6j0nm&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Ao longo desses três cenários vimos que, mesmo em uma transação “simples”, o &lt;strong&gt;troco&lt;/strong&gt; é o detalhe que separa uma operação segura de um erro caro:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Cenário 1&lt;/strong&gt; – Envio parcial: o Core cria automaticamente um endereço de troco e calcula a taxa.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Cenário 2&lt;/strong&gt; – Envio total com &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount&lt;/code&gt;: o Core deduz a taxa do próprio output, evitando troco.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Cenário 3&lt;/strong&gt; – Envio total com taxa manual: você mesmo define &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;input – output = taxa&lt;/code&gt;, sem troco.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Se você ignora o troco&lt;/strong&gt;, por exemplo, cria um &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createrawtransaction&lt;/code&gt; onde a soma dos outputs é menor que a soma dos inputs e &lt;strong&gt;não adiciona nem troco nem &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount,&lt;/code&gt; toda a diferença vira taxa de mineração&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Em mainnet isso pode significar perder muitos satoshis (ou bitcoins) em uma única transação.&lt;/p&gt;

&lt;p&gt;Por isso, sempre se pergunte antes de assinar e transmitir:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Os &lt;strong&gt;outputs somam exatamente o que eu espero?&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Estou deixando o Core cuidar do troco ou ajustei o valor manualmente para a taxa desejada?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Com essa checagem simples, você garante que cada satoshi vá para o destino certo e evita que “o resto” acabe nas mãos dos mineradores como taxa involuntária.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;transação-com-múltiplos-outputs-batching&quot;&gt;&lt;strong&gt;Transação com múltiplos outputs (batching)&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Uma prática comum para economizar taxas e espaço em bloco é enviar fundos para &lt;strong&gt;vários destinatários dentro de uma única transação&lt;/strong&gt;. Esse método é conhecido como &lt;strong&gt;batching&lt;/strong&gt; e é amplamente utilizado por exchanges e serviços de pagamento.&lt;/p&gt;

&lt;p&gt;Em vez de criar várias transações, uma para cada pagamento, reunimos todos os outputs em um só &lt;em&gt;raw transaction&lt;/em&gt;. O resultado é um &lt;strong&gt;único input&lt;/strong&gt; (ou alguns inputs selecionados) alimentando &lt;strong&gt;vários outputs&lt;/strong&gt;, reduzindo a taxa total, pois ela depende principalmente do tamanho em vbytes e não do valor transferido.&lt;/p&gt;

&lt;p&gt;Vamos ver em um caso prático.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Preparar os endereços de destino&lt;/strong&gt;
Vamos criar dois endereços para simular destinatários diferentes:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n (Kaká)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks (Carol)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Suponha que temos um UTXO de &lt;strong&gt;49.49988759 BTC&lt;/strong&gt; (resultado do cenário anterior).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. Criar a transação bruta com múltiplos outputs&lt;/strong&gt;
Definimos um valor para cada destinatário, por exemplo:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Kaká: &lt;strong&gt;0.7 BTC&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Carol: &lt;strong&gt;1.2 BTC&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction   &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;647c2b177ddeeb222e339e69a3237bdaca71aad881a6a81d74591c6a120934b4&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n&quot;:0.7,
    &quot;bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks&quot;:1.2}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff02801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Esse comando cria o &lt;strong&gt;hex bruto&lt;/strong&gt; com &lt;strong&gt;dois outputs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Completar com taxa e troco&lt;/strong&gt;
Como estamos enviando apenas 1.9 BTC do total, precisamos que o Core calcule a taxa e crie o endereço de troco para o restante.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff02801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;&apos;{&quot;feeRate&quot;:0.00001000}&apos;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000172,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: 1
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;d. Assinar e enviar&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000001b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6400000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6402473044022070655be3c7e287e70b81a4e928abd20d02fc5fc264f9111a52c0094c392c4dc802203920cb46a11bbe08d8dcc9de5b8412b5556a62cd6ead46ca0786d78d31ee6e63012103df6d57b8af03faf7ff2aeee55347c397ea08756403d88d5d2981e546529939e800000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000101b43409126a1c59741da8a681d8aa71cada7b23a3699e332e22ebde7d172b7c640000000000fdffffff03801d2c0400000000160014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d876ba9b71b01000000160014a71ab94297573c130d6ea2f9aa25047903f57787000e270700000000160014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba6402473044022070655be3c7e287e70b81a4e928abd20d02fc5fc264f9111a52c0094c392c4dc802203920cb46a11bbe08d8dcc9de5b8412b5556a62cd6ead46ca0786d78d31ee6e63012103df6d57b8af03faf7ff2aeee55347c397ea08756403d88d5d2981e546529939e800000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;e. Confirmar e inspecionar&lt;/strong&gt;
Minerar um bloco para confirmar:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Liste os UTXOs:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.70000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/5]039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f2)#duqx02j9&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q5udtjs5h2u7pxrtw5tu65fgy0ypl2au8rkfg62&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014a71ab94297573c130d6ea2f9aa25047903f57787&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 47.59988587,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/1/3]022a3cae7145dcfe74772d35b16fdb40e5fe0cf8fc3950eb5b9048a2b70d271e6f)#7uhj7gdg&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/1/*)#jtyys78l&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 2,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba64&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 1.20000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/6]037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f)#ax5l0vfn&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Você verá &lt;strong&gt;três outputs&lt;/strong&gt; (além de outros que não nos interessante aqui):&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;0.7 BTC&lt;/strong&gt; para Kaká&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1.2 BTC&lt;/strong&gt; para Carol&lt;/li&gt;
  &lt;li&gt;O &lt;strong&gt;troco&lt;/strong&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;47.59988587&lt;/code&gt;) de volta para a sua carteira.&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Por que o batching economiza?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Se você criasse duas transações separadas, uma de 0.7 BTC e outra de 1.2 BTC, pagaria taxa &lt;strong&gt;duas vezes&lt;/strong&gt; e criaria dois cabeçalhos, duas assinaturas etc.&lt;/p&gt;

&lt;p&gt;No batching, a maior parte do tamanho da transação está nos inputs; aumentar apenas os outputs tem custo marginal bem menor.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;consolidação-de-utxos&quot;&gt;&lt;strong&gt;Consolidação de UTXOs&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Consolidar&lt;/strong&gt; é juntar vários UTXOs pequenos em um único UTXO maior.
&lt;strong&gt;Vantagens:&lt;/strong&gt; transações futuras com menos inputs (mais baratas) e carteira mais simples.
&lt;strong&gt;Cuidado:&lt;/strong&gt; consolidação liga aqueles UTXOs entre si (impacto de privacidade). Evite misturar KYC/non-KYC e prefira fazer quando as taxas estão baixas.&lt;/p&gt;

&lt;p&gt;Vamos a um passo-a-passo para consolidar UTXOs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a) Identificar UTXOs pequenos&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1q7waheqekh39xlscz5ct28dqhhhh0u8v8nwh42n&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014f3bb7c8336bc4a6fc302a616a3b417bdeefe1d87&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.70000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/5]039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f2)#duqx02j9&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 2,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qllxahh4su69rszmyjr93y3t07h57nwny0j95ks&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014ffcddbdeb0e68a380b6490cb12456ff5e9e9ba64&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 1.20000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/6]037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f)#ax5l0vfn&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qkqp9xzkre29gl7kl7d3s264nstysw7fqjj5pqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0014b002530ac3ca8a8ffadff363056ab382c9077920&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 0.50000000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 4,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/1]0238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d9)#8q3llhqf&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  ...
&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Suponha que escolhemos esses &lt;strong&gt;três UTXOs&lt;/strong&gt; resultantes dos exemplos anteriores:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout:0&lt;/code&gt;, &lt;strong&gt;0.70000000 BTC&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;B: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout:2&lt;/code&gt;, &lt;strong&gt;1.20000000 BTC&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;C: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txid 1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vout:0&lt;/code&gt;, &lt;strong&gt;0.50000000 BTC&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;&lt;strong&gt;Total = 2.40000000 BTC&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;b) Gerar um endereço seu para receber a consolidação&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; getnewaddress
&lt;span class=&quot;c&quot;&gt;# bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Opção 1 — Com &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fundrawtransaction&lt;/code&gt; (sem troco via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractFeeFromOutputs&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mais simples: você informa o &lt;strong&gt;total&lt;/strong&gt; na saída e pede para a taxa ser &lt;strong&gt;descontada do próprio output&lt;/strong&gt;, evitando troco.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Criar o hex bruto com 3 inputs e 1 output (2.4 BTC)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 &lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;,&quot;vout&quot;:0},{&quot;txid&quot;:&quot;b9554be708c5ea7414876a3757a65df19cd5ddf8c19365c8425c3f8ce8066d79&quot;,&quot;vout&quot;:2},{&quot;txid&quot;:&quot;1417f599358ea49a63dd253a3b3701ce0fa28cdf006522e4a3c50c48fce12e8e&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;:2.4}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff01001c4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Completar: taxa e “sem troco”&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; fundrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff01001c4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;add_inputs&quot;:false, &quot;feeRate&quot;:0.00001000, &quot;subtractFeeFromOutputs&quot;:[0]}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;fee&quot;&lt;/span&gt;: 0.00000245,
  &lt;span class=&quot;s2&quot;&gt;&quot;changepos&quot;&lt;/span&gt;: &lt;span class=&quot;nt&quot;&gt;-1&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;changepos&lt;/strong&gt; igual a -1 indica que não há troco.
&lt;strong&gt;3. Assinar e enviar&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000003796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402203664d96a5f91c916e213e9a6adabda0c4a2031abe9db7e1a8f2f996f9fdbad91022070ea8353ce9281456776f5e723c48c1aa022a4adb35a207f9644c0338d95c6310121039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f20247304402203c350e5bd7a9a69fde895df1ae95d6935383c7ac7554f53ac10437391d45d3fd02202fbfc490b365afe774bb4771650ec9bb81e813a6df547e523ed9bacf4fa1d6f50121037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f0247304402206e422304d7a85fb96a9624c532cabd2ae0354711554410b7360cff55df14a57e02202bdbd8fb1983d5d3f24f859f735c11b174bfea9a5b813e77e8a9734047620a7001210238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d900000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90000000000fdffffff796d06e88c3f5c42c86593c1f8ddd59cf15da657376a871474eac508e74b55b90200000000fdffffff8e2ee1fc480cc5a3e4226500df8ca20fce01373b3a25dd639aa48e3599f517140000000000fdffffff010b1b4e0e000000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402203664d96a5f91c916e213e9a6adabda0c4a2031abe9db7e1a8f2f996f9fdbad91022070ea8353ce9281456776f5e723c48c1aa022a4adb35a207f9644c0338d95c6310121039c8a99f8d6008801b97a6ec5f0ca231e706ddb28edebd12666b0f16aef7a48f20247304402203c350e5bd7a9a69fde895df1ae95d6935383c7ac7554f53ac10437391d45d3fd02202fbfc490b365afe774bb4771650ec9bb81e813a6df547e523ed9bacf4fa1d6f50121037994b04a5183d16e24f1a3a2a08bf1fcd5c528e5efcc3855065a6f3e0659ae0f0247304402206e422304d7a85fb96a9624c532cabd2ae0354711554410b7360cff55df14a57e02202bdbd8fb1983d5d3f24f859f735c11b174bfea9a5b813e77e8a9734047620a7001210238caef26a2025d89d4230bcc7e2d1dbdcc8ce51ce1c07cd4509a76495bba07d900000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 61db943161c00e8cf797cb8d4e3d896e88f52c8e39490e735d70abaa6a74ce73&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;4. Confirmar e verificar o novo UTXO único&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;61db943161c00e8cf797cb8d4e3d896e88f52c8e39490e735d70abaa6a74ce73&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c1&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 2.39999755,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/7]02b1f28fe1718cb0d19d63ca8f00f1da97a9ca6a2f2fe58ea38dc8764271fd9bb9)#v6xev5z7&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perceba que agora temos um UTXO com &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.39999755&lt;/code&gt; BTC (2.4 BTC consolidados - taxa).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Opção 2 — Total controle (sem &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fundrawtransaction&lt;/code&gt;)&lt;/strong&gt;
Podemos definir a taxa e já criar a saída como &lt;strong&gt;soma(inputs) − taxa&lt;/strong&gt; (sem troco). Nesse cenário, vamos consolidar 3 UTXOs que receberam as recompensas de mineração em exemplos anteriores.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Calcular o valor de saída&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;VALOR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;150-&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.0001&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;VALOR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;149.9999
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Criar o raw sem espaço para troco&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; createrawtransaction &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;s1&quot;&gt;&apos;[{&quot;txid&quot;:&quot;347775cd427f4e7b88906ce5ca8c11570822063c76280cc2e63879e6ed956323&quot;,&quot;vout&quot;:0},{&quot;txid&quot;:&quot;cebd41bfe9964f604f7247ee0c27a1bec23a55880c5be1c91b3889f4e2277808&quot;,&quot;vout&quot;:0},{&quot;txid&quot;:&quot;1a2c538fb7b78a8898ddc82b79dd593922d402153c7ff97491e539a91b57fde7&quot;,&quot;vout&quot;:0}]&apos;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;:149.9999}&apos;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 0200000003236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. Assinar, enviar e confirmar&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; signrawtransactionwithwallet &lt;span class=&quot;s2&quot;&gt;&quot;0200000003236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c100000000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&quot;hex&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402204aa694a69c037ab059f75affd9db353cc2d54438c2d22d0a69f5996ae4e3b4d302205ea15356e49c0ae44ba9e110e3e0ff1f83b76943ace7d62171e6fa7e70154b190121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202ceef57fb7564c5108dfcadb719b6dfc34747ec30b13fe2c306bb76ee73902c30220349cbc0e130f446bc0313afe0502850e792d3e0edc08d198f89091b04607d4b90121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202c56c84d7bc2bdac40cfb9d3baea64e23193fb9145cd1da9737795c4553991e002205d7ec73eff147ac9903057abe1ff78fe54cdcc63f8270a52810dd3c44d86ab390121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;,
  &lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; sendrawtransaction &lt;span class=&quot;s2&quot;&gt;&quot;02000000000103236395ede67938e6c20c28763c06220857118ccae56c90887b4e7f42cd7577340000000000fdffffff087827e2f489381bc9e15b0c88553ac2bea1270cee47724f604f96e9bf41bdce0000000000fdffffffe7fd571ba939e59174f97f3c1502d4223959dd792bc8dd98888ab7b78f532c1a0000000000fdffffff01f0ae117e030000001600149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c10247304402204aa694a69c037ab059f75affd9db353cc2d54438c2d22d0a69f5996ae4e3b4d302205ea15356e49c0ae44ba9e110e3e0ff1f83b76943ace7d62171e6fa7e70154b190121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202ceef57fb7564c5108dfcadb719b6dfc34747ec30b13fe2c306bb76ee73902c30220349cbc0e130f446bc0313afe0502850e792d3e0edc08d198f89091b04607d4b90121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba70247304402202c56c84d7bc2bdac40cfb9d3baea64e23193fb9145cd1da9737795c4553991e002205d7ec73eff147ac9903057abe1ff78fe54cdcc63f8270a52810dd3c44d86ab390121024bdbdf6b6c264db5a9a9f2ffb6f964f228c722c419ffd7ae26a7b850bfce6ba700000000&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 2c668e312971983fc465d8c79f5813732f288331cda23dd86fd73fc5339e2984&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; generatetoaddress 1 bcrt1q9w437k3luux5crekejss56r8cysxhr4ypuha22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Podemos listar os UTXOs para conferir a consolidação.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bitcoin-cli &lt;span class=&quot;nt&quot;&gt;-datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt; listunspent
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;txid&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;2c668e312971983fc465d8c79f5813732f288331cda23dd86fd73fc5339e2984&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;vout&quot;&lt;/span&gt;: 0,
    &lt;span class=&quot;s2&quot;&gt;&quot;address&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;bcrt1qnk9lxpt4ch7zkp9ncdr3awe0aa0e49kp5v6453&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;scriptPubKey&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;00149d8bf30575c5fc2b04b3c3471ebb2fef5f9a96c1&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;amount&quot;&lt;/span&gt;: 149.99990000,
    &lt;span class=&quot;s2&quot;&gt;&quot;confirmations&quot;&lt;/span&gt;: 1,
    &lt;span class=&quot;s2&quot;&gt;&quot;spendable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;solvable&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;desc&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;wpkh([2f5cd395/84h/1h/0h/0/7]02b1f28fe1718cb0d19d63ca8f00f1da97a9ca6a2f2fe58ea38dc8764271fd9bb9)#v6xev5z7&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;parent_descs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;wpkh(tpubD6NzVbkrYhZ4WtpQ21uY5dQCNe2wu8GdTcB7zLmVcdvJPFjQ8c4FNq1wR4zsr1qc1XgZqVAmd6m6uHrSJhrfTHsy5cnw5yyQaWG49guuByL/84h/1h/0h/0/*)#rlp9dth8&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;safe&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;,
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Veja que agora temos um UTXO com &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;149.99990000&lt;/code&gt; BTC.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Construir transações manualmente no Bitcoin Core é mais do que um exercício de curiosidade: é um &lt;strong&gt;laboratório prático para entender o protocolo&lt;/strong&gt;. Ao longo deste artigo, vimos cenários que cobrem desde o envio básico com troco automático até estratégias mais avançadas como &lt;strong&gt;batching&lt;/strong&gt; e &lt;strong&gt;consolidação de UTXOs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Esses exemplos deixam claro que:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Cada satoshi importa&lt;/strong&gt; – negligenciar o cálculo de taxas ou o endereço de troco pode transformar uma simples distração em uma taxa gigantesca paga ao minerador.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Controle é poder&lt;/strong&gt; – escolher manualmente os inputs, definir a taxa e decidir quando consolidar UTXOs permite otimizar custos e simplificar a carteira.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Privacidade exige planejamento&lt;/strong&gt; – consolidar ou misturar UTXOs pode revelar vínculos entre endereços. Em ambientes de produção, combine estas técnicas com boas práticas de privacidade.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Praticar esses comandos em &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regtest&lt;/code&gt; ou &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;signet&lt;/code&gt; fornece a segurança de um ambiente controlado, mas o aprendizado é diretamente aplicável à &lt;strong&gt;mainnet&lt;/strong&gt;. Antes de enviar transações reais, revise sempre:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Soma dos outputs vs. inputs&lt;/strong&gt; – garanta que a diferença seja a taxa pretendida.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Destino do troco&lt;/strong&gt; – defina um endereço sob seu controle ou use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subtractfeefromamount&lt;/code&gt; se quiser evitá-lo.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Taxa de rede&lt;/strong&gt; – ajuste de acordo com o mempool para equilibrar custo e velocidade de confirmação.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Dominar essas práticas dá a você não apenas confiança para operar na rede, mas também &lt;strong&gt;uma compreensão profunda do modelo UTXO&lt;/strong&gt; que sustenta o Bitcoin.&lt;/p&gt;

&lt;p&gt;Nos próximos artigos, exploraremos outras questões avançadas relacionadas à transações, como &lt;strong&gt;PSBTs (Partially Signed Bitcoin Transactions)&lt;/strong&gt;, &lt;strong&gt;multisig&lt;/strong&gt; e &lt;strong&gt;timelocks&lt;/strong&gt;.  &lt;em&gt;**&lt;/em&gt;&lt;/p&gt;</content><author><name></name></author><category term="blog" /><summary type="html">Construindo Transações no Bitcoin Core</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitdevsmaputo.org/assets/img/og-preview.png" /><media:content medium="image" url="https://bitdevsmaputo.org/assets/img/og-preview.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>