Skip to content

Commit e460daa

Browse files
committed
fix: simplified did_short_sig(), fixed elements check and now btc uses 330 sat for p2tr change outputs
1 parent eed8329 commit e460daa

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

bitcoin/tx.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -987,11 +987,13 @@ struct amount_sat change_amount(struct amount_sat excess, u32 feerate_perkw,
987987
if (!amount_sat_sub(&excess, excess, fee))
988988
return AMOUNT_SAT(0);
989989

990-
// Change is P2TR (Bitcoin) or P2WPKH (Elements) both have
991-
// dust limit of 330 sat. Legacy types (P2PKH/P2SH) use 546 sat
992-
// but we dont create those as change outputs
993-
if (!amount_sat_greater_eq(excess, AMOUNT_SAT(330)))
994-
return AMOUNT_SAT(0);
990+
if (chainparams->is_elements) {
991+
if (!amount_sat_greater_eq(excess, AMOUNT_SAT(546)))
992+
return AMOUNT_SAT(0);
993+
} else {
994+
if (!amount_sat_greater_eq(excess, AMOUNT_SAT(330)))
995+
return AMOUNT_SAT(0);
996+
}
995997

996998
return excess;
997999
}

tests/utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,7 @@ def serialize_payload_final_tlv(amount_msat, delay, total_msat, blockheight, pay
675675
# I wish we could force libwally to use different entropy and thus force it to
676676
# create 71-byte sigs always!
677677
def did_short_sig(node):
678-
try:
679-
wait_for(lambda: node.daemon.is_in_log('overgrind: short signature length'), timeout=5)
680-
return True
681-
except (TimeoutError, ValueError):
682-
return False
678+
return node.daemon.is_in_log('overgrind: short signature length')
683679

684680

685681
def check_feerate(nodes, actual_feerate, expected_feerate):

0 commit comments

Comments
 (0)