Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions counterparty-core/counterpartycore/lib/api/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from counterpartycore.lib.utils import helpers, multisig, script

MAX_INPUTS_SET = 100
MAX_CONFIRMATION_TARGET = 1008

logger = logging.getLogger(config.LOGGER_NAME)

Expand Down Expand Up @@ -928,6 +929,10 @@ def prepare_fee_parameters(construct_params):
sat_per_vbyte, confirmation_target, max_fee = None, None, None
elif sat_per_vbyte is None:
if confirmation_target is not None:
if confirmation_target < 1 or confirmation_target > MAX_CONFIRMATION_TARGET:
raise exceptions.ComposeError(
f"Invalid confirmation_target: must be between 1 and {MAX_CONFIRMATION_TARGET}"
)
sat_per_vbyte = backend.bitcoind.satoshis_per_vbyte(confirmation_target)
else:
sat_per_vbyte = backend.bitcoind.satoshis_per_vbyte()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,15 @@ def test_prepare_fee_parameters():
1000,
)

with pytest.raises(exceptions.ComposeError, match="Invalid confirmation_target"):
composer.prepare_fee_parameters({"confirmation_target": 0})

with pytest.raises(exceptions.ComposeError, match="Invalid confirmation_target"):
composer.prepare_fee_parameters({"confirmation_target": -1})

with pytest.raises(exceptions.ComposeError, match="Invalid confirmation_target"):
composer.prepare_fee_parameters({"confirmation_target": 1009})


def test_prepare_unspent_list(ledger_db, defaults, monkeypatch):
txs = {
Expand Down