MCPcopy Create free account
hub / github.com/ElementsProject/lightning / bitcoin_tx_from_hex

Function bitcoin_tx_from_hex

bitcoin/tx.c:606–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604}
605
606struct bitcoin_tx *bitcoin_tx_from_hex(const tal_t *ctx, const char *hex,
607 size_t hexlen)
608{
609 const char *end;
610 u8 *linear_tx;
611 const u8 *p;
612 struct bitcoin_tx *tx;
613 size_t len;
614
615 end = memchr(hex, '\n', hexlen);
616 if (!end)
617 end = hex + hexlen;
618
619 len = hex_data_size(end - hex);
620 p = linear_tx = tal_arr(ctx, u8, len);
621 if (!hex_decode(hex, end - hex, linear_tx, len))
622 goto fail;
623
624 tx = pull_bitcoin_tx(ctx, &p, &len);
625 if (!tx)
626 goto fail;
627
628 if (len)
629 goto fail_free_tx;
630
631 tal_free(linear_tx);
632
633 return tx;
634
635fail_free_tx:
636 tal_free(tx);
637fail:
638 tal_free(linear_tx);
639 return NULL;
640}
641
642/* <sigh>. Bitcoind represents hashes as little-endian for RPC. */
643static void reverse_bytes(u8 *arr, size_t len)

Callers 6

htlc_timeout_txFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
test_channel_crudFunction · 0.85
tx_from_hexFunction · 0.85

Calls 4

hex_data_sizeFunction · 0.85
hex_decodeFunction · 0.85
pull_bitcoin_txFunction · 0.85
tal_freeFunction · 0.85

Tested by 6

htlc_timeout_txFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
test_channel_crudFunction · 0.68
tx_from_hexFunction · 0.68