|
libbtc
bitcoinclibrary
|
#include "btc.h"#include <stdint.h>#include <stddef.h>#include "chain.h"#include "cstr.h"#include "hash.h"#include "script.h"#include "vector.h"Go to the source code of this file.
Data Structures | |
| struct | btc_script_ |
| struct | btc_tx_outpoint_ |
| struct | btc_tx_in_ |
| struct | btc_tx_out_ |
| struct | btc_tx_ |
Typedefs | |
| typedef struct btc_script_ | btc_script |
| typedef struct btc_tx_outpoint_ | btc_tx_outpoint |
| typedef struct btc_tx_in_ | btc_tx_in |
| typedef struct btc_tx_out_ | btc_tx_out |
| typedef struct btc_tx_ | btc_tx |
Functions | |
| LIBBTC_API btc_tx_in * | btc_tx_in_new () |
| create a new tx input More... | |
| LIBBTC_API void | btc_tx_in_free (btc_tx_in *tx_in) |
| LIBBTC_API void | btc_tx_in_copy (btc_tx_in *dest, const btc_tx_in *src) |
| LIBBTC_API btc_tx_out * | btc_tx_out_new () |
| create a new tx output More... | |
| LIBBTC_API void | btc_tx_out_free (btc_tx_out *tx_out) |
| LIBBTC_API void | btc_tx_out_copy (btc_tx_out *dest, const btc_tx_out *src) |
| LIBBTC_API btc_tx * | btc_tx_new () |
| create a new tx input More... | |
| LIBBTC_API void | btc_tx_free (btc_tx *tx) |
| LIBBTC_API void | btc_tx_copy (btc_tx *dest, const btc_tx *src) |
| LIBBTC_API int | btc_tx_deserialize (const unsigned char *tx_serialized, size_t inlen, btc_tx *tx) |
| deserialize/parse a p2p serialized bitcoin transaction More... | |
| LIBBTC_API void | btc_tx_serialize (cstring *s, const btc_tx *tx) |
| serialize a lbc bitcoin data structure into a p2p serialized buffer More... | |
| LIBBTC_API void | btc_tx_hash (const btc_tx *tx, uint8_t *hashout) |
| LIBBTC_API btc_bool | btc_tx_sighash (const btc_tx *tx_to, const cstring *fromPubKey, unsigned int in_num, int hashtype, uint8_t *hash) |
| LIBBTC_API btc_bool | btc_tx_add_address_out (btc_tx *tx, const btc_chain *chain, int64_t amount, const char *address) |
| LIBBTC_API btc_bool | btc_tx_add_p2sh_hash160_out (btc_tx *tx, int64_t amount, uint8_t *hash160) |
| LIBBTC_API btc_bool | btc_tx_add_p2pkh_hash160_out (btc_tx *tx, int64_t amount, uint8_t *hash160) |
| LIBBTC_API btc_bool | btc_tx_add_p2pkh_out (btc_tx *tx, int64_t amount, const btc_pubkey *pubkey) |
| typedef struct btc_script_ btc_script |
| typedef struct btc_tx_in_ btc_tx_in |
| typedef struct btc_tx_out_ btc_tx_out |
| typedef struct btc_tx_outpoint_ btc_tx_outpoint |
| LIBBTC_API btc_bool btc_tx_add_address_out | ( | btc_tx * | tx, |
| const btc_chain * | chain, | ||
| int64_t | amount, | ||
| const char * | address | ||
| ) |
Definition at line 426 of file tx.c.
References btc_chain::b58prefix_pubkey_address, btc_chain::b58prefix_script_address, btc_base58_decode_check(), btc_tx_add_p2pkh_hash160_out(), and btc_tx_add_p2sh_hash160_out().
| LIBBTC_API btc_bool btc_tx_add_p2pkh_hash160_out | ( | btc_tx * | tx, |
| int64_t | amount, | ||
| uint8_t * | hash160 | ||
| ) |
Definition at line 447 of file tx.c.
References btc_script_build_p2pkh(), btc_tx_out_new(), cstr_new_sz(), btc_tx_out_::script_pubkey, btc_tx_out_::value, vector_add(), and btc_tx_::vout.
Referenced by btc_tx_add_address_out(), and btc_tx_add_p2pkh_out().
| LIBBTC_API btc_bool btc_tx_add_p2pkh_out | ( | btc_tx * | tx, |
| int64_t | amount, | ||
| const btc_pubkey * | pubkey | ||
| ) |
Definition at line 475 of file tx.c.
References btc_pubkey_get_hash160(), and btc_tx_add_p2pkh_hash160_out().
| LIBBTC_API btc_bool btc_tx_add_p2sh_hash160_out | ( | btc_tx * | tx, |
| int64_t | amount, | ||
| uint8_t * | hash160 | ||
| ) |
Definition at line 461 of file tx.c.
References btc_script_build_p2sh(), btc_tx_out_new(), cstr_new_sz(), btc_tx_out_::script_pubkey, btc_tx_out_::value, vector_add(), and btc_tx_::vout.
Referenced by btc_tx_add_address_out().
| LIBBTC_API void btc_tx_copy | ( | btc_tx * | dest, |
| const btc_tx * | src | ||
| ) |
Definition at line 283 of file tx.c.
References btc_tx_in_copy(), btc_tx_in_free_cb(), btc_tx_out_copy(), btc_tx_out_free_cb(), vector::len, btc_tx_::locktime, vector_add(), vector_free(), vector_idx, vector_new(), btc_tx_::version, btc_tx_::vin, and btc_tx_::vout.
Referenced by btc_tx_sighash().
| LIBBTC_API int btc_tx_deserialize | ( | const unsigned char * | tx_serialized, |
| size_t | inlen, | ||
| btc_tx * | tx | ||
| ) |
deserialize/parse a p2p serialized bitcoin transaction
Definition at line 157 of file tx.c.
References btc_tx_in_deserialize(), btc_tx_in_new(), btc_tx_out_deserialize(), btc_tx_out_new(), deser_u32(), deser_varlen(), btc_tx_::locktime, vector_add(), btc_tx_::version, btc_tx_::vin, and btc_tx_::vout.
| LIBBTC_API void btc_tx_free | ( | btc_tx * | tx | ) |
Definition at line 112 of file tx.c.
References vector_free(), btc_tx_::vin, and btc_tx_::vout.
Referenced by btc_tx_sighash().
| LIBBTC_API void btc_tx_hash | ( | const btc_tx * | tx, |
| uint8_t * | hashout | ||
| ) |
Definition at line 240 of file tx.c.
References btc_tx_serialize(), cstr_free(), cstr_new_sz(), cstring::len, sha256_Raw(), and cstring::str.
| LIBBTC_API void btc_tx_in_copy | ( | btc_tx_in * | dest, |
| const btc_tx_in * | src | ||
| ) |
Definition at line 252 of file tx.c.
References cstr_append_buf(), cstr_new_sz(), cstring::len, btc_tx_in_::prevout, btc_tx_in_::script_sig, btc_tx_in_::sequence, and cstring::str.
Referenced by btc_tx_copy().
| LIBBTC_API void btc_tx_in_free | ( | btc_tx_in * | tx_in | ) |
Definition at line 39 of file tx.c.
References cstr_free(), btc_tx_outpoint_::hash, btc_tx_outpoint_::n, btc_tx_in_::prevout, and btc_tx_in_::script_sig.
Referenced by btc_tx_in_free_cb().
| LIBBTC_API btc_tx_in* btc_tx_in_new | ( | ) |
create a new tx input
Definition at line 67 of file tx.c.
References btc_tx_in_::prevout, and btc_tx_in_::sequence.
Referenced by btc_tx_deserialize().
| LIBBTC_API btc_tx* btc_tx_new | ( | ) |
create a new tx input
Definition at line 124 of file tx.c.
References btc_tx_in_free_cb(), btc_tx_out_free_cb(), btc_tx_::locktime, vector_new(), btc_tx_::version, btc_tx_::vin, and btc_tx_::vout.
Referenced by btc_tx_sighash().
| LIBBTC_API void btc_tx_out_copy | ( | btc_tx_out * | dest, |
| const btc_tx_out * | src | ||
| ) |
Definition at line 268 of file tx.c.
References cstr_append_buf(), cstr_new_sz(), cstring::len, btc_tx_out_::script_pubkey, cstring::str, and btc_tx_out_::value.
Referenced by btc_tx_copy().
| LIBBTC_API void btc_tx_out_free | ( | btc_tx_out * | tx_out | ) |
Definition at line 77 of file tx.c.
References cstr_free(), btc_tx_out_::script_pubkey, and btc_tx_out_::value.
Referenced by btc_tx_out_free_cb().
| LIBBTC_API btc_tx_out* btc_tx_out_new | ( | ) |
create a new tx output
Definition at line 103 of file tx.c.
Referenced by btc_tx_add_p2pkh_hash160_out(), btc_tx_add_p2sh_hash160_out(), and btc_tx_deserialize().
| LIBBTC_API void btc_tx_serialize | ( | cstring * | s, |
| const btc_tx * | tx | ||
| ) |
serialize a lbc bitcoin data structure into a p2p serialized buffer
Definition at line 210 of file tx.c.
References btc_tx_in_serialize(), btc_tx_out_serialize(), vector::len, btc_tx_::locktime, ser_u32(), ser_varlen(), vector_idx, btc_tx_::version, btc_tx_::vin, and btc_tx_::vout.
Referenced by btc_tx_hash(), and btc_tx_sighash().
| LIBBTC_API btc_bool btc_tx_sighash | ( | const btc_tx * | tx_to, |
| const cstring * | fromPubKey, | ||
| unsigned int | in_num, | ||
| int | hashtype, | ||
| uint8_t * | hash | ||
| ) |
Definition at line 330 of file tx.c.
References btc_script_copy_without_op_codeseperator(), btc_tx_copy(), btc_tx_free(), btc_tx_new(), btc_tx_out_free_cb(), btc_tx_serialize(), cstr_append_buf(), cstr_free(), cstr_new_sz(), cstr_resize(), vector::len, cstring::len, btc_tx_out_::script_pubkey, btc_tx_in_::script_sig, btc_tx_in_::sequence, ser_s32(), sha256_Raw(), SIGHASH_ANYONECANPAY, SIGHASH_NONE, SIGHASH_SINGLE, cstring::str, btc_tx_out_::value, vector_free(), vector_idx, vector_new(), vector_remove_range(), vector_resize(), btc_tx_::vin, and btc_tx_::vout.
1.8.10