Commit 507c8dc
committed
Solve the fact that in some cases the built transaction is discarded by Bitcoin nodes.
In `sec1_to_der`, I used to say that we need mock signing and assume the largest signature size that is reachable by providing `vec![1; 64]` in `mock_signer` in order to be in the if case for both conditions of `sec1_to_der`. However as far as I know Bitcoin uses sometimes variable length integer so `r` and `s` absolute values encoded by `vec![1; 64]` are less than `r` and `s` values encoded by `vec![255; 64]` and so the latter may take more signature size than the former. So in addition to assume that `r` and `s` are negative, we also have to assume that their value are the most negative one.
So the solution is to return `vec![255; 64]` in mock_signer and not `vec![1; 64]`. It solves the problem as for a signed transaction size of 223 bytes it now considers a fee of 224 satoshis.1 parent 5ad505c commit 507c8dc
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
549 | | - | |
| 549 | + | |
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
| |||
0 commit comments