mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-20 16:08:51 +03:00
checkpoint: into main from release/1.7.0 @ 998ef392d9
(#14091)
Source hash: 998ef392d9
Remaining commits: 1
This commit is contained in:
commit
32fa4fd41b
@ -88,7 +88,7 @@ def print_coins(
|
||||
break
|
||||
coin, conf_height = coins[i + j]
|
||||
address = encode_puzzle_hash(coin.puzzle_hash, addr_prefix)
|
||||
amount_str = print_balance(coin.amount, mojo_per_unit, addr_prefix)
|
||||
amount_str = print_balance(coin.amount, mojo_per_unit, addr_prefix, decimal_only=True)
|
||||
print(f"Coin ID: 0x{coin.name().hex()}")
|
||||
print(target_string.format(address, amount_str, conf_height))
|
||||
|
||||
@ -179,7 +179,6 @@ async def async_split(args: Dict[str, Any], wallet_client: WalletRpcClient, fing
|
||||
fee = Decimal(args["fee"])
|
||||
# new args
|
||||
amount_per_coin = Decimal(args["amount_per_coin"])
|
||||
unique_addresses = bool(args["unique_addresses"])
|
||||
target_coin_id: bytes32 = bytes32.from_hexstr(args["target_coin_id"])
|
||||
if number_of_coins > 500:
|
||||
print(f"{number_of_coins} coins is greater then the maximum limit of 500 coins.")
|
||||
@ -208,7 +207,8 @@ async def async_split(args: Dict[str, Any], wallet_client: WalletRpcClient, fing
|
||||
return
|
||||
additions: List[Dict[str, Union[uint64, bytes32]]] = []
|
||||
for i in range(number_of_coins): # for readability.
|
||||
target_ph: bytes32 = decode_puzzle_hash(await wallet_client.get_next_address(str(wallet_id), unique_addresses))
|
||||
# we always use new addresses
|
||||
target_ph: bytes32 = decode_puzzle_hash(await wallet_client.get_next_address(str(wallet_id), new_address=True))
|
||||
additions.append({"amount": final_amount_per_coin, "puzzle_hash": target_ph})
|
||||
transaction: TransactionRecord = await wallet_client.send_transaction_multi(
|
||||
str(wallet_id), additions, [removal_coin_record.coin], final_fee
|
||||
|
@ -215,7 +215,6 @@ def combine_cmd(
|
||||
type=str,
|
||||
required=True,
|
||||
)
|
||||
@click.option("-u", "--unique_addresses", is_flag=True, help="Generate a new address for each coin.")
|
||||
@click.option("-t", "--target-coin-id", type=str, required=True, help="The coin id of the coin we are splitting.")
|
||||
def split_cmd(
|
||||
wallet_rpc_port: Optional[int],
|
||||
@ -224,7 +223,6 @@ def split_cmd(
|
||||
number_of_coins: int,
|
||||
fee: str,
|
||||
amount_per_coin: str,
|
||||
unique_addresses: bool,
|
||||
target_coin_id: str,
|
||||
) -> None:
|
||||
extra_params = {
|
||||
@ -232,7 +230,6 @@ def split_cmd(
|
||||
"number_of_coins": number_of_coins,
|
||||
"fee": fee,
|
||||
"amount_per_coin": amount_per_coin,
|
||||
"unique_addresses": unique_addresses,
|
||||
"target_coin_id": target_coin_id,
|
||||
}
|
||||
from .coin_funcs import async_split
|
||||
|
@ -707,8 +707,12 @@ def wallet_coin_unit(typ: WalletType, address_prefix: str) -> Tuple[str, int]:
|
||||
return "", units["mojo"]
|
||||
|
||||
|
||||
def print_balance(amount: int, scale: int, address_prefix: str) -> str:
|
||||
ret = f"{amount / scale} {address_prefix} "
|
||||
def print_balance(amount: int, scale: int, address_prefix: str, *, decimal_only: bool = False) -> str:
|
||||
if decimal_only: # dont use scientific notation.
|
||||
final_amount = f"{amount / scale:.12f}"
|
||||
else:
|
||||
final_amount = f"{amount / scale}"
|
||||
ret = f"{final_amount} {address_prefix} "
|
||||
if scale > 1:
|
||||
ret += f"({amount} mojo)"
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user