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

Function bitcoin_tx_from_hex

bitcoin/tx.c:659–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657}
658
659struct bitcoin_tx *bitcoin_tx_from_hex(const tal_t *ctx, const char *hex,
660 size_t hexlen)
661{
662 const char *end;
663 u8 *linear_tx;
664 const u8 *p;
665 struct bitcoin_tx *tx;
666 size_t len;
667
668 end = memchr(hex, '\n', hexlen);
669 if (!end)
670 end = hex + hexlen;
671
672 len = hex_data_size(end - hex);
673 p = linear_tx = tal_arr(ctx, u8, len);
674 if (!hex_decode(hex, end - hex, linear_tx, len))
675 goto fail;
676
677 tx = pull_bitcoin_tx(ctx, &p, &len);
678 if (!tx)
679 goto fail;
680
681 if (len)
682 goto fail_free_tx;
683
684 tal_free(linear_tx);
685
686 return tx;
687
688fail_free_tx:
689 tal_free(tx);
690fail:
691 tal_free(linear_tx);
692 return NULL;
693}
694
695bool bitcoin_txid_from_hex(const char *hexstr, size_t hexstr_len,
696 struct bitcoin_txid *txid)

Callers 7

htlc_timeout_txFunction · 0.85
mainFunction · 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 7

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