@@ -132,21 +132,12 @@ static bool is_valid_elements_tx_input_pegin(const struct wally_tx_input *input)
132132 return is_valid_elements_tx_input (input ) && (input -> features & WALLY_TX_IS_PEGIN );
133133}
134134
135- static bool is_null_bytes (const unsigned char * bytes , size_t bytes_len )
136- {
137- size_t i ;
138- for (i = 0 ; i < bytes_len ; ++ i )
139- if (bytes [i ])
140- return false;
141- return true;
142- }
143-
144135static bool is_coinbase_bytes (const unsigned char * bytes , size_t bytes_len , uint32_t index )
145136{
146- return index == 0xffffffff && is_null_bytes (bytes , bytes_len );
137+ return index == 0xffffffff && mem_is_zero (bytes , bytes_len );
147138}
148139
149- static bool is_valid_coinbase_input (const struct wally_tx_input * input )
140+ static bool is_coinbase_input (const struct wally_tx_input * input )
150141{
151142 return input && is_coinbase_bytes (input -> txhash , sizeof (input -> txhash ), input -> index );
152143}
@@ -3252,32 +3243,35 @@ int wally_tx_from_hex(const char *hex, uint32_t flags,
32523243
32533244int wally_tx_is_elements (const struct wally_tx * tx , size_t * written )
32543245{
3246+ if (written )
3247+ * written = 0 ;
32553248 if (!tx || !written )
32563249 return WALLY_EINVAL ;
32573250
32583251 * written = is_valid_elements_tx (tx );
3259-
32603252 return WALLY_OK ;
32613253}
32623254
32633255int wally_tx_elements_input_is_pegin (const struct wally_tx_input * input ,
32643256 size_t * written )
32653257{
3258+ if (written )
3259+ * written = 0 ;
32663260 if (!input || !written )
32673261 return WALLY_EINVAL ;
32683262
32693263 * written = is_valid_elements_tx_input_pegin (input );
3270-
32713264 return WALLY_OK ;
32723265}
32733266
32743267int wally_tx_is_coinbase (const struct wally_tx * tx , size_t * written )
32753268{
3269+ if (written )
3270+ * written = 0 ;
32763271 if (!tx || !written )
32773272 return WALLY_EINVAL ;
32783273
3279- * written = tx -> num_inputs == 1 && is_valid_coinbase_input (tx -> inputs );
3280-
3274+ * written = tx -> num_inputs == 1 && is_coinbase_input (tx -> inputs );
32813275 return WALLY_OK ;
32823276}
32833277
0 commit comments