Giter Club home page Giter Club logo

psbt_faker's Introduction

PSBT Faker

A simple program to create test PSBT files, that are plausible and self-consistent so that PSBT-signing tools will actually sign them. Does not involve any blockchains... completely made up inputs and output addresses are chosen at random.

You should use the XPUB of the Coldcard you want experiment against. This can be retrieved using ckcc xpub with the ckcc-protocol CLI tool, or by exporting the wallet (see Advanced > MicroSD > Export Wallet menu).

For the Coldcard Simulator, you could use tpubD6NzVbkrYhZ4XzL5Dhayo67Gorv1YMS7j8pRUvVMd5odC2LBPLAygka9p7748JtSq82FNGPppFEz5xxZUdasBRCqJqXvUHq6xpnsMcYJzeh

Installation

git clone https://github.com/Coldcard/psbt_faker.git
cd psbt_faker
python3 -m pip install -U pip setuptools
python3 -m pip install --editable .
rehash

Usage

$ psbt_faker --help

Usage: psbt_faker [OPTIONS] OUTPUT.PSBT [XPUB]

  Construct a valid PSBT which spends non-existant BTC to random addresses!

Options:
  -n, --num-outs INTEGER          Number of outputs (default 1)
  -c, --num-change INTEGER        Number of change outputs (default 1)
  -v, --value INTEGER             Total BTC value of inputs (integer, default
                                  3)
  -f, --fee INTEGER               Miner's fee in Satoshis
  -s, --segwit                    Make ins/outs be segwit style
  -a, --styles [p2wpkh|p2wsh|p2sh|p2pkh|p2wsh-p2sh|p2wpkh-p2sh|p2tr]
                                  Output address style (multiple ok)
  -6, --base64                    Output base64 (default binary)
  -t, --testnet                   Assume testnet3 addresses (default mainnet)
  -p, --partial                   Change first input so its different XPUB and
                                  result cannot be finalized
  -z, --zero-xfp                  Provide zero XFP and junk XPUB (cannot be
                                  signed, but should be decodable)
  --help                          Show this message and exit.

Examples

$ export XPUB=tpubD6NzVbkrYhZ4Xp6tGusznF6KMdYHy1JSCdDk3XVLDuAA7EgJKghA5J1FP4pDXb4sCypJjAYPB4uTTXkVo2iWzK8BsMaccXTNyShDx3gxagi

$ psbt_faker foo.psbt $XPUB -s -a p2wsh --fee 15000000 -c 0

Fake PSBT would send 3 BTC to: 
 2.85000000 => bc1qqalzjffzy9nwcd35t0phdyugdmmqpskldgcw3xd40qxh32z908msf5alem 
 0.15000000 => miners fee

$ psbt_faker foo.psbt $XPUB -n 10

Fake PSBT would send 3 BTC to: 
 0.27272636 => 17VardgvHiYjDEtpBRWpqQLgrvKDUiGGaW 
 0.27272636 => 1A1FDLRD1caNjbwpr4odqpcB2sGgZSgGqZ 
 0.27272636 => 1P3Zr4zQko2CDbDDiqrkMduSppNB3Pb1Aq 
 0.27272636 => 1LcDusCVB6KjjAcrk5NvscV4AQ3cRJTR8j 
 0.27272636 => 15oy1fAxnbYr6Vgz7eNwjBQfujdvssdRaG 
 0.27272636 => 1EkYuiLo9Tt3cYCJwMfDvX38MddTBMqPc1 
 0.27272636 => 185VxgHqCEYudH6XXwdDiQtqfEUXGMxSXJ 
 0.27272636 => 19dR12aRSj8nyUaJLM11ruExa7N6jdAmUJ 
 0.27272636 => 1Ppj73d7z6cQvKhzezmaBywbJRSUnrymPE 
 0.27272636 => 1CPCdAWTrVqgS8cHVTbDQwkCvASjTfcaTe 
 0.27272636 => 1F2WTuA3BRpYmM82gsLuAdyAiLPYoUYijP  (change back)
 0.00001000 => miners fee


$ psbt_faker foo.psbt $XPUB -n 3 -v 100 -c 10

