Create Bitcoin double-spend discouraging bonds on Liquid.

Overview

doubletake

A tool for creating Bitcoin double-spend punishment bonds on Liquid.

WARNING: Don't use this tool for real use cases yet. There are still a few known shortcomings in the design that make the bond circumventable.

How it works

This tool will allow you to create a bond on Liquid where you lock up some money for a limited amount of time and that anyone can burn if they prove that you have attempted a double spend on Bitcoin with the public key tied to the bond.

To start, you need to specify which public key you want to create a bond for.

Note that a bond can only work for either segwit v0 OR taproot, not for both. Also, currently, only segwit is supported.

CLI

There is a CLI tool included by default.

$ cargo install doubletake
$ doubletake create --segwit \
    --pubkey 028c920fd8a18688dada0af50177941c80920c0dc86c2ecba6b13784dcbd0ffcb7 \
    --bond-value "2 BTC" \
    --expiry 1722369854 \
    --reclaim-pubkey 03339c911ea18b24c3dea446ca4b8ba5d1b9cf5de0170a1d9fde2da17ec8431a56
{
  "address": "ex1qref05f3urpcrcr59x45tar2xu3y0hppfcd6avujq5kerxqfhr73smdjj5h",
  "spec": "AAKMkg_YoYaI2toK9QF3lByAkgwNyGwuy6axN4TcvQ_8twDC6wsAAAAAbVIcOOweoVc0riK3xGBkQSgpwNBXnwpxPRwE7el5Am8-R6lmAzOckR6hiyTD3qRGykuLpdG5z13gFwodn94toX7IQxpW"
}%

As a Rust library

If you want to use doubletake purely as a Rust library, you can turn off the CLI dependencies by disabling the default feature cli.

Testing

There is an integration test that tests either

  • against libelementsconsensus, but this one isn't working for now
  • against an elementsregtest network that should be running

You can run a compatible regtest network as follows:

$ elementsd -chain=elementsregtest -server=1 -validatepegin=0 -rpcport=8888 -rpcuser=testuser -rpcpassword=testpass -anyonecanspendaremine=1 -initialfreecoins=2100000000000000 -blindedaddresses=0
$ # in another terminal, prepare as follows:
$ elements-cli -chain=elementsregtest -rpcuser=testuser -rpcpassword=testpass -rpcport=8888 createwallet ""
$ elements-cli -chain=elementsregtest -rpcuser=testuser -rpcpassword=testpass -rpcport=8888 rescanblockchain

You can run the tests as follows:

$ cd ./integration_test/
$ cargo run -- regtest

WASM

To build for WASM, use the wasm feature.

$ wasm-pack build --target web -- --features wasm

Observations

Currently we only support segwit v0 spends. This means that any segwit v0 spend done by the given pubkey, should be covered. This means p2wpkh and p2wsh.

Also, our implementation should be robust enough that any sighash flags should be supported. So if you hold an unconfirmed spend of an output with any sighash flags, you will be able to burn the bond if any other kind of spend is done using another sighash flag.

This becomes a lot harder with taproot, where the sighash structure changes significantly depending on the sighash flags used. The taproot version is still a work in progress.

You might also like...
The Parity Bitcoin client

The Parity Bitcoin client. Gitter Installing from source Installing the snap Running tests Going online Importing bitcoind database Command line inter

Iterate over bitcoin blocks

Blocks iterator Iterates over Bitcoin blocks, decoding data inside Bitcoin Core's blocks directory. Features: Blocks are returned in height order, it

EXPERIMENTAL: Bitcoin Core Prometheus exporter based on User-Space, Statically Defined Tracing and eBPF.

bitcoind-observer An experimental Prometheus metric exporter for Bitcoin Core based on Userspace, Statically Defined Tracing and eBPF. This demo is ba

Rust command line program for Bitcoin brainwallet

brainwallet Rust command line program for Bitcoin brainwallet as implemented at https://www.bitaddress.org. To run it, first install Rust, e.g. from h

Rustcoin - A LightWeight SDK For Bitcoin, Ethernum

Rustcoin - A LightWeight SDK For Bitcoin, Ethernum

The Stage 2 building block to reach the dream of DSNs with Bitcoin DeFi

rust-nostr Intro A complete suite of nostr Bitcoin libraries that can be used to develop Decentralized Social Networks (DSN) with integrated Bitcoin f

A preview of the integration between Bitcoin and the Internet Computer.

Bitcoin Integration Developer Preview Overview The integration between the Internet Computer and Bitcoin will enable developers to build canisters tha

Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin
Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin

Rust Bitcoin Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin. Heads up for

interBTC  A trust-minimized bridge from Bitcoin to Polkadot.
interBTC A trust-minimized bridge from Bitcoin to Polkadot.

interBTC A trust-minimized bridge from Bitcoin to Polkadot. Explore the specification » Report Bug · Request Feature This repository is hosted on GitH

Owner
Steven Roose
"We publish our code so that our fellow Cypherpunks may practice and play with it. Our code is free for all to use, worldwide." - A Cypherpunk's Manifesto
Steven Roose
Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transactions of your non-custodial wallets on a provider of your choice, all while respecting your privacy

Bitcoin Push Notification Service (BPNS) Description Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transacti

BPNS 1 May 2, 2022
Minimal Bitcoin wallet intended for teaching rust-bitcoin

Insanely minimal Bitcoin wallet intended for demonstration of Rust Bitcoin ecosystem Absolutely DO NOT use with mainnet funds!!! No privacy - address

Martin Habovštiak 4 May 5, 2023
Modern, lightweight & standard-compliant bitcoin wallet runtime & cli without rust-bitcoin dependencies

Bitcoin protocol command-line wallet & tools Modern, minimalistic & standard-compliant cold wallet from LNP/BP Standards Association. Contributing Con

BP: Bitcoin protocol 3 Jul 31, 2023
A wallet library for Elements / Liquid written in Rust!

EDK Elements Dev Kit A modern, lightweight, descriptor-based wallet library for Elements / Liquid written in Rust! Inspired by BDK for Elements & Liqu

luca vaccaro 11 Dec 11, 2021
Marinde Anchor-Based, first on mainnet, liquid-staking-program and mSOL->SOL swap pool

marinade-anchor Marinade-finance liquid staking program for the Solana blockchain Audits & Code Review Kudelski Security: https://marinade.finance/Kud

Marinade.Finance 42 Dec 11, 2022
Eternally liquid. Forward compatible. Nested, conditional, & Multi-resourced NFTs.

RMRK Substrate Rust Setup First, complete the basic Rust setup instructions. Run Use Rust's native cargo command to build and launch the template node

RMRK Team 67 Dec 25, 2022
Terra liquid staking derivative

Terra liquid staking derivative. Of the community, by the community, for the community.

null 36 Dec 6, 2022
🎙️ Catalyst Voices provides a unified experience and platform including production-ready liquid democracy

??️ Catalyst Voices provides a unified experience and platform including production-ready liquid democracy, meaningful collaboration opportunities & data-driven context for better onboarding & decisions.

Input Output 6 Oct 11, 2023
A quick create wizard to create and modify opinionated kustomize deployments.

kqc ?? ☸️ A quick create wizard to create and modify opinionated kustomize deployments. This tool should help to quickly create and build up kustomize

Daniel Jankowski 8 May 20, 2023
A Rust library for working with Bitcoin SV

Rust-SV A library to build Bitcoin SV applications in Rust. Documentation Features P2P protocol messages (construction and serialization) Address enco

Brenton Gunning 51 Oct 13, 2022