mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
Remove tal_len, use tal_count() or tal_bytelen().
tal_count() is used where there's a type, even if it's char or u8, and tal_bytelen() is going to replace tal_len() for clarity: it's only needed where a pointer is void. We shim tal_bytelen() for now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
eae9b81099
commit
5cf34d6618
@@ -30,8 +30,8 @@ void push_varint_blob(const tal_t *blob,
|
||||
void (*push)(const void *, size_t, void *),
|
||||
void *pushp)
|
||||
{
|
||||
push_varint(tal_len(blob), push, pushp);
|
||||
push(blob, tal_len(blob), pushp);
|
||||
push_varint(tal_bytelen(blob), push, pushp);
|
||||
push(blob, tal_bytelen(blob), pushp);
|
||||
}
|
||||
|
||||
void push(const void *data, size_t len, void *pptr_)
|
||||
|
||||
@@ -369,7 +369,7 @@ u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key)
|
||||
|
||||
bool is_p2pkh(const u8 *script, struct bitcoin_address *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
size_t script_len = tal_count(script);
|
||||
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2PKH_LEN)
|
||||
return false;
|
||||
@@ -390,7 +390,7 @@ bool is_p2pkh(const u8 *script, struct bitcoin_address *addr)
|
||||
|
||||
bool is_p2sh(const u8 *script, struct ripemd160 *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
size_t script_len = tal_count(script);
|
||||
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2SH_LEN)
|
||||
return false;
|
||||
@@ -407,7 +407,7 @@ bool is_p2sh(const u8 *script, struct ripemd160 *addr)
|
||||
|
||||
bool is_p2wsh(const u8 *script, struct sha256 *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
size_t script_len = tal_count(script);
|
||||
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2WSH_LEN)
|
||||
return false;
|
||||
@@ -422,7 +422,7 @@ bool is_p2wsh(const u8 *script, struct sha256 *addr)
|
||||
|
||||
bool is_p2wpkh(const u8 *script, struct bitcoin_address *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
size_t script_len = tal_count(script);
|
||||
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN)
|
||||
return false;
|
||||
@@ -668,7 +668,7 @@ u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx,
|
||||
witness[1] = stack_sig(witness, remotehtlcsig);
|
||||
witness[2] = stack_sig(witness, localhtlcsig);
|
||||
witness[3] = stack_number(witness, 0);
|
||||
witness[4] = tal_dup_arr(witness, u8, wscript, tal_len(wscript), 0);
|
||||
witness[4] = tal_dup_arr(witness, u8, wscript, tal_count(wscript), 0);
|
||||
|
||||
return witness;
|
||||
}
|
||||
@@ -685,7 +685,7 @@ u8 **bitcoin_witness_htlc_success_tx(const tal_t *ctx,
|
||||
witness[1] = stack_sig(witness, remotesig);
|
||||
witness[2] = stack_sig(witness, localhtlcsig);
|
||||
witness[3] = stack_preimage(witness, preimage);
|
||||
witness[4] = tal_dup_arr(witness, u8, wscript, tal_len(wscript), 0);
|
||||
witness[4] = tal_dup_arr(witness, u8, wscript, tal_count(wscript), 0);
|
||||
|
||||
return witness;
|
||||
}
|
||||
@@ -724,12 +724,12 @@ u8 *bitcoin_wscript_htlc_tx(const tal_t *ctx,
|
||||
return script;
|
||||
}
|
||||
|
||||
bool scripteq(const tal_t *s1, const tal_t *s2)
|
||||
bool scripteq(const u8 *s1, const u8 *s2)
|
||||
{
|
||||
memcheck(s1, tal_len(s1));
|
||||
memcheck(s2, tal_len(s2));
|
||||
memcheck(s1, tal_count(s1));
|
||||
memcheck(s2, tal_count(s2));
|
||||
|
||||
if (tal_len(s1) != tal_len(s2))
|
||||
if (tal_count(s1) != tal_count(s2))
|
||||
return false;
|
||||
return memcmp(s1, s2, tal_len(s1)) == 0;
|
||||
return memcmp(s1, s2, tal_count(s1)) == 0;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ bool is_p2wsh(const u8 *script, struct sha256 *addr);
|
||||
bool is_p2wpkh(const u8 *script, struct bitcoin_address *addr);
|
||||
|
||||
/* Are these two scripts equal? */
|
||||
bool scripteq(const tal_t *s1, const tal_t *s2);
|
||||
bool scripteq(const u8 *s1, const u8 *s2);
|
||||
|
||||
/* OP_DUP + OP_HASH160 + PUSH(20-byte-hash) + OP_EQUALVERIFY + OP_CHECKSIG */
|
||||
#define BITCOIN_SCRIPTPUBKEY_P2PKH_LEN (1 + 1 + 1 + 20 + 1 + 1)
|
||||
|
||||
@@ -43,13 +43,13 @@ static void dump_tx(const char *msg,
|
||||
warnx("output[%zu].amount = %llu",
|
||||
i, (long long)tx->output[i].amount);
|
||||
warnx("output[%zu].script = %zu",
|
||||
i, tal_len(tx->output[i].script));
|
||||
for (j = 0; j < tal_len(tx->output[i].script); j++)
|
||||
i, tal_count(tx->output[i].script));
|
||||
for (j = 0; j < tal_count(tx->output[i].script); j++)
|
||||
fprintf(stderr, "%02x", tx->output[i].script[j]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
warnx("input[%zu].script = %zu", inputnum, tal_len(script));
|
||||
for (i = 0; i < tal_len(script); i++)
|
||||
warnx("input[%zu].script = %zu", inputnum, tal_count(script));
|
||||
for (i = 0; i < tal_count(script); i++)
|
||||
fprintf(stderr, "%02x", script[i]);
|
||||
if (key) {
|
||||
fprintf(stderr, "\nPubkey: ");
|
||||
|
||||
@@ -48,7 +48,7 @@ int main(void)
|
||||
|
||||
/* This is a p2sh-p2wpkh: */
|
||||
/* ScriptSig is push of "version 0 + hash of pubkey" */
|
||||
hexeq(tx->input[0].script, tal_len(tx->input[0].script),
|
||||
hexeq(tx->input[0].script, tal_count(tx->input[0].script),
|
||||
"16" "00" "144aa38e396e1394fb45cbf83f48d1464fbc9f498f");
|
||||
|
||||
/* Witness with 2 items */
|
||||
|
||||
@@ -341,7 +341,7 @@ static void pull_input(const tal_t *ctx, const u8 **cursor, size_t *max,
|
||||
input->script = tal_arr(ctx, u8, script_len);
|
||||
else
|
||||
input->script = NULL;
|
||||
pull(cursor, max, input->script, tal_len(input->script));
|
||||
pull(cursor, max, input->script, tal_count(input->script));
|
||||
input->sequence_number = pull_le32(cursor, max);
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ static void pull_output(const tal_t *ctx, const u8 **cursor, size_t *max,
|
||||
{
|
||||
output->amount = pull_value(cursor, max);
|
||||
output->script = tal_arr(ctx, u8, pull_length(cursor, max, 1));
|
||||
pull(cursor, max, output->script, tal_len(output->script));
|
||||
pull(cursor, max, output->script, tal_count(output->script));
|
||||
}
|
||||
|
||||
static u8 *pull_witness_item(const tal_t *ctx, const u8 **cursor, size_t *max)
|
||||
|
||||
Reference in New Issue
Block a user