1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
crateix!;
//-------------------------------------------[.cpp/bitcoin/src/wallet/coinselection.cpp]
/**
| Compute the waste for this result given
| the cost of change and the opportunity
| cost of spending these inputs now vs
| in the future.
|
| If change exists, waste = change_cost
| + inputs * (effective_feerate - long_term_feerate)
|
| If no change, waste = excess + inputs
| * (effective_feerate - long_term_feerate)
|
| where excess = selected_effective_value
| - target
|
| change_cost = effective_feerate
| * change_output_size + long_term_feerate
| * change_spend_size
|
| -----------
| @param[in] inputs
|
| The selected inputs
| ----------
| @param[in] change_cost
|
| The cost of creating change and spending
| it in the future.
|
| Only used if there is change, in which
| case it must be positive.
|
| Must be 0 if there is no change.
| ----------
| @param[in] target
|
| The amount targeted by the coin selection
| algorithm.
| ----------
| @param[in] use_effective_value
|
| Whether to use the input's effective
| value (when true) or the real value (when
| false).
|
| -----------
| @return
|
| The waste
|
*/