Coder Social home page Coder Social logo

chaincode-bitcoin-signet-wallet-project's Introduction

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

wallet_019: wpkh(tprv8ZgxMBicQKsPdL9HoopTVCQ6VjpzpEPZmGoJeBtw3BUjfQATEJvTNACXjy6x9uZLjgsVvHXWkTPiRQMqmEb5BFciXVDwzt79nbBi9dXVxwA/84h/1h/0h/0/*)#6kh6r3d8

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.

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 should never be killed, but the node can always be restarted by using -datadir=<path/for/bitcoin/datadir>

chaincode-bitcoin-signet-wallet-project's People

Contributors

github-classroom[bot] avatar mattmcgiv avatar

Watchers

 avatar

chaincode-bitcoin-signet-wallet-project's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.