|
|
@ -831,13 +831,13 @@ size_t bitcoin_tx_input_sig_weight(void) |
|
|
|
return 1 + 71; |
|
|
|
} |
|
|
|
|
|
|
|
/* We only do segwit inputs, and we assume witness is sig + key */ |
|
|
|
size_t bitcoin_tx_simple_input_weight(bool p2sh) |
|
|
|
/* Input weight */ |
|
|
|
size_t bitcoin_tx_input_weight(bool p2sh, size_t witness_weight) |
|
|
|
{ |
|
|
|
size_t weight; |
|
|
|
size_t weight = witness_weight; |
|
|
|
|
|
|
|
/* Input weight: txid + index + sequence */ |
|
|
|
weight = (32 + 4 + 4) * 4; |
|
|
|
weight += (32 + 4 + 4) * 4; |
|
|
|
|
|
|
|
/* We always encode the length of the script, even if empty */ |
|
|
|
weight += 1 * 4; |
|
|
@ -846,9 +846,6 @@ size_t bitcoin_tx_simple_input_weight(bool p2sh) |
|
|
|
if (p2sh) |
|
|
|
weight += 23 * 4; |
|
|
|
|
|
|
|
/* Account for witness (1 byte count + sig + key) */ |
|
|
|
weight += 1 + (bitcoin_tx_input_sig_weight() + 1 + 33); |
|
|
|
|
|
|
|
/* Elements inputs have 6 bytes of blank proofs attached. */ |
|
|
|
if (chainparams->is_elements) |
|
|
|
weight += 6; |
|
|
@ -856,6 +853,19 @@ size_t bitcoin_tx_simple_input_weight(bool p2sh) |
|
|
|
return weight; |
|
|
|
} |
|
|
|
|
|
|
|
size_t bitcoin_tx_simple_input_witness_weight(void) |
|
|
|
{ |
|
|
|
/* Account for witness (1 byte count + sig + key) */ |
|
|
|
return 1 + (bitcoin_tx_input_sig_weight() + 1 + 33); |
|
|
|
} |
|
|
|
|
|
|
|
/* We only do segwit inputs, and we assume witness is sig + key */ |
|
|
|
size_t bitcoin_tx_simple_input_weight(bool p2sh) |
|
|
|
{ |
|
|
|
return bitcoin_tx_input_weight(p2sh, |
|
|
|
bitcoin_tx_simple_input_witness_weight()); |
|
|
|
} |
|
|
|
|
|
|
|
struct amount_sat change_amount(struct amount_sat excess, u32 feerate_perkw) |
|
|
|
{ |
|
|
|
size_t outweight; |
|
|
|