https://github.com/bl4ck5un/p2sh-examples
Examples of Rust code to generate various P2SH transactions
https://github.com/bl4ck5un/p2sh-examples
bitcoin bitcoin-transaction p2sh rust-lang
Last synced: about 2 months ago
JSON representation
Examples of Rust code to generate various P2SH transactions
- Host: GitHub
- URL: https://github.com/bl4ck5un/p2sh-examples
- Owner: bl4ck5un
- Created: 2018-09-02T00:03:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-16T03:14:17.000Z (over 6 years ago)
- Last Synced: 2025-01-27T08:28:55.578Z (4 months ago)
- Topics: bitcoin, bitcoin-transaction, p2sh, rust-lang
- Language: Rust
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Constructing P2SH transactions in Rust
This repo contains educational (hopefully) examples for handcrafting pay-to-script-hash transactions in Rust.
## A simple one: hodl coins using CheckLocktimeVerify
`cltv.rs` is inspired by Peter Todd's CLTV demo (see a [fork of mine](https://github.com/bl4ck5un/checklocktimeverify-demos)).
`cltv` has two subcommands: `create` and `spend`. The former generates a `P2SH`
address such that coins sent to it can be spent by the specified secret key
after the specified timeout (an absolute unix epoch).### Usage
```
USAGE:
cltv --locktime --secret createFLAGS:
-h, --help Prints help information
-V, --version Prints version information
```The latter generate a transaction that spends an P2SH UTXO to a specified address.
```
USAGE:
cltv --locktime --secret spend [OPTIONS] --address --txFLAGS:
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
--address
--tx
--vout [default: 0]
```See `cltv --help` for the usage info.
## Tips
- Use the attached config file to create a regtest for fast testing.
- Make sure the P2SH UTXO is confirmed before trying to spend it. Otherwise you might a `non-final` error, even the timelock has expired.