Bitcoin UTXO management redesign#3601
Draft
TaprootFreak wants to merge 1 commit intodevelopfrom
Draft
Conversation
Replace the two-node Bitcoin architecture (input/output) with a single node and descriptor wallet. Addresses are never reused — every deposit gets a unique address and every transaction uses a fresh change address. - Remove BTC_INPUT/BTC_OUTPUT node separation - Set forwardRequired=false to skip unnecessary forwarding transactions - Generate fresh change addresses via getnewaddress per transaction - Add lock_unspents to prevent UTXO race conditions - Switch deposit address type from p2sh-segwit to native segwit (bech32) - Add BitcoinUtxo entity for individual UTXO tracking - Update downstream services to handle COMPLETED PayIn status
Collaborator
Author
Open items before deployCode (follow-up commit):
Server setup (manual, before switching env vars):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the two-node Bitcoin architecture (separate input/output wallets) with a single descriptor wallet where addresses are never reused. Every deposit gets a unique address, every transaction generates a fresh change address, and unnecessary forwarding transactions are eliminated.
This significantly improves on-chain privacy — previously, all funds were consolidated into a single output address that was reused for every payout and change output, making it trivial to link all DFX Bitcoin transactions on-chain.
Key changes
BTC_INPUT/BTC_OUTPUTseparation, use one Bitcoin Core walletforwardRequired=false— deposits stay in the wallet, no intermediate forward transactions (saves fees)sendManycall generates a new address viagetnewaddressinstead of reusing a fixed addresslock_unspents: trueprevents race conditions on parallel payoutsbech32(bc1q) instead ofp2sh-segwitBitcoinUtxoentity + repository + service for individual UTXO tracking in the databaseBuyFiatRegistrationandBuyFiatreturn logic updated to handleCOMPLETEDstatus alongsideFORWARD_CONFIRMEDServer setup required before deploy
bitcoin-cli createwallet "dfx" false false "" false truebitcoin-cli -rpcwallet=dfx setwalletflag avoid_reuse trueNODE_BTC_URL_ACTIVE/NODE_BTC_URL_PASSIVETest plan
listunspentshows no reused addresses