diff --git a/src/psbt.c b/src/psbt.c index bb6b33492..4acde0efc 100644 --- a/src/psbt.c +++ b/src/psbt.c @@ -1154,7 +1154,7 @@ static int psbt_init(uint32_t version, size_t num_inputs, size_t num_outputs, if ((version != PSBT_0 && version != PSBT_2) || !psbt_out) return WALLY_EINVAL; /* Only v0/v2 are specified/supported */ if (num_inputs > TX_MAX_INPUTS || num_outputs > TX_MAX_OUTPUTS) - return WALLY_EINVAL; /* Resulting tx could not fit in a block */ + return WALLY_EINVAL; /* Resulting tx would be non-standard */ #ifdef BUILD_ELEMENTS if (flags & ~WALLY_PSBT_INIT_PSET || (flags & WALLY_PSBT_INIT_PSET && version != PSBT_2)) diff --git a/src/transaction.c b/src/transaction.c index 23e81cdfd..66cff32cf 100644 --- a/src/transaction.c +++ b/src/transaction.c @@ -1162,9 +1162,6 @@ static int tx_init_alloc(uint32_t version, uint32_t locktime, struct wally_tx_output *new_outputs = NULL; OUTPUT_CHECK; - if (inputs_allocation_len > TX_MAX_INPUTS || - outputs_allocation_len > TX_MAX_OUTPUTS) - return WALLY_EINVAL; /* Tx cannot fit in a block: invalid */ OUTPUT_ALLOC(struct wally_tx); if (inputs_allocation_len) { @@ -1202,6 +1199,9 @@ int wally_tx_init_alloc(uint32_t version, uint32_t locktime, size_t outputs_allocation_len, struct wally_tx **output) { + if (inputs_allocation_len > TX_MAX_INPUTS || + outputs_allocation_len > TX_MAX_OUTPUTS) + return WALLY_EINVAL; /* Non-standard tx: invalid */ return tx_init_alloc(version, locktime, inputs_allocation_len, outputs_allocation_len, TX_MAX_INPUTS_ALLOC, TX_MAX_OUTPUTS_ALLOC, output);