Skip to content

chaincodelabs/signet-wallet-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Signet Wallet Project

The goal of this project is to write a simple wallet over two weeks and use it to interact with a custom signet network provided by the administrator.

Simplify

To reduce the scope of this project the wallet will be very limited:

  • No separate change addresses: one descriptor is used for all internal and external addressees.
  • No VarInt: all vectors will be under 255 bytes in length and always require one single byte to indicate length.
  • All sending and receiving addresses will be p2wpkh
    • Except one p2wsh multisig which is the goal of the week 2 assignment
  • Fees can be hard-coded by value, no estimation is necessary.
  • Transactions you create will always have exactly 1 input and 2 outputs.
  • Don't worry about invalid keys (probabilty is less than 1 in 2127)
  • Other constants:
    • All transactions will be version 2 (little-endian encoded as \x02\x00\x00\x00)
    • All input sequences will be 0xffffffff
    • All transaction locktimes will be 0x00000000
    • All input scriptSigs will be 0x00 (because we are only concerned with segregated witness inputs)
    • All sighash flags will be SIGHASH_ALL which is 0x01 in signatures and little-endian encoded as \x01\x00\x00\x00 in transaction commitments

Custom Signet

We will pre-fabricate a signet blockchain and host a mining node that everyone can connect to, download the chain (around 20 MB), and broadcast their completed transactions. We will have already generated private key descriptors for each student and used them to generate hundreds of transactions sending and receiving in the chain. Each student will be provided with a single wpkh descriptor with an extended private key like this example:

wallet_000: wpkh(tprv8ZgxMBicQKsPekvUvQEdWuFnTazwP6QwU15RJCTAEUaUn9ti3NEtywCywj1PF4G2MzvTad4F3MSSZvT2nZuxHBJ9HaZad5r1dYJtzYsR9iW/84h/1h/0h/0/*)#3ajpxxju

The important elements here are the extended private key (tprv...) and the derivation path (84h/1h/0h/0/*).

Note: If you have already connected to the "default" (or any other) signet network with your node, you may need to rename / move your existing data directory. See #27494

A bitcoin.conf file will be provided to students in config/bitcoin.conf which will set the address of the mining node as well as provide the signet challenge. Copy this file to your system's default datadir location and start Bitcoin Core:

bitcoind -signet

You should also then be able to execute RPCs with (for example):

bitcoin-cli -signet getblockcount

Week 1 (keys and addresses)

See Recover Balance coding challenge

Week 2 (transactions, scripts, and signatures)

See Send Multisig coding challenge

Admin Infrastructure

Students do not need to read this section

Setup the Signet server

The included script signet-setup.py needs to be run by the administrator on a publicly reachable server to start the game.

The script requires a local installation of Bitcoin Core since it consumes the test framework as a library. Minimum required version of Bitcoin Core is v29 to include cmake build system. bitcoin-util must be built by adding -BUILD_UTIL=on to the configuration.

You may need to increase file descriptor limits (macos example): ulimit -n 8176

Usage: python signet-setup.py <path/to/bitcoin> <path/to/student/files> <path/for/bitcoin/datadir>

<path/to/bitcoin>: (required) Path to local installation of Bitcoin Core repository

<path/to/student/files>: (optional, default ./config) Destination for student bitcoin.conf and wallet descriptors

<path/for/bitcoin/datadir>: (optional, default is os.tmpdir()) Data directory for the signet full node

The script runs the signet full node, creates all the wallets and continues mining blocks forever. It is designed to run uninterrupted at least through block 300 to generate enough data for the challenge. After that, the node can be restarted from the root of the Bitcoin Core repository using the commands below.

DIR=/absolute/path/for/bitcoin/data/node0
./build/src/bitcoind -datadir=$DIR -printtoconsole=1

Note the node0 suffix is required because the directory is created by the functional test framework.

Then the signet miner can be continued:

CLI="./build/src/bitcoin-cli -datadir=$DIR -rpcwallet=miner"
$CLI loadwallet miner
ADDR=$($CLI getnewaddress)
./contrib/signet/miner --cli="$CLI" generate --address=$ADDR --grind-cmd="./build/src/bitcoin-util grind" --min-nbits --ongoing

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •