mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
tools/generate_wire.py: make bitcoin_tx a varlen structs
Now it allocates naturally. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
526d3a232e
commit
674a2c7554
@ -1150,8 +1150,7 @@ static void handle_onchain_broadcast_tx(struct peer *peer, const u8 *msg)
|
||||
{
|
||||
struct bitcoin_tx *tx;
|
||||
|
||||
tx = tal(msg, struct bitcoin_tx);
|
||||
if (!fromwire_onchain_broadcast_tx(msg, NULL, tx)) {
|
||||
if (!fromwire_onchain_broadcast_tx(msg, msg, NULL, &tx)) {
|
||||
peer_internal_error(peer, "Invalid onchain_broadcast_tx");
|
||||
return;
|
||||
}
|
||||
@ -1581,12 +1580,12 @@ static void opening_got_hsm_funding_sig(struct funding_channel *fc,
|
||||
const struct crypto_state *cs,
|
||||
u64 gossip_index)
|
||||
{
|
||||
struct bitcoin_tx *tx = tal(fc, struct bitcoin_tx);
|
||||
struct bitcoin_tx *tx;
|
||||
u8 *linear;
|
||||
u64 change_satoshi;
|
||||
struct json_result *response = new_json_result(fc->cmd);
|
||||
|
||||
if (!fromwire_hsm_sign_funding_reply(resp, NULL, tx))
|
||||
if (!fromwire_hsm_sign_funding_reply(fc, resp, NULL, &tx))
|
||||
fatal("HSM gave bad sign_funding_reply %s",
|
||||
tal_hex(fc, resp));
|
||||
|
||||
@ -1788,9 +1787,9 @@ static bool better_closing_fee(struct peer *peer, const struct bitcoin_tx *tx)
|
||||
static void peer_received_closing_signature(struct peer *peer, const u8 *msg)
|
||||
{
|
||||
secp256k1_ecdsa_signature sig;
|
||||
struct bitcoin_tx *tx = tal(msg, struct bitcoin_tx);
|
||||
struct bitcoin_tx *tx;
|
||||
|
||||
if (!fromwire_closing_received_signature(msg, NULL, &sig, tx)) {
|
||||
if (!fromwire_closing_received_signature(msg, msg, NULL, &sig, &tx)) {
|
||||
peer_internal_error(peer, "Bad closing_received_signature %s",
|
||||
tal_hex(peer, msg));
|
||||
return;
|
||||
@ -2220,14 +2219,13 @@ static void opening_funder_finished(struct subd *opening, const u8 *resp,
|
||||
/* At this point, we care about peer */
|
||||
fc->peer->channel_info = channel_info
|
||||
= tal(fc->peer, struct channel_info);
|
||||
remote_commit = tal(resp, struct bitcoin_tx);
|
||||
|
||||
/* This is a new channel_info->their_config so set its ID to 0 */
|
||||
fc->peer->channel_info->their_config.id = 0;
|
||||
|
||||
if (!fromwire_opening_funder_reply(resp, NULL,
|
||||
if (!fromwire_opening_funder_reply(resp, resp, NULL,
|
||||
&channel_info->their_config,
|
||||
remote_commit,
|
||||
&remote_commit,
|
||||
&remote_commit_sig,
|
||||
&cs,
|
||||
&gossip_index,
|
||||
@ -2340,8 +2338,6 @@ static void opening_fundee_finished(struct subd *opening,
|
||||
log_debug(peer->log, "Got opening_fundee_finish_response");
|
||||
assert(tal_count(fds) == 2);
|
||||
|
||||
remote_commit = tal(reply, struct bitcoin_tx);
|
||||
|
||||
/* At this point, we care about peer */
|
||||
peer->channel_info = channel_info = tal(peer, struct channel_info);
|
||||
/* This is a new channel_info->their_config, set its ID to 0 */
|
||||
@ -2350,7 +2346,7 @@ static void opening_fundee_finished(struct subd *opening,
|
||||
peer->funding_txid = tal(peer, struct bitcoin_txid);
|
||||
if (!fromwire_opening_fundee_reply(tmpctx, reply, NULL,
|
||||
&channel_info->their_config,
|
||||
remote_commit,
|
||||
&remote_commit,
|
||||
&remote_commit_sig,
|
||||
&cs,
|
||||
&gossip_index,
|
||||
|
@ -1081,7 +1081,7 @@ void peer_got_commitsig(struct peer *peer, const u8 *msg)
|
||||
struct fulfilled_htlc *fulfilled;
|
||||
struct failed_htlc **failed;
|
||||
struct changed_htlc *changed;
|
||||
struct bitcoin_tx *tx = tal(msg, struct bitcoin_tx);
|
||||
struct bitcoin_tx *tx;
|
||||
size_t i;
|
||||
|
||||
if (!fromwire_channel_got_commitsig(msg, msg, NULL,
|
||||
@ -1094,7 +1094,7 @@ void peer_got_commitsig(struct peer *peer, const u8 *msg)
|
||||
&fulfilled,
|
||||
&failed,
|
||||
&changed,
|
||||
tx)) {
|
||||
&tx)) {
|
||||
peer_internal_error(peer,
|
||||
"bad fromwire_channel_got_commitsig %s",
|
||||
tal_hex(peer, msg));
|
||||
|
@ -943,7 +943,7 @@ static void wait_for_resolved(struct tracked_output **outs)
|
||||
while (!all_irrevocably_resolved(outs)) {
|
||||
u8 *msg = wire_sync_read(outs, REQ_FD);
|
||||
struct bitcoin_txid txid;
|
||||
struct bitcoin_tx *tx = tal(msg, struct bitcoin_tx);
|
||||
struct bitcoin_tx *tx;
|
||||
u32 input_num, depth, tx_blockheight;
|
||||
struct preimage preimage;
|
||||
|
||||
@ -952,7 +952,7 @@ static void wait_for_resolved(struct tracked_output **outs)
|
||||
|
||||
if (fromwire_onchain_depth(msg, NULL, &txid, &depth))
|
||||
tx_new_depth(outs, &txid, depth);
|
||||
else if (fromwire_onchain_spent(msg, NULL, tx, &input_num,
|
||||
else if (fromwire_onchain_spent(msg, msg, NULL, &tx, &input_num,
|
||||
&tx_blockheight))
|
||||
output_spent(&outs, tx, input_num, tx_blockheight);
|
||||
else if (fromwire_onchain_known_preimage(msg, NULL, &preimage))
|
||||
@ -1982,7 +1982,6 @@ int main(int argc, char *argv[])
|
||||
missing_htlc_msgs = tal_arr(ctx, u8 *, 0);
|
||||
|
||||
msg = wire_sync_read(ctx, REQ_FD);
|
||||
tx = tal(ctx, struct bitcoin_tx);
|
||||
if (!fromwire_onchain_init(ctx, msg, NULL,
|
||||
&seed, &shachain,
|
||||
&funding_amount_satoshi,
|
||||
@ -2001,7 +2000,7 @@ int main(int argc, char *argv[])
|
||||
&remote_payment_basepoint,
|
||||
&remote_htlc_basepoint,
|
||||
&remote_delayed_payment_basepoint,
|
||||
tx,
|
||||
&tx,
|
||||
&tx_blockheight,
|
||||
&reasonable_depth,
|
||||
&remote_htlc_sigs,
|
||||
|
@ -32,6 +32,7 @@ varlen_structs = [
|
||||
'gossip_getnodes_entry',
|
||||
'failed_htlc',
|
||||
'utxo',
|
||||
'bitcoin_tx',
|
||||
]
|
||||
|
||||
class FieldType(object):
|
||||
|
@ -289,9 +289,7 @@ static void json_withdraw(struct command *cmd,
|
||||
|
||||
msg = hsm_sync_read(cmd, cmd->ld);
|
||||
|
||||
tx = tal(withdraw, struct bitcoin_tx);
|
||||
|
||||
if (!fromwire_hsm_sign_withdrawal_reply(msg, NULL, tx))
|
||||
if (!fromwire_hsm_sign_withdrawal_reply(msg, msg, NULL, &tx))
|
||||
fatal("HSM gave bad sign_withdrawal_reply %s",
|
||||
tal_hex(withdraw, msg));
|
||||
|
||||
|
@ -225,7 +225,9 @@ void derive_channel_id(struct channel_id *channel_id,
|
||||
channel_id->id[sizeof(*channel_id)-1] ^= txout;
|
||||
}
|
||||
|
||||
void fromwire_bitcoin_tx(const u8 **cursor, size_t *max, struct bitcoin_tx *tx)
|
||||
/* FIXME: Simply rename pull_bitcoin_tx, remove pull_bitcoin_tx_onto */
|
||||
struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
|
||||
const u8 **cursor, size_t *max)
|
||||
{
|
||||
pull_bitcoin_tx_onto(tx, cursor, max, tx);
|
||||
return pull_bitcoin_tx(ctx, cursor, max);
|
||||
}
|
||||
|
@ -87,5 +87,6 @@ void fromwire_pad(const u8 **cursor, size_t *max, size_t num);
|
||||
|
||||
void fromwire_u8_array(const u8 **cursor, size_t *max, u8 *arr, size_t num);
|
||||
|
||||
void fromwire_bitcoin_tx(const u8 **cursor, size_t *max, struct bitcoin_tx *tx);
|
||||
struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
|
||||
const u8 **cursor, size_t *max);
|
||||
#endif /* LIGHTNING_WIRE_WIRE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user