62 memset(tx_in, 0,
sizeof(*tx_in));
70 tx_in = calloc(1,
sizeof(*tx_in));
98 memset(tx_out, 0,
sizeof(*tx_out));
106 tx_out = calloc(1,
sizeof(*tx_out));
127 tx = calloc(1,
sizeof(*tx));
168 for (i = 0; i < vlen; i++) {
180 for (i = 0; i < vlen; i++) {
218 for (i = 0; i < tx->
vin->
len; i++) {
229 for (i = 0; i < tx->
vout->
len; i++) {
298 for (i = 0; i < src->
vin->
len; i++) {
302 tx_in_new = malloc(
sizeof(*tx_in_new));
319 for (i = 0; i < src->
vout->
len; i++) {
323 tx_out_new = malloc(
sizeof(*tx_out_new));
332 if (in_num >= tx_to->
vin->
len)
345 for (i = 0; i < tx_tmp->
vin->
len; i++) {
364 for (i = 0; i < tx_tmp->
vin->
len; i++) {
373 unsigned int n_out = in_num;
374 if (n_out >= tx_tmp->
vout->
len) {
382 for (i = 0; i < n_out; i++) {
394 for (i = 0; i < tx_tmp->
vin->
len; i++) {
429 uint8_t buf[strlen(address)*2];
454 tx_out->
value = amount;
468 tx_out->
value = amount;
vector * vector_new(size_t res, void(*free_f)(void *))
void btc_tx_copy(btc_tx *dest, const btc_tx *src)
void btc_tx_out_serialize(cstring *s, const btc_tx_out *tx_out)
btc_tx_out * btc_tx_out_new()
create a new tx output
void btc_tx_in_free_cb(void *data)
btc_bool btc_tx_in_deserialize(btc_tx_in *tx_in, struct const_buffer *buf)
void vector_remove_range(vector *vec, size_t pos, size_t len)
btc_bool btc_script_build_p2sh(cstring *script_in, const uint8_t *hash160)
static void ser_s32(cstring *s, int32_t v_)
void btc_tx_free(btc_tx *tx)
void ser_u32(cstring *s, uint32_t v_)
void sha256_Raw(const sha2_byte *data, size_t len, uint8_t digest[SHA256_DIGEST_LENGTH])
static void ser_s64(cstring *s, int64_t v_)
btc_bool btc_tx_add_p2sh_hash160_out(btc_tx *tx, int64_t amount, uint8_t *hash160)
btc_tx_in * btc_tx_in_new()
create a new tx input
static void ser_u256(cstring *s, const unsigned char *v_)
cstring * cstr_new_sz(size_t sz)
btc_tx * btc_tx_new()
create a new tx input
void btc_tx_hash(const btc_tx *tx, uint8_t *hashout)
void ser_varlen(cstring *s, uint32_t vlen)
void ser_varstr(cstring *s, cstring *s_in)
int btc_base58_decode_check(const char *str, uint8_t *data, size_t datalen)
void btc_tx_in_serialize(cstring *s, const btc_tx_in *tx_in)
btc_bool deser_u32(uint32_t *vo, struct const_buffer *buf)
btc_bool deser_varlen(uint32_t *lo, struct const_buffer *buf)
void btc_tx_serialize(cstring *s, const btc_tx *tx)
serialize a lbc bitcoin data structure into a p2p serialized buffer
btc_bool cstr_resize(cstring *s, size_t new_sz)
btc_bool vector_add(vector *vec, void *data)
int btc_tx_deserialize(const unsigned char *tx_serialized, size_t inlen, btc_tx *tx)
deserialize/parse a p2p serialized bitcoin transaction
btc_bool btc_tx_add_p2pkh_hash160_out(btc_tx *tx, int64_t amount, uint8_t *hash160)
#define vector_idx(vec, idx)
btc_bool btc_tx_add_address_out(btc_tx *tx, const btc_chain *chain, int64_t amount, const char *address)
btc_bool deser_varstr(cstring **so, struct const_buffer *buf)
void btc_tx_out_copy(btc_tx_out *dest, const btc_tx_out *src)
btc_bool btc_tx_add_p2pkh_out(btc_tx *tx, int64_t amount, const btc_pubkey *pubkey)
static btc_bool deser_s64(int64_t *vo, struct const_buffer *buf)
void btc_tx_in_copy(btc_tx_in *dest, const btc_tx_in *src)
void vector_free(vector *vec, btc_bool free_array)
uint8_t b58prefix_pubkey_address
void btc_tx_out_free_cb(void *data)
btc_bool btc_script_build_p2pkh(cstring *script_in, const uint8_t *hash160)
btc_bool vector_resize(vector *vec, size_t newsz)
uint8_t b58prefix_script_address
void btc_pubkey_get_hash160(const btc_pubkey *pubkey, uint8_t *hash160)
btc_bool btc_tx_sighash(const btc_tx *tx_to, const cstring *fromPubKey, unsigned int in_num, int hashtype, uint8_t *hash)
void btc_tx_out_free(btc_tx_out *tx_out)
btc_bool btc_script_copy_without_op_codeseperator(const cstring *script_in, cstring *script_out)
btc_bool btc_tx_out_deserialize(btc_tx_out *tx_out, struct const_buffer *buf)
void cstr_free(cstring *s, btc_bool free_buf)
btc_bool cstr_append_buf(cstring *s, const void *buf, size_t sz)
static btc_bool deser_u256(uint8_t *vo, struct const_buffer *buf)
void btc_tx_in_free(btc_tx_in *tx_in)