pylint
This commit is contained in:
parent
d8265add2d
commit
2f74611844
1 changed files with 12 additions and 18 deletions
|
@ -35,18 +35,16 @@ class CoinSelector:
|
||||||
return getattr(self, strategy_name or "standard")(txos, available)
|
return getattr(self, strategy_name or "standard")(txos, available)
|
||||||
|
|
||||||
@strategy
|
@strategy
|
||||||
def prefer_confirmed(
|
def prefer_confirmed(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator],
|
||||||
self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], available: int
|
available: int) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
||||||
) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
|
||||||
return (
|
return (
|
||||||
self.only_confirmed(txos, available) or
|
self.only_confirmed(txos, available) or
|
||||||
self.standard(txos, available)
|
self.standard(txos, available)
|
||||||
)
|
)
|
||||||
|
|
||||||
@strategy
|
@strategy
|
||||||
def only_confirmed(
|
def only_confirmed(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator],
|
||||||
self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], _
|
_) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
||||||
) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
|
||||||
confirmed = [t for t in txos if t.txo.tx_ref and t.txo.tx_ref.height > 0]
|
confirmed = [t for t in txos if t.txo.tx_ref and t.txo.tx_ref.height > 0]
|
||||||
if not confirmed:
|
if not confirmed:
|
||||||
return []
|
return []
|
||||||
|
@ -56,9 +54,8 @@ class CoinSelector:
|
||||||
return self.standard(confirmed, confirmed_available)
|
return self.standard(confirmed, confirmed_available)
|
||||||
|
|
||||||
@strategy
|
@strategy
|
||||||
def standard(
|
def standard(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator],
|
||||||
self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], available: int
|
available: int) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
||||||
) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
|
||||||
return (
|
return (
|
||||||
self.branch_and_bound(txos, available) or
|
self.branch_and_bound(txos, available) or
|
||||||
self.closest_match(txos, available) or
|
self.closest_match(txos, available) or
|
||||||
|
@ -66,9 +63,8 @@ class CoinSelector:
|
||||||
)
|
)
|
||||||
|
|
||||||
@strategy
|
@strategy
|
||||||
def branch_and_bound(
|
def branch_and_bound(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator],
|
||||||
self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], available: int
|
available: int) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
||||||
) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
|
||||||
# see bitcoin implementation for more info:
|
# see bitcoin implementation for more info:
|
||||||
# https://github.com/bitcoin/bitcoin/blob/master/src/wallet/coinselection.cpp
|
# https://github.com/bitcoin/bitcoin/blob/master/src/wallet/coinselection.cpp
|
||||||
|
|
||||||
|
@ -127,9 +123,8 @@ class CoinSelector:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@strategy
|
@strategy
|
||||||
def closest_match(
|
def closest_match(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator],
|
||||||
self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], _
|
_) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
||||||
) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
|
||||||
""" Pick one UTXOs that is larger than the target but with the smallest change. """
|
""" Pick one UTXOs that is larger than the target but with the smallest change. """
|
||||||
target = self.target + self.cost_of_change
|
target = self.target + self.cost_of_change
|
||||||
smallest_change = None
|
smallest_change = None
|
||||||
|
@ -142,9 +137,8 @@ class CoinSelector:
|
||||||
return [best_match] if best_match else []
|
return [best_match] if best_match else []
|
||||||
|
|
||||||
@strategy
|
@strategy
|
||||||
def random_draw(
|
def random_draw(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator],
|
||||||
self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], _
|
_) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
||||||
) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]:
|
|
||||||
""" Accumulate UTXOs at random until there is enough to cover the target. """
|
""" Accumulate UTXOs at random until there is enough to cover the target. """
|
||||||
target = self.target + self.cost_of_change
|
target = self.target + self.cost_of_change
|
||||||
self.random.shuffle(txos, self.random.random)
|
self.random.shuffle(txos, self.random.random)
|
||||||
|
|
Loading…
Reference in a new issue