mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-10 12:29:49 +03:00
Use secure coin ids (#3095)
This commit is contained in:
parent
ad205d9cd6
commit
e611bef223
@ -249,7 +249,7 @@ class MempoolManager:
|
||||
if npc_result.error is not None:
|
||||
return None, MempoolInclusionStatus.FAILED, Err(npc_result.error)
|
||||
# build removal list
|
||||
removal_names: List[bytes32] = new_spend.removal_names()
|
||||
removal_names: List[bytes32] = [npc.coin_name for npc in npc_list]
|
||||
|
||||
additions = additions_for_npc(npc_list)
|
||||
|
||||
|
@ -40,37 +40,19 @@ class SpendBundle(Streamable):
|
||||
return items
|
||||
|
||||
def removals(self) -> List[Coin]:
|
||||
""" This should be used only by wallet"""
|
||||
"""This should be used only by wallet"""
|
||||
return [_.coin for _ in self.coin_solutions]
|
||||
|
||||
def fees(self) -> int:
|
||||
""" Unsafe to use for fees validation!!! """
|
||||
"""Unsafe to use for fees validation!!!"""
|
||||
amount_in = sum(_.amount for _ in self.removals())
|
||||
amount_out = sum(_.amount for _ in self.additions())
|
||||
|
||||
return amount_in - amount_out
|
||||
|
||||
def removal_names(self) -> List[bytes32]:
|
||||
return [_.coin.name() for _ in self.coin_solutions]
|
||||
|
||||
def addition_names(self) -> List[bytes32]:
|
||||
return [_.name() for _ in self.additions()]
|
||||
|
||||
def name(self) -> bytes32:
|
||||
return self.get_hash()
|
||||
|
||||
def not_ephemeral_spends(self):
|
||||
all_removals = self.removals()
|
||||
all_additions = self.additions()
|
||||
result: List[Coin] = []
|
||||
|
||||
for rem in all_removals:
|
||||
if rem in all_additions:
|
||||
continue
|
||||
result.append(rem)
|
||||
|
||||
return result
|
||||
|
||||
def not_ephemeral_additions(self):
|
||||
all_removals = self.removals()
|
||||
all_additions = self.additions()
|
||||
|
@ -195,8 +195,8 @@ class Wallet:
|
||||
primaries: Optional[List[Dict[str, Any]]] = None,
|
||||
min_time=0,
|
||||
me=None,
|
||||
coin_announcements=None,
|
||||
coin_announcements_to_assert=None,
|
||||
coin_announcements: Optional[List[bytes32]] = None,
|
||||
coin_announcements_to_assert: Optional[List[bytes32]] = None,
|
||||
puzzle_announcements=None,
|
||||
puzzle_announcements_to_assert=None,
|
||||
fee=0,
|
||||
@ -315,6 +315,7 @@ class Wallet:
|
||||
self.log.info(f"coins is not None {coins}")
|
||||
spend_value = sum([coin.amount for coin in coins])
|
||||
change = spend_value - total_amount
|
||||
assert change >= 0
|
||||
|
||||
spends: List[CoinSolution] = []
|
||||
output_created = False
|
||||
|
Loading…
Reference in New Issue
Block a user