mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
global: use tal_dup_or_null().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -546,13 +546,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
|
|||||||
htlc->fail_immediate = false;
|
htlc->fail_immediate = false;
|
||||||
|
|
||||||
htlc->rhash = *payment_hash;
|
htlc->rhash = *payment_hash;
|
||||||
if (blinding)
|
htlc->blinding = tal_dup_or_null(htlc, struct pubkey, blinding);
|
||||||
htlc->blinding = tal_dup(htlc, struct pubkey, blinding);
|
|
||||||
else {
|
|
||||||
/* Can be taken, even if NULL. */
|
|
||||||
taken(blinding);
|
|
||||||
htlc->blinding = NULL;
|
|
||||||
}
|
|
||||||
htlc->failed = NULL;
|
htlc->failed = NULL;
|
||||||
htlc->r = NULL;
|
htlc->r = NULL;
|
||||||
htlc->routing = tal_dup_arr(htlc, u8, routing, TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE), 0);
|
htlc->routing = tal_dup_arr(htlc, u8, routing, TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE), 0);
|
||||||
|
|||||||
@@ -101,11 +101,9 @@ struct height_states *dup_height_states(const tal_t *ctx,
|
|||||||
tal_steal(ctx, states));
|
tal_steal(ctx, states));
|
||||||
|
|
||||||
n = tal_dup(ctx, struct height_states, states);
|
n = tal_dup(ctx, struct height_states, states);
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(n->height); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(n->height); i++)
|
||||||
if (n->height[i])
|
n->height[i] = tal_dup_or_null(n, u32, n->height[i]);
|
||||||
n->height[i] = tal_dup(n, u32, n->height[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,10 +105,7 @@ static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx,
|
|||||||
|
|
||||||
/* for htlc's that are filled onchain, we also have a
|
/* for htlc's that are filled onchain, we also have a
|
||||||
* preimage, NULL otherwise */
|
* preimage, NULL otherwise */
|
||||||
if (payment_hash)
|
mvt->payment_hash = tal_dup_or_null(mvt, struct sha256, payment_hash);
|
||||||
mvt->payment_hash = tal_dup(mvt, struct sha256, payment_hash);
|
|
||||||
else
|
|
||||||
mvt->payment_hash = NULL;
|
|
||||||
mvt->blockheight = blockheight;
|
mvt->blockheight = blockheight;
|
||||||
|
|
||||||
mvt->tags = tal_steal(mvt, tags);
|
mvt->tags = tal_steal(mvt, tags);
|
||||||
|
|||||||
@@ -48,10 +48,9 @@ struct fee_states *dup_fee_states(const tal_t *ctx,
|
|||||||
return cast_const(struct fee_states *,
|
return cast_const(struct fee_states *,
|
||||||
tal_steal(ctx, fee_states));
|
tal_steal(ctx, fee_states));
|
||||||
n = tal_dup(ctx, struct fee_states, fee_states);
|
n = tal_dup(ctx, struct fee_states, fee_states);
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(n->feerate); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(n->feerate); i++)
|
||||||
if (n->feerate[i])
|
n->feerate[i] = tal_dup_or_null(n, u32, n->feerate[i]);
|
||||||
n->feerate[i] = tal_dup(n, u32, n->feerate[i]);
|
|
||||||
}
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ static struct failed_htlc *failed_htlc_dup(const tal_t *ctx,
|
|||||||
return cast_const(struct failed_htlc *, tal_steal(ctx, f));
|
return cast_const(struct failed_htlc *, tal_steal(ctx, f));
|
||||||
newf = tal(ctx, struct failed_htlc);
|
newf = tal(ctx, struct failed_htlc);
|
||||||
newf->id = f->id;
|
newf->id = f->id;
|
||||||
if (f->sha256_of_onion)
|
newf->sha256_of_onion = tal_dup_or_null(newf, struct sha256,
|
||||||
newf->sha256_of_onion = tal_dup(newf, struct sha256, f->sha256_of_onion);
|
f->sha256_of_onion);
|
||||||
else
|
|
||||||
newf->sha256_of_onion = NULL;
|
|
||||||
newf->badonion = f->badonion;
|
newf->badonion = f->badonion;
|
||||||
if (f->onion)
|
if (f->onion)
|
||||||
newf->onion = dup_onionreply(newf, f->onion);
|
newf->onion = dup_onionreply(newf, f->onion);
|
||||||
@@ -46,15 +44,9 @@ struct existing_htlc *new_existing_htlc(const tal_t *ctx,
|
|||||||
existing->payment_hash = *payment_hash;
|
existing->payment_hash = *payment_hash;
|
||||||
memcpy(existing->onion_routing_packet, onion_routing_packet,
|
memcpy(existing->onion_routing_packet, onion_routing_packet,
|
||||||
sizeof(existing->onion_routing_packet));
|
sizeof(existing->onion_routing_packet));
|
||||||
if (blinding)
|
existing->blinding = tal_dup_or_null(existing, struct pubkey, blinding);
|
||||||
existing->blinding = tal_dup(existing, struct pubkey, blinding);
|
existing->payment_preimage
|
||||||
else
|
= tal_dup_or_null(existing, struct preimage, preimage);
|
||||||
existing->blinding = NULL;
|
|
||||||
if (preimage)
|
|
||||||
existing->payment_preimage
|
|
||||||
= tal_dup(existing, struct preimage, preimage);
|
|
||||||
else
|
|
||||||
existing->payment_preimage = NULL;
|
|
||||||
if (failed)
|
if (failed)
|
||||||
existing->failed = failed_htlc_dup(existing, failed);
|
existing->failed = failed_htlc_dup(existing, failed);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -355,10 +355,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
p->payment_secret = NULL;
|
p->payment_secret = NULL;
|
||||||
if (blinding)
|
p->blinding = tal_dup_or_null(p, struct pubkey, blinding);
|
||||||
p->blinding = tal_dup(p, struct pubkey, blinding);
|
|
||||||
else
|
|
||||||
p->blinding = NULL;
|
|
||||||
|
|
||||||
#if EXPERIMENTAL_FEATURES
|
#if EXPERIMENTAL_FEATURES
|
||||||
if (!p->blinding) {
|
if (!p->blinding) {
|
||||||
|
|||||||
@@ -183,12 +183,9 @@ new_inflight(struct channel *channel,
|
|||||||
/* Channel lease infos */
|
/* Channel lease infos */
|
||||||
inflight->lease_blockheight_start = lease_blockheight_start;
|
inflight->lease_blockheight_start = lease_blockheight_start;
|
||||||
inflight->lease_expiry = lease_expiry;
|
inflight->lease_expiry = lease_expiry;
|
||||||
if (lease_commit_sig)
|
inflight->lease_commit_sig
|
||||||
inflight->lease_commit_sig
|
= tal_dup_or_null(inflight, secp256k1_ecdsa_signature,
|
||||||
= tal_dup(inflight, secp256k1_ecdsa_signature,
|
|
||||||
lease_commit_sig);
|
lease_commit_sig);
|
||||||
else
|
|
||||||
inflight->lease_commit_sig = NULL;
|
|
||||||
|
|
||||||
inflight->lease_chan_max_msat = lease_chan_max_msat;
|
inflight->lease_chan_max_msat = lease_chan_max_msat;
|
||||||
inflight->lease_chan_max_ppt = lease_chan_max_ppt;
|
inflight->lease_chan_max_ppt = lease_chan_max_ppt;
|
||||||
|
|||||||
@@ -214,10 +214,7 @@ void delay_then_reconnect(struct channel *channel, u32 seconds_delay,
|
|||||||
d = tal(channel, struct delayed_reconnect);
|
d = tal(channel, struct delayed_reconnect);
|
||||||
d->channel = channel;
|
d->channel = channel;
|
||||||
d->seconds_delayed = seconds_delay;
|
d->seconds_delayed = seconds_delay;
|
||||||
if (addrhint)
|
d->addrhint = tal_dup_or_null(d, struct wireaddr_internal, addrhint);
|
||||||
d->addrhint = tal_dup(d, struct wireaddr_internal, addrhint);
|
|
||||||
else
|
|
||||||
d->addrhint = NULL;
|
|
||||||
|
|
||||||
log_debug(channel->log, "Will try reconnect in %u seconds",
|
log_debug(channel->log, "Will try reconnect in %u seconds",
|
||||||
seconds_delay);
|
seconds_delay);
|
||||||
|
|||||||
@@ -144,10 +144,7 @@ struct htlc_in *new_htlc_in(const tal_t *ctx,
|
|||||||
hin->payment_hash = *payment_hash;
|
hin->payment_hash = *payment_hash;
|
||||||
hin->status = NULL;
|
hin->status = NULL;
|
||||||
hin->fail_immediate = fail_immediate;
|
hin->fail_immediate = fail_immediate;
|
||||||
if (shared_secret)
|
hin->shared_secret = tal_dup_or_null(hin, struct secret, shared_secret);
|
||||||
hin->shared_secret = tal_dup(hin, struct secret, shared_secret);
|
|
||||||
else
|
|
||||||
hin->shared_secret = NULL;
|
|
||||||
if (blinding) {
|
if (blinding) {
|
||||||
hin->blinding = tal_dup(hin, struct pubkey, blinding);
|
hin->blinding = tal_dup(hin, struct pubkey, blinding);
|
||||||
hin->blinding_ss = *blinding_ss;
|
hin->blinding_ss = *blinding_ss;
|
||||||
@@ -303,10 +300,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
|
|||||||
hout->preimage = NULL;
|
hout->preimage = NULL;
|
||||||
hout->timeout = NULL;
|
hout->timeout = NULL;
|
||||||
|
|
||||||
if (blinding)
|
hout->blinding = tal_dup_or_null(hout, struct pubkey, blinding);
|
||||||
hout->blinding = tal_dup(hout, struct pubkey, blinding);
|
|
||||||
else
|
|
||||||
hout->blinding = NULL;
|
|
||||||
hout->am_origin = am_origin;
|
hout->am_origin = am_origin;
|
||||||
if (am_origin) {
|
if (am_origin) {
|
||||||
hout->partid = partid;
|
hout->partid = partid;
|
||||||
|
|||||||
@@ -306,11 +306,8 @@ new_log(const tal_t *ctx, struct log_book *record,
|
|||||||
* by log entries, too */
|
* by log entries, too */
|
||||||
log->prefix = log_prefix_new(log->lr, take(tal_vfmt(NULL, fmt, ap)));
|
log->prefix = log_prefix_new(log->lr, take(tal_vfmt(NULL, fmt, ap)));
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (default_node_id)
|
log->default_node_id = tal_dup_or_null(log, struct node_id,
|
||||||
log->default_node_id = tal_dup(log, struct node_id,
|
|
||||||
default_node_id);
|
default_node_id);
|
||||||
else
|
|
||||||
log->default_node_id = NULL;
|
|
||||||
|
|
||||||
/* Initialized on first use */
|
/* Initialized on first use */
|
||||||
log->print_level = NULL;
|
log->print_level = NULL;
|
||||||
|
|||||||
@@ -495,11 +495,8 @@ remote_routing_failure(const tal_t *ctx,
|
|||||||
routing_failure->failcode = failcode;
|
routing_failure->failcode = failcode;
|
||||||
routing_failure->msg = tal_dup_talarr(routing_failure, u8, failuremsg);
|
routing_failure->msg = tal_dup_talarr(routing_failure, u8, failuremsg);
|
||||||
|
|
||||||
if (erring_node != NULL)
|
routing_failure->erring_node =
|
||||||
routing_failure->erring_node =
|
tal_dup_or_null(routing_failure, struct node_id, erring_node);
|
||||||
tal_dup(routing_failure, struct node_id, erring_node);
|
|
||||||
else
|
|
||||||
routing_failure->erring_node = NULL;
|
|
||||||
|
|
||||||
if (erring_channel != NULL) {
|
if (erring_channel != NULL) {
|
||||||
routing_failure->erring_channel = tal_dup(
|
routing_failure->erring_channel = tal_dup(
|
||||||
@@ -1081,10 +1078,8 @@ send_payment_core(struct lightningd *ld,
|
|||||||
payment->payment_hash = *rhash;
|
payment->payment_hash = *rhash;
|
||||||
payment->partid = partid;
|
payment->partid = partid;
|
||||||
payment->groupid = group;
|
payment->groupid = group;
|
||||||
if (destination)
|
payment->destination = tal_dup_or_null(payment, struct node_id,
|
||||||
payment->destination = tal_dup(payment, struct node_id, destination);
|
destination);
|
||||||
else
|
|
||||||
payment->destination = NULL;
|
|
||||||
payment->status = PAYMENT_PENDING;
|
payment->status = PAYMENT_PENDING;
|
||||||
payment->msatoshi = msat;
|
payment->msatoshi = msat;
|
||||||
payment->msatoshi_sent = first_hop->amount;
|
payment->msatoshi_sent = first_hop->amount;
|
||||||
@@ -1092,14 +1087,8 @@ send_payment_core(struct lightningd *ld,
|
|||||||
payment->timestamp = time_now().ts.tv_sec;
|
payment->timestamp = time_now().ts.tv_sec;
|
||||||
payment->payment_preimage = NULL;
|
payment->payment_preimage = NULL;
|
||||||
payment->path_secrets = tal_steal(payment, path_secrets);
|
payment->path_secrets = tal_steal(payment, path_secrets);
|
||||||
if (route_nodes)
|
payment->route_nodes = tal_steal(payment, route_nodes);
|
||||||
payment->route_nodes = tal_steal(payment, route_nodes);
|
payment->route_channels = tal_steal(payment, route_channels);
|
||||||
else
|
|
||||||
payment->route_nodes = NULL;
|
|
||||||
if (route_channels)
|
|
||||||
payment->route_channels = tal_steal(payment, route_channels);
|
|
||||||
else
|
|
||||||
payment->route_channels = NULL;
|
|
||||||
payment->failonion = NULL;
|
payment->failonion = NULL;
|
||||||
if (label != NULL)
|
if (label != NULL)
|
||||||
payment->label = tal_strdup(payment, label);
|
payment->label = tal_strdup(payment, label);
|
||||||
@@ -1109,10 +1098,8 @@ send_payment_core(struct lightningd *ld,
|
|||||||
payment->invstring = tal_strdup(payment, invstring);
|
payment->invstring = tal_strdup(payment, invstring);
|
||||||
else
|
else
|
||||||
payment->invstring = NULL;
|
payment->invstring = NULL;
|
||||||
if (local_offer_id)
|
payment->local_offer_id = tal_dup_or_null(payment, struct sha256,
|
||||||
payment->local_offer_id = tal_dup(payment, struct sha256, local_offer_id);
|
local_offer_id);
|
||||||
else
|
|
||||||
payment->local_offer_id = NULL;
|
|
||||||
|
|
||||||
/* We write this into db when HTLC is actually sent. */
|
/* We write this into db when HTLC is actually sent. */
|
||||||
wallet_payment_setup(ld->wallet, payment);
|
wallet_payment_setup(ld->wallet, payment);
|
||||||
|
|||||||
@@ -753,10 +753,7 @@ static struct subd *new_subd(struct lightningd *ld,
|
|||||||
list_head_init(&sd->reqs);
|
list_head_init(&sd->reqs);
|
||||||
sd->channel = channel;
|
sd->channel = channel;
|
||||||
sd->rcvd_version = false;
|
sd->rcvd_version = false;
|
||||||
if (node_id)
|
sd->node_id = tal_dup_or_null(sd, struct node_id, node_id);
|
||||||
sd->node_id = tal_dup(sd, struct node_id, node_id);
|
|
||||||
else
|
|
||||||
sd->node_id = NULL;
|
|
||||||
|
|
||||||
/* conn actually owns daemon: we die when it does. */
|
/* conn actually owns daemon: we die when it does. */
|
||||||
sd->conn = io_new_conn(ld, msg_fd, msg_setup, sd);
|
sd->conn = io_new_conn(ld, msg_fd, msg_setup, sd);
|
||||||
|
|||||||
@@ -929,11 +929,8 @@ new_tracked_output(struct tracked_output ***outs,
|
|||||||
if (htlc)
|
if (htlc)
|
||||||
out->htlc = *htlc;
|
out->htlc = *htlc;
|
||||||
out->wscript = tal_steal(out, wscript);
|
out->wscript = tal_steal(out, wscript);
|
||||||
if (remote_htlc_sig)
|
out->remote_htlc_sig = tal_dup_or_null(out, struct bitcoin_signature,
|
||||||
out->remote_htlc_sig = tal_dup(out, struct bitcoin_signature,
|
|
||||||
remote_htlc_sig);
|
remote_htlc_sig);
|
||||||
else
|
|
||||||
out->remote_htlc_sig = NULL;
|
|
||||||
|
|
||||||
tal_arr_expand(outs, out);
|
tal_arr_expand(outs, out);
|
||||||
|
|
||||||
|
|||||||
@@ -2361,9 +2361,7 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||||||
feature_offered(b11->features, OPT_VAR_ONION);
|
feature_offered(b11->features, OPT_VAR_ONION);
|
||||||
p->payment_hash = tal_dup(p, struct sha256, &b11->payment_hash);
|
p->payment_hash = tal_dup(p, struct sha256, &b11->payment_hash);
|
||||||
p->payment_secret =
|
p->payment_secret =
|
||||||
b11->payment_secret
|
tal_dup_or_null(p, struct secret, b11->payment_secret);
|
||||||
? tal_dup(p, struct secret, b11->payment_secret)
|
|
||||||
: NULL;
|
|
||||||
p->routes = tal_steal(p, b11->routes);
|
p->routes = tal_steal(p, b11->routes);
|
||||||
p->min_final_cltv_expiry = b11->min_final_cltv_expiry;
|
p->min_final_cltv_expiry = b11->min_final_cltv_expiry;
|
||||||
p->features = tal_steal(p, b11->features);
|
p->features = tal_steal(p, b11->features);
|
||||||
|
|||||||
Reference in New Issue
Block a user