outscript
A Rust crate for generating output scripts, parsing/encoding addresses, and building/signing transactions across multiple cryptocurrency networks.
This is a Rust port of the Go library
github.com/KarpelesLab/outscript.
All cryptography is provided by the pure-Rust
purecrypto crate.
Supported Networks
| Network | Address Formats | Transactions |
|---|---|---|
| Bitcoin | p2pkh, p2pk, p2wpkh, p2sh:p2wpkh, p2wsh, p2tr | BtcTx |
| Bitcoin Cash | p2pkh, p2pk (CashAddr) | BtcTx |
| Litecoin | p2pkh, p2pk, p2wpkh, p2sh:p2wpkh | BtcTx |
| Dogecoin | p2pkh, p2pk | BtcTx |
| Namecoin | p2pkh, p2sh | BtcTx |
| Monacoin | p2pkh, p2sh, p2wpkh | BtcTx |
| Dash | p2pkh, p2sh | BtcTx |
| Electraproto | p2pkh, p2sh, p2wpkh | BtcTx |
| EVM (Ethereum, etc.) | EIP-55 checksummed | EvmTx |
| Massa | AU (user) / AS (smart contract) | - |
| Solana | Base58 (32 bytes) | SolanaTx |
Usage
Address generation
use Script;
use SecpPrivateKey;
use ed25519;
use PubKey;
// Bitcoin / EVM (secp256k1)
let key = from_bytes.unwrap;
let s = new;
let addr = s.address.unwrap; // bc1q...
let eth = s.address.unwrap; // 0x...
// Solana / Massa (ed25519)
let pk = public_from_seed;
let s = new;
let sol = s.address.unwrap; // base58
Address parsing
use ;
let out = parse_bitcoin_based_address.unwrap; // auto-detect
let out = parse_evm_address.unwrap;
let out = parse_solana_address.unwrap;
let out = parse_massa_address.unwrap;
Bitcoin transactions
use ;
let mut tx = unmarshal_binary.unwrap;
tx.sign.unwrap;
let bytes = tx.bytes;
// P2TR (BIP-341 key-path, SIGHASH_DEFAULT) — PrevScript is required.
tx.sign.unwrap;
Taproot supports both raw SecpPrivateKey signing (the library applies the
BIP-341 tweak) and external signers implementing the [Signer::sign_taproot]
method (TSS / MuSig2 / FROST / HSM). Use [crypto::secp256k1::taproot_tweak]
and [BtcTx::taproot_sighash] to compute the tweaked key and sighash offline.
EVM transactions
use ;
use BigInt;
let mut tx = EvmTx ;
tx.call.unwrap;
tx.sign.unwrap;
let data = tx.marshal_binary.unwrap;
let sender = tx.sender_address.unwrap;
Solana transactions
use ;
let ix = transfer_instruction; // lamports
let mut tx = new_solana_tx.unwrap;
tx.sign.unwrap;
let data = tx.marshal_binary.unwrap;
let txid = tx.hash.unwrap; // first signature
Block rewards
let reward = block_reward.unwrap; // 3.125 BTC in sats
let total = cumulative_reward.unwrap; // total minted
Architecture
- Format / Insertable — a sequence of operations (literal bytes, lookups, hashes, push-data, taproot tweak) that derive an output script from a key.
- Script — holds a [
PubKey] and evaluates named formats, caching results. - Out — a generated output script with its format name, hex and network flags; converts to/from human-readable addresses.
- Transactions —
BtcTx,EvmTx,SolanaTxwith binary serialization, signing and hashing.
License
See LICENSE.