This project is a simple Bitcoin wallet implementation that allows users to create and send Bitcoin transactions on the Testnet. It demonstrates the use of Segregated Witness (SegWit) transactions and interacts with the Blockstream API for fetching UTXOs and broadcasting transactions.
To integrate with MPC, we need to replace the signature with the MPC signature.
- Generate a Bitcoin wallet from a mnemonic phrase.
- Create and sign Bitcoin transactions.
- Fetch UTXOs for a given address.
- Send transactions to the Bitcoin Testnet.
- Go 1.16 or later
- A basic understanding of Bitcoin and how transactions work.
-
Clone the repository:
git clone https://github.com/yourusername/btc-demo-go.git cd btc-demo-go -
Install the required Go modules:
go mod tidy
-
Set up your mnemonic and receiver address in the
mainfunction ofmain.go:config := WalletConfig{ mnemonic: "your mnemonic here", receiverAddress: "tb1qyourreceiveraddresshere", amount: 100000, // Amount in satoshis }
-
Run the application:
go run main.go helper.go
-
The application will create a transaction and send it to the Testnet. You will see logs indicating the transaction details.
- NewWallet(mnemonic string): Creates a new wallet from the provided mnemonic.
- CreateTransaction(receiverAddress string, amount int64): Creates and signs a new Bitcoin transaction.
- GetUTXOs(address string): Fetches all UTXOs for a given address.
- SendTransactionPlain(txHex []byte): Sends the transaction as raw plain text to the network.
- This project is intended for educational purposes and should not be used for real transactions without proper security measures.
- Make sure to use Testnet addresses and funds when testing.
This project is licensed under the MIT License - see the LICENSE file for details.
- btcsuite/btcd - A full node implementation of Bitcoin in Go.
- Blockstream API - Provides access to Bitcoin blockchain data and transaction broadcasting.