Git Product home page Git Product logo

bitcoin-dead-mans-switch's Introduction

Dead Man's Switch Bitcoin Wallet

This CLI Bitcoin wallet written in Ruby uses timelocked UTXOs to act as a dead man's switch. After configuring a time period (nSequence), the owner needs to periodically use the wallet to withdraw funds. If the owner does not use the wallet within the configured time period, the funds become spendable by the successor.

This is performed by managing a p2sh address mapping to the following Bitcoin Script:

OP_If
	<Owner’s pubkey> OP_CheckSig
OP_Else
	<TTL> OP_CheckSequenceVerify
	OP_Drop
	<Successor’s pubkey> OP_CheckSig
OP_EndIf

Donations accepted at 19LfwY1x5j3mNeBZ8MamfMAuxbsMbpoFEe

Installation

bundle install

Owner Usage

Generate owner key

The following operation will create a succession.key file in your local directory with the contents of your private key ./succession keygen

Configure successor

The following operation will configure a successor to your funds. Future transactions sent from this wallet will include a "change" output to a p2sh address derived by your succession config.

./succession -p <successor_public_key> -t <nSequence>

Get current balance

Retrieves the balance mapping to the sum of your key's p2pkh address, and of the configured p2sh address.

./succession balance

Construct send transaction

This operation will construct and sign a Bitcoin transaction and output it in JSON and hex to stdout. You should upload the constructed transaction to a Bitcoin node.

To spend funds as an owner, refreshing the timelock period:

./succession send -t <btc_address> -c <bitcoin_amount>

After the transaction is generated, a p2sh.state file will be created on your working directory. This file contains the p2sh redeem script and should be sent to the successor.

Successor usage

The successor should create a new wallet via ./succession keygen and configure their own successor via ./succession -p <next_successor_public_key> -t <nSequence>. Then, they should paste the p2sh.state file provided to them by the owner into the working dir.

After the timelock period has expired, the successor can use the following command to create a bitcoin transaction which spends the funds using the successor key:

./succession send -t <btc_address> -c <bitcoin_amount> -s

bitcoin-dead-mans-switch's People

Contributors

alexmavr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.