All Projects → shesek → Minsc

shesek / Minsc

Licence: mit
A Miniscript-based high-level scripting language for Bitcoin contracts

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Minsc

Hadoopcryptoledger
Hadoop Crypto Ledger - Analyzing CryptoLedgers, such as Bitcoin Blockchain, on Big Data platforms, such as Hadoop/Spark/Flink/Hive
Stars: ✭ 126 (-8.03%)
Mutual labels:  bitcoin
Phptrader
A simple php powered Bitcoin and Ethereum trading bot
Stars: ✭ 131 (-4.38%)
Mutual labels:  bitcoin
Bitcoin Kit Ios
Full Bitcoin library for iOS, implemented on Swift. SPV wallet implementation for Bitcoin, Bitcoin Cash and Dash blockchains.
Stars: ✭ 134 (-2.19%)
Mutual labels:  bitcoin
Phoenix
Phoenix is a non custodial Bitcoin wallet using Lightning to send/receive payments.
Stars: ✭ 129 (-5.84%)
Mutual labels:  bitcoin
Coinnect
Coinnect is a Rust library aiming to provide a complete access to main crypto currencies exchanges via REST API.
Stars: ✭ 130 (-5.11%)
Mutual labels:  bitcoin
Base58
Base58 and Base58Check implementation compatible with what is used by the bitcoin network.
Stars: ✭ 132 (-3.65%)
Mutual labels:  bitcoin
Ptarmigan
Lightning Network (BOLT)
Stars: ✭ 125 (-8.76%)
Mutual labels:  bitcoin
Bitiodine
A Rust Bitcoin blockchain parser with clustering capabilities, allowing to group together addresses in ownership clusters. Please contact @mikispag if interested in using BitIodine for any real-world use case.
Stars: ✭ 135 (-1.46%)
Mutual labels:  bitcoin
Paypercall
Charge for HTTP APIs on a pay-per-call basis with Bitcoin and Lightning ⚡️
Stars: ✭ 131 (-4.38%)
Mutual labels:  bitcoin
Umbrel Os
Run Umbrel Bitcoin and Lightning node on a Raspberry Pi in one click
Stars: ✭ 132 (-3.65%)
Mutual labels:  bitcoin
Orko
Trade on and script multiple crypto exchanges from a single user interface on desktop and mobile. In development.
Stars: ✭ 128 (-6.57%)
Mutual labels:  bitcoin
Awesome Bitcoin Payment Processors
🌟 A curated list of Bitcoin payment processors enabling merchants, businesses and nonprofits to accept Bitcoin payments.
Stars: ✭ 129 (-5.84%)
Mutual labels:  bitcoin
Awdy
are we decentralized yet? an analysis of how truly decentralized cryptocurrency networks are
Stars: ✭ 133 (-2.92%)
Mutual labels:  bitcoin
Nakamoto
Bitcoin light-client implementation in Rust
Stars: ✭ 129 (-5.84%)
Mutual labels:  bitcoin
Blockchain2graph
Blockchain2graph extracts blockchain data (bitcoin) and insert them into a graph database (neo4j).
Stars: ✭ 134 (-2.19%)
Mutual labels:  bitcoin
Blinktradejs
BlinkTrade JavaScript SDK and CLI
Stars: ✭ 126 (-8.03%)
Mutual labels:  bitcoin
Chainabstractionlayer
Blockchain abstraction layer
Stars: ✭ 131 (-4.38%)
Mutual labels:  bitcoin
Lstm Crypto Price Prediction
Predicting price trends in cryptomarkets using an lstm-RNN for the use of a trading bot
Stars: ✭ 136 (-0.73%)
Mutual labels:  bitcoin
Lnbits
LNbits, free and open-source lightning-network wallet/accounts system.
Stars: ✭ 135 (-1.46%)
Mutual labels:  bitcoin
Binance grid trader
A grid trading strategy and trading-bot for Binance Exchange. 币安交易所的网格交易
Stars: ✭ 132 (-3.65%)
Mutual labels:  bitcoin

Build Status crates.io npm MIT license Pull Requests Welcome

Minsc

A Miniscript-based scripting language for Bitcoin contracts

Minsc is a high-level scripting language for expressing Bitcoin Script spending conditions. It is based on the Miniscript Policy language, with additional features and syntactic sugar sprinkled on top, including variables, functions, infix notation, human-readable times and more.

Documentation & live playground are available on the website: https://min.sc

Support development: ⛓️ on-chain or ⚡ lightning via BTCPay

Examples

  • A user and a 2FA service need to sign off, but after 90 days the user alone is enough

    pk(user_pk) && (pk(service_pk) || older(90 days))
    

    ▶️ Try it live

  • Traditional preimage-based HTLC

    $redeem = pk(A) && sha256(H);
    $refund = pk(B) && older(10);
    
    $redeem || $refund
    

    ▶️ Try it live

  • Liquid-like federated pegin, with emergency recovery keys that become active after a timeout

    $federation = 4 of [ pk(A), pk(B), pk(C), pk(D), pk(E) ];
    $recovery = 2 of [ pk(F), pk(G), pk(I) ];
    $timeout = older(3 months);
    
    likely@$federation || ($timeout && $recovery)
    

    ▶️ Try it live

  • The BOLT #3 received HTLC policy

    fn bolt3_htlc_received($revoke_pk, $local_pk, $remote_pk, $secret, $delay) {
      $success = pk($local_pk) && hash160($secret);
      $timeout = older($delay);
    
      pk($revoke_pk) || (pk($remote_pk) && ($success || $timeout))
    }
    
    bolt3_htlc_received(A, B, C, H1, 2 hours)
    

    ▶️ Try it live

  • Advanced 2FA where the user has a 2-of-2 setup and the service provider is a 3-of-4 federation

    fn two_factor($user, $provider, $delay) =
      $user && (likely@$provider || older($delay));
    
    $user = pk(desktop_pk) && pk(mobile_pk);
    $providers = [ pk(A), pk(B), pk(C), pk(D) ];
    
    two_factor($user, 3 of $providers, 4 months)
    

    ▶️ Try it live

More examples are available on https://min.sc.

Local installation

Install Rust and:

$ cargo install minsc

# Compile a minsc file
$ minsc examples/htlc.minsc

# Compile from stdin
$ echo 'pk(A) && older(1 week)' | minsc -

# Dump AST
$ minsc examples/htlc.minsc --ast

Using the Rust API:

use minsc::{parse, run, eval};

let code = "pk(A) && older(1 week)";
let ast = parse(&code).unwrap();
let result = eval(ast).unwrap();
// or parse+eval in one go with `run(&code)`

let policy = result.into_policy().unwrap();
println!("{}", policy);

// also available: into_miniscript() and into_desc()

Full documentation for the Rust API is available here.

JavaScript WASM package

Install with npm install minsc and:

import { run } from 'minsc'

const policy = run('pk(A) && older(1 week)')
const miniscript = run('miniscript(pk(A) && older(1 week))')
const descriptor = run('wsh(miniscript(pk(A) && older(1 week)))')
const address = run('address(wsh(miniscript(pk(A) && older(1 week))))')
const address2 = run('address(pk(A) && older(1 week))')

console.log({ policy, miniscript, descriptor, address, address2 })

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].