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

Function wally_tx_output

bitcoin/tx.c:23–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23struct wally_tx_output *wally_tx_output(const tal_t *ctx,
24 const u8 *script,
25 struct amount_sat amount)
26{
27 u64 satoshis = amount.satoshis; /* Raw: wally API */
28 struct wally_tx_output *output;
29 int ret;
30
31 tal_wally_start();
32 if (chainparams->is_elements) {
33 u8 value[9];
34 ret = wally_tx_confidential_value_from_satoshi(satoshis, value,
35 sizeof(value));
36 assert(ret == WALLY_OK);
37 ret = wally_tx_elements_output_init_alloc(
38 script, tal_bytelen(script), chainparams->fee_asset_tag, 33,
39 value, sizeof(value), NULL, 0, NULL, 0, NULL, 0, &output);
40 if (ret != WALLY_OK) {
41 output = NULL;
42 goto done;
43 }
44
45 /* Cheat a bit by also setting the numeric satoshi value,
46 * otherwise we end up converting a number of times */
47 output->satoshi = satoshis;
48 } else {
49 ret = wally_tx_output_init_alloc(satoshis, script,
50 tal_bytelen(script), &output);
51 if (ret != WALLY_OK) {
52 output = NULL;
53 goto done;
54 }
55 }
56
57done:
58 tal_wally_end_onto(ctx, output, struct wally_tx_output);
59 return output;
60}
61
62int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
63 const u8 *wscript, struct amount_sat amount)

Callers 1

bitcoin_tx_add_outputFunction · 0.70

Calls 2

tal_wally_startFunction · 0.85
tal_bytelenFunction · 0.85

Tested by

no test coverage detected