38 if (script_in->
len == 0)
84 script_op = calloc(1,
sizeof(*script_op));
92 if (script_op->
data) {
93 free(script_op->
data);
94 script_op->
data = NULL;
110 if (script_in->
len == 0)
114 unsigned char opcode;
117 while (buf.
len > 0) {
149 op->
data = calloc(1, data_len);
150 memcpy(op->
data, &buf.
p, data_len);
172 return (op->
op == opcode);
196 return ((ops->
len == 2) &&
204 return ((ops->
len == 5) &&
215 return ((ops->
len == 3) &&
223 return ((op->
op ==
OP_0) ||
229 if ((ops->
len < 3) || (ops->
len > (16 + 3)) ||
236 for (i = 1; i < (ops->
len - 2); i++)
259 assert(n >= 0 && n <= 16);
278 else if (datalen <= 0xff)
283 else if (datalen <= 0xffff)
286 uint16_t v = htole16(datalen);
292 uint32_t v = htole32(datalen);
302 if(required_signatures > 16 || pubkeys_chars->
len > 16)
308 for (i = 0; i < (int)pubkeys_chars->
len; i++)
btc_bool deser_skip(struct const_buffer *buf, size_t len)
btc_bool btc_script_build_p2sh(cstring *script_in, const uint8_t *hash160)
btc_script_op * btc_script_op_new()
enum btc_tx_out_type btc_script_classify(vector *ops)
static void btc_script_append_pushdata(cstring *script_in, unsigned char *data, size_t datalen)
btc_bool btc_script_is_scripthash(vector *ops)
#define BTC_ECKEY_COMPRESSED_LENGTH
#define BTC_ECKEY_UNCOMPRESSED_LENGTH
static btc_bool btc_script_is_pushdata(enum opcodetype op)
btc_bool btc_script_is_multisig(vector *ops)
btc_bool deser_u32(uint32_t *vo, struct const_buffer *buf)
void btc_script_op_free(btc_script_op *script_op)
btc_bool deser_bytes(void *po, struct const_buffer *buf, size_t len)
btc_bool cstr_resize(cstring *s, size_t new_sz)
btc_bool vector_add(vector *vec, void *data)
btc_bool deser_u16(uint16_t *vo, struct const_buffer *buf)
static btc_bool btc_script_is_op_pubkey(const btc_script_op *op)
#define vector_idx(vec, idx)
static void btc_script_append_op(cstring *script_in, enum opcodetype op)
static btc_bool btc_script_is_op_smallint(const btc_script_op *op)
static enum opcodetype btc_encode_op_n(int n)
btc_bool btc_script_build_multisig(cstring *script_in, unsigned int required_signatures, vector *pubkeys_chars)
btc_bool btc_script_is_pubkey(vector *ops)
btc_bool btc_script_build_p2pkh(cstring *script_in, const uint8_t *hash160)
void btc_script_op_free_cb(void *data)
static btc_bool btc_script_is_op(const btc_script_op *op, enum opcodetype opcode)
btc_bool btc_script_copy_without_op_codeseperator(const cstring *script_in, cstring *script_out)
btc_bool cstr_append_buf(cstring *s, const void *buf, size_t sz)
uint8_t pubkey[BTC_ECKEY_UNCOMPRESSED_LENGTH]
static btc_bool btc_script_is_op_pubkeyhash(const btc_script_op *op)
btc_bool btc_script_is_pubkeyhash(vector *ops)
btc_bool btc_script_get_ops(const cstring *script_in, vector *ops_out)