mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +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
@@ -305,7 +305,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx,
|
||||
|
||||
/* Worst-case sig is 73 bytes */
|
||||
fee = feerate_per_kw * (measure_tx_weight(tx)
|
||||
+ 1 + 3 + 73 + 0 + tal_len(wscript))
|
||||
+ 1 + 3 + 73 + 0 + tal_count(wscript))
|
||||
/ 1000;
|
||||
|
||||
/* Result is trivial? Spend with small feerate, but don't wait
|
||||
@@ -313,7 +313,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx,
|
||||
if (tx->output[0].amount < dust_limit_satoshis + fee) {
|
||||
/* FIXME: We should use SIGHASH_NONE so others can take it */
|
||||
fee = feerate_floor() * (measure_tx_weight(tx)
|
||||
+ 1 + 3 + 73 + 0 + tal_len(wscript))
|
||||
+ 1 + 3 + 73 + 0 + tal_count(wscript))
|
||||
/ 1000;
|
||||
/* This shouldn't happen (we don't set feerate below floor!),
|
||||
* but just in case. */
|
||||
@@ -505,7 +505,7 @@ static void propose_resolution_at_block(struct tracked_output *out,
|
||||
static bool is_valid_sig(const u8 *e)
|
||||
{
|
||||
secp256k1_ecdsa_signature sig;
|
||||
size_t len = tal_len(e);
|
||||
size_t len = tal_count(e);
|
||||
|
||||
/* Last byte is sighash flags */
|
||||
if (len < 1)
|
||||
@@ -820,12 +820,12 @@ static void handle_htlc_onchain_fulfill(struct tracked_output *out,
|
||||
tx_type_name(out->tx_type),
|
||||
output_type_name(out->output_type));
|
||||
|
||||
if (tal_len(witness_preimage) != sizeof(preimage))
|
||||
if (tal_count(witness_preimage) != sizeof(preimage))
|
||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||
"%s/%s spent with bad witness length %zu",
|
||||
tx_type_name(out->tx_type),
|
||||
output_type_name(out->output_type),
|
||||
tal_len(witness_preimage));
|
||||
tal_count(witness_preimage));
|
||||
memcpy(&preimage, witness_preimage, sizeof(preimage));
|
||||
sha256(&sha, &preimage, sizeof(preimage));
|
||||
ripemd160(&ripemd, &sha, sizeof(sha));
|
||||
@@ -1391,9 +1391,9 @@ static int match_htlc_output(const struct bitcoin_tx *tx,
|
||||
if (!htlc_scripts[i])
|
||||
continue;
|
||||
|
||||
sha256(&sha, htlc_scripts[i], tal_len(htlc_scripts[i]));
|
||||
sha256(&sha, htlc_scripts[i], tal_count(htlc_scripts[i]));
|
||||
if (memeq(tx->output[outnum].script + 2,
|
||||
tal_len(tx->output[outnum].script) - 2,
|
||||
tal_count(tx->output[outnum].script) - 2,
|
||||
&sha, sizeof(sha)))
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
|
||||
*tx->input[0].amount = 700000;
|
||||
der = tal_hexdata(tmpctx, "30450221009b2e0eef267b94c3899fb0dc7375012e2cee4c10348a068fe78d1b82b4b14036022077c3fad3adac2ddf33f415e45f0daf6658b7a0b09647de4443938ae2dbafe2b9",
|
||||
strlen("30450221009b2e0eef267b94c3899fb0dc7375012e2cee4c10348a068fe78d1b82b4b14036022077c3fad3adac2ddf33f415e45f0daf6658b7a0b09647de4443938ae2dbafe2b9"));
|
||||
if (!signature_from_der(der, tal_len(der), &sig))
|
||||
if (!signature_from_der(der, tal_count(der), &sig))
|
||||
abort();
|
||||
|
||||
wscript = tal_hexdata(tmpctx, "76a914a8c40c334351dbe8e5908544f1c98fbcfb8719fc8763ac6721038ffd2621647812011960152bfb79c5a2787dfe6c4f37e2222547de054432eb7f7c820120876475527c2103cf8e2f193a6aed60db80af75f3c8d59c2de735b299b7c7083527be9bd23b77a852ae67a914b8bcd51efa35be1e50ae2d5f72f4500acb005c9c88ac6868", strlen("76a914a8c40c334351dbe8e5908544f1c98fbcfb8719fc8763ac6721038ffd2621647812011960152bfb79c5a2787dfe6c4f37e2222547de054432eb7f7c820120876475527c2103cf8e2f193a6aed60db80af75f3c8d59c2de735b299b7c7083527be9bd23b77a852ae67a914b8bcd51efa35be1e50ae2d5f72f4500acb005c9c88ac6868"));
|
||||
|
||||
Reference in New Issue
Block a user