I'm about to update our utxo type, but Christian spotted that this is part of the ABI for the hsm. So make that a private "hsm_utxo" type, to insulate it from changes. In particular, the HSM versions only contain the fields that the hsm cares about, and the wire format is consistent (even though that *did* include some of those fields, they are now dummies). In the long term, this should be removed from the ABI: once we no longer have "close_info" utxos, this information should already be in the PSBT. I tested this hadn't accidentally changed the wire format by disabling version checks and using an old hsmd with the altered daemons and running the test suite. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
34 lines
904 B
C
34 lines
904 B
C
#include "config.h"
|
|
#include <common/utxo.h>
|
|
#include <wire/wire.h>
|
|
|
|
size_t utxo_spend_weight(const struct utxo *utxo, size_t min_witness_weight)
|
|
{
|
|
size_t wit_weight = bitcoin_tx_simple_input_witness_weight();
|
|
/* If the min is less than what we'd use for a 'normal' tx,
|
|
* we return the value with the greater added/calculated */
|
|
if (wit_weight < min_witness_weight)
|
|
return bitcoin_tx_input_weight(utxo->is_p2sh,
|
|
min_witness_weight);
|
|
|
|
return bitcoin_tx_input_weight(utxo->is_p2sh, wit_weight);
|
|
}
|
|
|
|
u32 utxo_is_immature(const struct utxo *utxo, u32 blockheight)
|
|
{
|
|
if (utxo->is_in_coinbase) {
|
|
/* We got this from a block, it must have a known
|
|
* blockheight. */
|
|
assert(utxo->blockheight);
|
|
|
|
if (blockheight < *utxo->blockheight + 100)
|
|
return *utxo->blockheight + 99 - blockheight;
|
|
|
|
else
|
|
return 0;
|
|
} else {
|
|
/* Non-coinbase outputs are always mature. */
|
|
return 0;
|
|
}
|
|
}
|