|
libbtc
bitcoinclibrary
|
#include <stdint.h>#include <stddef.h>#include <string.h>#include "btc/base58.h"#include "btc/tx.h"#include "serialize.h"#include "sha2.h"#include "utils.h"Go to the source code of this file.
Functions | |
| void | btc_tx_in_free (btc_tx_in *tx_in) |
| void | btc_tx_in_free_cb (void *data) |
| btc_tx_in * | btc_tx_in_new () |
| create a new tx input More... | |
| void | btc_tx_out_free (btc_tx_out *tx_out) |
| void | btc_tx_out_free_cb (void *data) |
| btc_tx_out * | btc_tx_out_new () |
| create a new tx output More... | |
| void | btc_tx_free (btc_tx *tx) |
| btc_tx * | btc_tx_new () |
| create a new tx input More... | |
| btc_bool | btc_tx_in_deserialize (btc_tx_in *tx_in, struct const_buffer *buf) |
| btc_bool | btc_tx_out_deserialize (btc_tx_out *tx_out, struct const_buffer *buf) |
| int | btc_tx_deserialize (const unsigned char *tx_serialized, size_t inlen, btc_tx *tx) |
| deserialize/parse a p2p serialized bitcoin transaction More... | |
| void | btc_tx_in_serialize (cstring *s, const btc_tx_in *tx_in) |
| void | btc_tx_out_serialize (cstring *s, const btc_tx_out *tx_out) |
| void | btc_tx_serialize (cstring *s, const btc_tx *tx) |
| serialize a lbc bitcoin data structure into a p2p serialized buffer More... | |
| void | btc_tx_hash (const btc_tx *tx, uint8_t *hashout) |
| void | btc_tx_in_copy (btc_tx_in *dest, const btc_tx_in *src) |
| void | btc_tx_out_copy (btc_tx_out *dest, const btc_tx_out *src) |
| void | btc_tx_copy (btc_tx *dest, const btc_tx *src) |
| btc_bool | btc_tx_sighash (const btc_tx *tx_to, const cstring *fromPubKey, unsigned int in_num, int hashtype, uint8_t *hash) |
| btc_bool | btc_tx_add_address_out (btc_tx *tx, const btc_chain *chain, int64_t amount, const char *address) |
| btc_bool | btc_tx_add_p2pkh_hash160_out (btc_tx *tx, int64_t amount, uint8_t *hash160) |
| btc_bool | btc_tx_add_p2sh_hash160_out (btc_tx *tx, int64_t amount, uint8_t *hash160) |
| btc_bool | btc_tx_add_p2pkh_out (btc_tx *tx, int64_t amount, const btc_pubkey *pubkey) |
| 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().
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().
| 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().
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().
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().
| 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.
| 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().
| 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.
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().
| btc_bool btc_tx_in_deserialize | ( | btc_tx_in * | tx_in, |
| struct const_buffer * | buf | ||
| ) |
Definition at line 136 of file tx.c.
References deser_u256(), deser_u32(), deser_varstr(), btc_tx_outpoint_::hash, btc_tx_outpoint_::n, btc_tx_in_::prevout, btc_tx_in_::script_sig, and btc_tx_in_::sequence.
Referenced by btc_tx_deserialize().
| 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().
| void btc_tx_in_free_cb | ( | void * | data | ) |
Definition at line 54 of file tx.c.
References btc_tx_in_free().
Referenced by btc_tx_copy(), and btc_tx_new().
| 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().
Definition at line 196 of file tx.c.
References btc_tx_outpoint_::hash, btc_tx_outpoint_::n, btc_tx_in_::prevout, btc_tx_in_::script_sig, btc_tx_in_::sequence, ser_u256(), ser_u32(), and ser_varstr().
Referenced by btc_tx_serialize().
| 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().
| 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().
| btc_bool btc_tx_out_deserialize | ( | btc_tx_out * | tx_out, |
| struct const_buffer * | buf | ||
| ) |
Definition at line 148 of file tx.c.
References deser_s64(), deser_varstr(), btc_tx_out_::script_pubkey, and btc_tx_out_::value.
Referenced by btc_tx_deserialize().
| 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().
| void btc_tx_out_free_cb | ( | void * | data | ) |
Definition at line 90 of file tx.c.
References btc_tx_out_free().
Referenced by btc_tx_copy(), btc_tx_new(), and btc_tx_sighash().
| 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().
| void btc_tx_out_serialize | ( | cstring * | s, |
| const btc_tx_out * | tx_out | ||
| ) |
Definition at line 204 of file tx.c.
References btc_tx_out_::script_pubkey, ser_s64(), ser_varstr(), and btc_tx_out_::value.
Referenced by btc_tx_serialize().
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().
| 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