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

Function wally_tx_output

bitcoin/tx.c:22–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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