Skip to main content

Crate outscript

Crate outscript 

Source
Expand description

outscript generates potential output scripts for a given public key.

It supports Bitcoin and Bitcoin-like cryptocurrency output script formats (P2PKH, P2SH, P2WPKH, P2WSH, P2PK, P2TR, etc.), EVM-based networks (Ethereum and compatible chains), and other blockchains such as Litecoin, Dogecoin, Namecoin, Monacoin, Electraproto, Dash, Bitcoin Cash, Massa and Solana.

This is a Rust port of the Go library github.com/KarpelesLab/outscript. All cryptography is provided by the purecrypto crate.

Re-exports§

pub use address::eip55;
pub use address::encode_base58_addr;
pub use address::parse_bitcoin_based_address;
pub use address::parse_evm_address;
pub use btcguess::GuessResult;
pub use btcguess::guess_by_in_script;
pub use btcguess::guess_by_out_script;
pub use btctx::BtcTx;
pub use btctx::BtcTxInput;
pub use btctx::BtcTxOutput;
pub use btctx::BtcTxSign;
pub use btctx::Signer;
pub use btctxparse::BtcInputSig;
pub use btctxparse::extract_btc_input_sig;
pub use evmabi::AbiBuffer;
pub use evmabi::AbiValue;
pub use evmabi::evm_call;
pub use evmtx::EvmTx;
pub use evmtx::EvmTxType;
pub use insertable::Format;
pub use insertable::Insertable;
pub use massa::parse_massa_address;
pub use out::Out;
pub use out::get_outs;
pub use out::guess_out;
pub use pubkey::PubKey;
pub use pushbytes::parse_push_bytes;
pub use pushbytes::push_bytes;
pub use reward::block_reward;
pub use reward::cumulative_reward;
pub use script::Script;
pub use script::format_def;
pub use script::formats_per_network;
pub use solana_addr::parse_solana_address;

Modules§

address
Address parsing and encoding across Bitcoin-family, EVM, Massa and Solana networks (port of address.go, eip55.go).
base58
Base58 encoding using the Bitcoin alphabet.
bech32
Bech32 / Bech32m segwit addresses (BIP-173 / BIP-350) and Bitcoin Cash CashAddr encoding.
btcguess
Heuristics to recover a public-key hash (and possibly the pubkey) from a Bitcoin output or input script (port of btcguess.go).
btctx
Bitcoin transactions: building, signing (legacy, segwit BIP-143, taproot BIP-341/340), serialization and parsing. Port of btctx.go and btctx_p2tr.go.
btctxparse
Parsing/extraction of signatures from Bitcoin input scripts and recomputing the sighash they committed to. Port of btctxparse.go.
crypto
Cryptographic primitives used by outscript, built on purecrypto.
evmabi
EVM ABI encoding (port of evmabi.go).
evmtx
EVM transactions: legacy, EIP-2930, EIP-1559, EIP-4844. Build, sign, serialize, parse and recover sender. Port of evmtx.go.
hash
Hashing helpers built on purecrypto::hash.
insertable
Composable Insertable operations that define how an output script is derived from a public key (port of the Go Insertable/Format types).
massa
Massa address parsing (port of massa.go).
out
The Out type: a generated output script with format name and network flags, plus script-recognition helpers (guess_out, get_outs).
pubkey
Public-key abstraction used by crate::script::Script.
pushbytes
Bitcoin script PUSHDATA encoding/decoding.
reward
Block reward and cumulative-supply calculations across networks. Port of reward.go.
rlp
RLP (Recursive Length Prefix) encoding/decoding.
script
The Script engine: holds a public key and generates output scripts for various named formats, caching results.
solana
Solana keys, instructions, transactions (legacy + v0), program-derived addresses. Port of solanatx.go, solana_instructions.go, solana_pda.go.
solana_addr
Solana address parsing (port of solana.go).

Structs§

BtcAmount
A Bitcoin amount in satoshis (1 BTC = 100,000,000 satoshis).
BtcVarInt
A Bitcoin variable-length integer as defined in the Bitcoin protocol. Values 0-0xfc are a single byte; larger values use a prefix byte (0xfd, 0xfe, 0xff) followed by 2, 4, or 8 little-endian bytes.