Giter VIP home page Giter VIP logo

create-bitcoin-transaction's Introduction

Create Bitcoin Transaction

Satiate my need to understand how the engine works, not just that it works.

Personal testing ground for learning and experimenting with how various bitcoin transactions are created.


⚠️ This is experimental. Please use at your own risk.⚠️


Install

Add package to Cargo.toml file

[dependencies]
create_bitcoin_transaction = "0.1.3"

Usage:

use create_bitcoin_transaction::{
    get_signed_transaction_hex, get_unsigned_transaction_hex, PayFrom, PayTo, Wifs,
};

fn main() {
    let pay_froms = vec![PayFrom {
        transaction: "2d0821b1a1ee6d04c5f91b0b400ec38cf7613bdb06a5d43ce658e672ea66d081".to_string(),
        vout_index: 1,
        script_pub_key_hex_of_vout: "001443400caddfaffbb17b130304349384c8ef7e6fa4".to_string(), 
        address: "tb1qgdqqetwl4lamz7cnqvzrfyuyerhhumayhhprt2".to_string(), 
        vout_amount_in_sats: 30000, // 
    }];
    let pay_tos = vec![PayTo {
        address: "tb1psmsr8rc6jwl47xsv4zahnt39m2peexxhxrfvprqpw86yf55rkzgq70ycww".to_string(),
        amount_in_sats: 29878,
    }];
    let mut wifs: Wifs = Wifs::new();
    wifs.insert(
        0,
        "cSPybNQG6n1LpmxGNiWUHSSseaVfNszVjoPwo7qi4dvRE2Se825q".to_string(),
    );

    let unsigned_transaction_hex = get_unsigned_transaction_hex(&pay_froms, &pay_tos);
    println!("Unsigned transaction: {}", unsigned_transaction_hex);

    let signed_transaction_hex = get_signed_transaction_hex(&pay_froms, &pay_tos, &wifs);
    println!("Signed transaction: {}", signed_transaction_hex);
}

Resources

To read various resources used to learn how to create and sign transactions, see the RESOURCES.md

create-bitcoin-transaction's People

Contributors

joegesualdo avatar

Watchers

 avatar mrzhao avatar

Forkers

h1opok

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.