mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-13 12:09:25 +03:00
89f15f591c
* wallet changes from pac * cat changes * pool tests * pooling tests passing * offers * lint * mempool_mode * black * linting * workflow files * flake8 * more cleanup * renamed * remove obsolete test, don't cast announcement * memos are not only bytes32 * trade renames * fix rpcs, block_record * wallet rpc, recompile settlement clvm * key derivation * clvm tests * lgtm issues and wallet peers * stash * rename * mypy linting * flake8 * bad initializer * flaky tests * Make CAT wallets only create on verified hints (#9651) * fix clvm tests * return to log lvl warn * check puzzle unhardened * public key, not bytes. api caching change * precommit changes * remove unused import * mypy ci file, tests * ensure balance before creating a tx * Remove CAT logic from full node test (#9741) * Add confirmations and sleeps for wallet (#9742) * use pool executor * rever merge mistakes/cleanup * Fix trade test flakiness (#9751) * remove precommit * older version of black * lint only in super linter * Make announcements in RPC be objects instead of bytes (#9752) * Make announcements in RPC be objects instead of bytes * Lint * misc hint'ish cleanup (#9753) * misc hint'ish cleanup * unremove some ci bits * Use main cached_bls.py * Fix bad merge in main_pac (#9774) * Fix bad merge at71da0487b9
* Remove unused ignores * more unused ignores * Fix bad merge at3b143e7050
* One more byte32.from_hexstr * Remove obsolete test * remove commented out * remove duplicate payment object * remove long sync * remove unused test, noise * memos type * bytes32 * make it clear it's a single state at a time * copy over asset ids from pacr * file endl linter * Update chia/server/ws_connection.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Matt Hauff <quexington@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from dataclasses import dataclass
|
|
|
|
from typing import List
|
|
|
|
from chia.types.blockchain_format.sized_bytes import bytes32
|
|
from chia.types.blockchain_format.program import Program
|
|
from chia.util.ints import uint64
|
|
|
|
|
|
# This class is supposed to correspond to a CREATE_COIN condition
|
|
@dataclass(frozen=True)
|
|
class Payment:
|
|
puzzle_hash: bytes32
|
|
amount: uint64
|
|
memos: List[bytes]
|
|
|
|
def as_condition_args(self) -> List:
|
|
return [self.puzzle_hash, self.amount, self.memos]
|
|
|
|
def as_condition(self) -> Program:
|
|
return Program.to([51, *self.as_condition_args()])
|
|
|
|
def name(self) -> bytes32:
|
|
return self.as_condition().get_tree_hash()
|
|
|
|
@classmethod
|
|
def from_condition(cls, condition: Program) -> "Payment":
|
|
python_condition: List = condition.as_python()
|
|
puzzle_hash, amount = python_condition[1:3]
|
|
memos: List[bytes] = []
|
|
if len(python_condition) > 3:
|
|
memos = python_condition[3]
|
|
return cls(bytes32(puzzle_hash), uint64(int.from_bytes(amount, "big")), memos)
|