Fake PSBT would send 100 BTC to: 
 7.69230692 => 13mRoGiQHzmPhaCgQZbjw42njWhV3ymqDw 
 7.69230692 => 1MMbuGuuaJ9GnRXh4ixa6xiKER3xzg52TJ 
 7.69230692 => 1NjnUBrWSSx8iK5TC3XJXqQ7grC23kpZX2 
 7.69230692 => 1Aq96VVsd2nocTqAYQ4PnD6XhotKqmrBNn  (change back)
 7.69230692 => 1Bj7KprFDJ1d1F1se3DKedASFYvjWNaZMT  (change back)
 7.69230692 => 1HVTgLgZF95tF4B1CJk4BEvkLmT3hYDrmA  (change back)
 7.69230692 => 17Uz3tHeG1Zf8W4hmst2kQtbH17tHe3UTN  (change back)
 7.69230692 => 1LyLjaPcXbo5TxJYMYyUT9HzCgkJnKef1j  (change back)
 7.69230692 => 19DasuH8grQGc4MrPPR5abYUZAKF9UbbwZ  (change back)
 7.69230692 => 1JpymwTGWfXpcurLnsFbLcPRnkkzvRiKsy  (change back)
 7.69230692 => 1PoFUSStjmogrv2eEtRjbpz8N5reETVVZn  (change back)
 7.69230692 => 1Q8yrQsHotMNkrsAyEynDAuqC8rDs7nG41  (change back)
 7.69230692 => 1AbiaE64hjUygVoqkedaLvneHht8bbvPgo  (change back)
 0.00001000 => miners fee

psbt_faker foo.psbt $XPUB -n 10 -a p2wpkh -a p2wsh -a p2sh -a p2pkh -a p2wsh-p2sh -a p2wpkh-p2sh

Fake PSBT would send 3 BTC to: 
 0.27272636 => bc1q2l0zgfksxacs8hdxwmq56ftpzagcyvq8z237qf 
 0.27272636 => bc1q4ru6vpngexl348we0fkydheat3azcvr96uc975tmvcy0z8kjaz6qz30498 
 0.27272636 => 37Axq8rmQGjEHVoCb877RiNfWnnMtFCZ6H 
 0.27272636 => 16JDSqRVvYdWV4KntQ5wjUK5es6CaiTyBc 
 0.27272636 => 3HXq92K1xvx6QMNmQTHPWPLNiEReez595d 
 0.27272636 => 3LyBpZ2aaTs1Qj1NFmGGttL8PyhEzB9iDW 
 0.27272636 => bc1qsplnzq8n500q4zg6a8m2nj4c8ygvlp8p8zuppc 
 0.27272636 => bc1qw9hery5rjcujuf3f09djlxepepx6luen7jq9t0hfsu44dv3t6x3s4k4aw5 
 0.27272636 => 3Ld1TUaWQouRRGGAc8PSzvqtgjfyxdM3Vr 
 0.27272636 => 1ABmPHMdqK4MqF9BkACv8PHHYL7McmbYAq 
 0.27272636 => 15mkVohf2A1g9nVo9tn2KtN2f4eBHQCche  (change back)
 0.00001000 => miners fee

psbt_faker's People

Contributors

doc-hex avatar fang- avatar nvk avatar schjonhaug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

psbt_faker's Issues

command not found: psbt_faker

Trying to get psbt_faker up an running, but facing some issues. I’m on macOS 12.4. After cloning the repo, I do:

❯ python3 --version
Python 3.9.13

❯ python3 -m pip install --editable .
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Obtaining (...)psbt_faker
  Preparing metadata (setup.py) ... done
Requirement already satisfied: Click in /usr/local/lib/python3.9/site-packages (from psbt-faker==1.3) (8.1.3)
Requirement already satisfied: pycoin==0.80 in /usr/local/lib/python3.9/site-packages (from psbt-faker==1.3) (0.80)
Installing collected packages: psbt-faker
  Attempting uninstall: psbt-faker
    Found existing installation: psbt-faker 1.3
    Uninstalling psbt-faker-1.3:
      Successfully uninstalled psbt-faker-1.3
  DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
  Running setup.py develop for psbt-faker
Successfully installed psbt-faker-1.3

❯ rehash
❯ psbt_faker --help
zsh: command not found: psbt_faker

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.