chia-blockchain/chia/wallet/wallet.py

535 lines
22 KiB
Python
Raw Normal View History

2020-11-11 20:22:29 +03:00
import logging
2020-04-28 04:42:08 +03:00
import time
from typing import Any, Dict, List, Optional, Set
2020-11-11 20:22:29 +03:00
from blspy import G1Element
2020-11-11 20:22:29 +03:00
from chia.consensus.cost_calculator import NPCResult
2021-04-17 09:13:22 +03:00
from chia.full_node.bundle_tools import simple_solution_generator
from chia.full_node.mempool_check_conditions import get_name_puzzle_conditions
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
from chia.types.announcement import Announcement
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import Program, SerializedProgram
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.coin_spend import CoinSpend
2021-04-17 09:13:22 +03:00
from chia.types.generator_types import BlockGenerator
from chia.types.spend_bundle import SpendBundle
from chia.util.hash import std_hash
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
from chia.util.ints import uint8, uint32, uint64, uint128
from chia.wallet.coin_selection import select_coins
from chia.wallet.derivation_record import DerivationRecord
from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import (
2020-11-11 20:22:29 +03:00
DEFAULT_HIDDEN_PUZZLE_HASH,
calculate_synthetic_secret_key,
puzzle_for_pk,
solution_for_conditions,
2020-09-17 02:41:06 +03:00
)
from chia.wallet.puzzles.puzzle_utils import (
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
make_assert_absolute_seconds_exceeds_condition,
make_assert_coin_announcement,
2020-02-13 22:57:40 +03:00
make_assert_my_coin_id_condition,
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
make_assert_puzzle_announcement,
make_create_coin_announcement,
2020-02-13 22:57:40 +03:00
make_create_coin_condition,
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
make_create_puzzle_announcement,
make_reserve_fee_condition,
2020-04-20 08:10:19 +03:00
)
from chia.wallet.secret_key_store import SecretKeyStore
from chia.wallet.sign_coin_spends import sign_coin_spends
from chia.wallet.transaction_record import TransactionRecord
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
from chia.wallet.util.compute_memos import compute_memos
from chia.wallet.util.transaction_type import TransactionType
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
from chia.wallet.util.wallet_types import AmountWithPuzzlehash, WalletType
from chia.wallet.wallet_coin_record import WalletCoinRecord
from chia.wallet.wallet_info import WalletInfo
2020-02-24 20:16:47 +03:00
2020-02-12 00:00:41 +03:00
2020-09-24 03:06:42 +03:00
class Wallet:
wallet_state_manager: Any
2020-02-13 22:57:40 +03:00
log: logging.Logger
wallet_id: uint32
secret_key_store: SecretKeyStore
cost_of_single_tx: Optional[int]
2020-02-13 23:59:03 +03:00
2020-02-13 22:57:40 +03:00
@staticmethod
2020-02-24 21:41:54 +03:00
async def create(
2020-09-15 19:56:04 +03:00
wallet_state_manager: Any,
info: WalletInfo,
name: str = None,
2020-02-24 21:41:54 +03:00
):
2020-02-13 22:57:40 +03:00
self = Wallet()
self.log = logging.getLogger(name if name else __name__)
2020-02-24 20:16:47 +03:00
self.wallet_state_manager = wallet_state_manager
self.wallet_id = info.id
self.secret_key_store = SecretKeyStore()
self.cost_of_single_tx = None
2020-02-13 22:57:40 +03:00
return self
2020-02-12 04:01:39 +03:00
async def get_max_send_amount(self, records: Optional[Set[WalletCoinRecord]] = None) -> int:
spendable: List[WalletCoinRecord] = list(
await self.wallet_state_manager.get_spendable_coins_for_wallet(self.id(), records)
)
if len(spendable) == 0:
return 0
spendable.sort(reverse=True, key=lambda record: record.coin.amount)
if self.cost_of_single_tx is None:
coin = spendable[0].coin
tx = await self.generate_signed_transaction(
coin.amount, coin.puzzle_hash, coins={coin}, ignore_max_send_amount=True
)
assert tx.spend_bundle is not None
2021-04-17 09:13:22 +03:00
program: BlockGenerator = simple_solution_generator(tx.spend_bundle)
# npc contains names of the coins removed, puzzle_hashes and their spend conditions
result: NPCResult = get_name_puzzle_conditions(
program,
self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=self.wallet_state_manager.constants.COST_PER_BYTE,
mempool_mode=True,
)
self.cost_of_single_tx = result.cost
self.log.info(f"Cost of a single tx for standard wallet: {self.cost_of_single_tx}")
max_cost = self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM / 5 # avoid full block TXs
current_cost = 0
total_amount = 0
total_coin_count = 0
for record in spendable:
current_cost += self.cost_of_single_tx
total_amount += record.coin.amount
total_coin_count += 1
if current_cost + self.cost_of_single_tx > max_cost:
break
return total_amount
2020-09-24 03:47:06 +03:00
@classmethod
def type(cls) -> uint8:
return uint8(WalletType.STANDARD_WALLET)
def id(self) -> uint32:
return self.wallet_id
2020-09-24 03:47:06 +03:00
2021-02-11 06:53:38 +03:00
async def get_confirmed_balance(self, unspent_records=None) -> uint128:
2021-01-16 07:04:34 +03:00
return await self.wallet_state_manager.get_confirmed_balance_for_wallet(self.id(), unspent_records)
2020-02-13 22:57:40 +03:00
2021-02-11 06:53:38 +03:00
async def get_unconfirmed_balance(self, unspent_records=None) -> uint128:
2021-01-16 07:04:34 +03:00
return await self.wallet_state_manager.get_unconfirmed_balance(self.id(), unspent_records)
2020-02-13 23:59:03 +03:00
2021-02-11 06:53:38 +03:00
async def get_spendable_balance(self, unspent_records=None) -> uint128:
2021-01-16 07:04:34 +03:00
spendable = await self.wallet_state_manager.get_confirmed_spendable_balance_for_wallet(
self.id(), unspent_records
)
return spendable
Electron react (#226) * clean react * add material ui * add word list * mnemonic v0 * jeepney backup * keychain usage * wallet api * mnemonic ui * mnemonics redux state * handle exceptions correctly * dashboard * wallets * get puzzle hash * tx history * sidebar * start stop wallet node * use existing mnemonics * status info * create cc wallet * theme should be outside of switch * create offer * dbus alternative for linux * key migration * don't autocomplete, don't reset simulator db * reset mnemonics * Refactor keychain, and key migration * Implement UI for changing keys * Removing keys and mnemonic button * Start making farmer and harvester RPCs * start rpx for simulator * Harvester and farmer websocket, and basic UI * Plot display and deletion * launch daemon on start * State changes from full node, harvester, farmer, and full node ui improvements * split balances in react * pending change balance * plotter * dev config * maintain connection / retry * Remove electron-ui, and style fixes * Better farmer and full node control * Remove electron ui references * Uncomment out starting the dameon * Remove timelord tab, and change full node style * Clean up new wallet login * Refactor RPCs * Now that the GH runner uses python 3.7.7 - use for windows installer * add balance split to coloured coin wallet * spendable balance fix * Import private key from UI fix * mac build/installer Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Lipa Long <lipa@chia.net> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com>
2020-05-20 10:41:10 +03:00
async def get_pending_change_balance(self) -> uint64:
unconfirmed_tx: List[TransactionRecord] = await self.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(
self.id()
)
Electron react (#226) * clean react * add material ui * add word list * mnemonic v0 * jeepney backup * keychain usage * wallet api * mnemonic ui * mnemonics redux state * handle exceptions correctly * dashboard * wallets * get puzzle hash * tx history * sidebar * start stop wallet node * use existing mnemonics * status info * create cc wallet * theme should be outside of switch * create offer * dbus alternative for linux * key migration * don't autocomplete, don't reset simulator db * reset mnemonics * Refactor keychain, and key migration * Implement UI for changing keys * Removing keys and mnemonic button * Start making farmer and harvester RPCs * start rpx for simulator * Harvester and farmer websocket, and basic UI * Plot display and deletion * launch daemon on start * State changes from full node, harvester, farmer, and full node ui improvements * split balances in react * pending change balance * plotter * dev config * maintain connection / retry * Remove electron-ui, and style fixes * Better farmer and full node control * Remove electron ui references * Uncomment out starting the dameon * Remove timelord tab, and change full node style * Clean up new wallet login * Refactor RPCs * Now that the GH runner uses python 3.7.7 - use for windows installer * add balance split to coloured coin wallet * spendable balance fix * Import private key from UI fix * mac build/installer Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Lipa Long <lipa@chia.net> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com>
2020-05-20 10:41:10 +03:00
addition_amount = 0
for record in unconfirmed_tx:
if not record.is_in_mempool():
if record.spend_bundle is not None:
self.log.warning(f"Record: {record} not in mempool, {record.sent_to}")
continue
Electron react (#226) * clean react * add material ui * add word list * mnemonic v0 * jeepney backup * keychain usage * wallet api * mnemonic ui * mnemonics redux state * handle exceptions correctly * dashboard * wallets * get puzzle hash * tx history * sidebar * start stop wallet node * use existing mnemonics * status info * create cc wallet * theme should be outside of switch * create offer * dbus alternative for linux * key migration * don't autocomplete, don't reset simulator db * reset mnemonics * Refactor keychain, and key migration * Implement UI for changing keys * Removing keys and mnemonic button * Start making farmer and harvester RPCs * start rpx for simulator * Harvester and farmer websocket, and basic UI * Plot display and deletion * launch daemon on start * State changes from full node, harvester, farmer, and full node ui improvements * split balances in react * pending change balance * plotter * dev config * maintain connection / retry * Remove electron-ui, and style fixes * Better farmer and full node control * Remove electron ui references * Uncomment out starting the dameon * Remove timelord tab, and change full node style * Clean up new wallet login * Refactor RPCs * Now that the GH runner uses python 3.7.7 - use for windows installer * add balance split to coloured coin wallet * spendable balance fix * Import private key from UI fix * mac build/installer Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Lipa Long <lipa@chia.net> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com>
2020-05-20 10:41:10 +03:00
our_spend = False
for coin in record.removals:
2020-12-11 10:27:03 +03:00
if await self.wallet_state_manager.does_coin_belong_to_wallet(coin, self.id()):
Electron react (#226) * clean react * add material ui * add word list * mnemonic v0 * jeepney backup * keychain usage * wallet api * mnemonic ui * mnemonics redux state * handle exceptions correctly * dashboard * wallets * get puzzle hash * tx history * sidebar * start stop wallet node * use existing mnemonics * status info * create cc wallet * theme should be outside of switch * create offer * dbus alternative for linux * key migration * don't autocomplete, don't reset simulator db * reset mnemonics * Refactor keychain, and key migration * Implement UI for changing keys * Removing keys and mnemonic button * Start making farmer and harvester RPCs * start rpx for simulator * Harvester and farmer websocket, and basic UI * Plot display and deletion * launch daemon on start * State changes from full node, harvester, farmer, and full node ui improvements * split balances in react * pending change balance * plotter * dev config * maintain connection / retry * Remove electron-ui, and style fixes * Better farmer and full node control * Remove electron ui references * Uncomment out starting the dameon * Remove timelord tab, and change full node style * Clean up new wallet login * Refactor RPCs * Now that the GH runner uses python 3.7.7 - use for windows installer * add balance split to coloured coin wallet * spendable balance fix * Import private key from UI fix * mac build/installer Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Lipa Long <lipa@chia.net> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com>
2020-05-20 10:41:10 +03:00
our_spend = True
break
if our_spend is not True:
continue
for coin in record.additions:
2020-12-11 10:27:03 +03:00
if await self.wallet_state_manager.does_coin_belong_to_wallet(coin, self.id()):
Electron react (#226) * clean react * add material ui * add word list * mnemonic v0 * jeepney backup * keychain usage * wallet api * mnemonic ui * mnemonics redux state * handle exceptions correctly * dashboard * wallets * get puzzle hash * tx history * sidebar * start stop wallet node * use existing mnemonics * status info * create cc wallet * theme should be outside of switch * create offer * dbus alternative for linux * key migration * don't autocomplete, don't reset simulator db * reset mnemonics * Refactor keychain, and key migration * Implement UI for changing keys * Removing keys and mnemonic button * Start making farmer and harvester RPCs * start rpx for simulator * Harvester and farmer websocket, and basic UI * Plot display and deletion * launch daemon on start * State changes from full node, harvester, farmer, and full node ui improvements * split balances in react * pending change balance * plotter * dev config * maintain connection / retry * Remove electron-ui, and style fixes * Better farmer and full node control * Remove electron ui references * Uncomment out starting the dameon * Remove timelord tab, and change full node style * Clean up new wallet login * Refactor RPCs * Now that the GH runner uses python 3.7.7 - use for windows installer * add balance split to coloured coin wallet * spendable balance fix * Import private key from UI fix * mac build/installer Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Lipa Long <lipa@chia.net> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com>
2020-05-20 10:41:10 +03:00
addition_amount += coin.amount
return uint64(addition_amount)
def puzzle_for_pk(self, pubkey: bytes) -> Program:
2020-02-12 04:01:39 +03:00
return puzzle_for_pk(pubkey)
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
async def convert_puzzle_hash(self, puzzle_hash: bytes32) -> bytes32:
return puzzle_hash # Looks unimpressive, but it's more complicated in other wallets
2020-12-11 10:27:03 +03:00
async def hack_populate_secret_key_for_puzzle_hash(self, puzzle_hash: bytes32) -> G1Element:
maybe = await self.wallet_state_manager.get_keys(puzzle_hash)
if maybe is None:
error_msg = f"Wallet couldn't find keys for puzzle_hash {puzzle_hash}"
self.log.error(error_msg)
raise ValueError(error_msg)
# Get puzzle for pubkey
public_key, secret_key = maybe
# HACK
2020-12-11 10:27:03 +03:00
synthetic_secret_key = calculate_synthetic_secret_key(secret_key, DEFAULT_HIDDEN_PUZZLE_HASH)
2020-11-11 20:22:29 +03:00
self.secret_key_store.save_secret_key(synthetic_secret_key)
2020-09-17 01:53:22 +03:00
return public_key
async def hack_populate_secret_keys_for_coin_spends(self, coin_spends: List[CoinSpend]) -> None:
"""
This hack forces secret keys into the `_pk2sk` lookup. This should eventually be replaced
by a persistent DB table that can do this look-up directly.
"""
for coin_spend in coin_spends:
await self.hack_populate_secret_key_for_puzzle_hash(coin_spend.coin.puzzle_hash)
2020-09-17 01:53:22 +03:00
async def puzzle_for_puzzle_hash(self, puzzle_hash: bytes32) -> Program:
public_key = await self.hack_populate_secret_key_for_puzzle_hash(puzzle_hash)
return puzzle_for_pk(bytes(public_key))
2020-04-10 17:53:31 +03:00
async def get_new_puzzle(self) -> Program:
dr = await self.wallet_state_manager.get_unused_derivation_record(self.id())
2020-08-13 03:08:05 +03:00
return puzzle_for_pk(bytes(dr.pubkey))
2020-04-10 17:53:31 +03:00
Pools mainnet (#7047) * added clarifying comments * WIP test * added WIP test * Refine genesis challenge. Remove unnecessary pool_puzzle function * Sign spend. Remove create_member_spend. Rename state transition function to create_travel_spend * Rename create_member_spend to create_travel_spend * Add singleton id logging * Enhance logging for debugging * renaming * rephrase inside the puzzle * fixed signing and added some support functions * Fix issue with announcement * Progress spending the singleton * Fix arguments to pool_state_to_inner_puzzle call * Fix arguments to pool_state_to_inner_puzzle * Improve error message when wallet is not running * Remove misleading message about missing wallet process, when problem is the farmer by making poolnft command error out earlier * Fix parent coin info bug * Multiple state transitions in one block * Lint * Remove assert * Fix incorrect p2_singleton_ph calculation (thanks nil00) * Update waiting room puzzle to accept genesis_challenge * Update calls to create_waiting * Go to waiting state from committed state * Augment debug_spend_bundle * fix 2 bugs in wallet * Fix lint * fix bad_agg_sig bug * Tests and lint * remove breakpoint * fix clvm tests for new hexs and hashs * Fixed a bug in the coin store that was probably from merging. (#6577) * Fixed a bug in the coin store that was probably from merging. * The exception doesn't need to be there * CI Lint fix * Added lifecycle tests for pooling drivers (#6610) * Ms.poolabsorb (#6615) * Support for absorbing rewards in pools (untested) * Style improvements * More work on absorb * Revert default root and remove log * Revert small plots * Use real sub slot iters * Update types * debug1 * Fix bugs * fix output of agg sig log messages * Make fewer calls to pw_status in test * remove old comment * logging and state management * logging * small bug fix & rename for accuracy * format * Fix types for uncurry function * lint * Update test to use exceptions * Change assumptions about self-pooling in lifecycle test * Install types for mypy * Revert "Install types for mypy" This reverts commit a82dcb712a6a97b8789b17c98cac8eafaffe90f5. * install types for mypy * install types for mypy * More keys * Remove flags requiring interactive prompts * Change initial spend to waiting room if self-pooling * lint * lint * linting * Refactor test * Use correct value in log message * update p2_singleton_or_delated_puzhash * initial version of pool wallet with p2_singleton_or_delay * run black formatting * fix rebase wonkiness * fix announcement code in p2_singleton_or_delayed * removed redundant defaulting standardised hexstr handling * lint fixes * Fixed pool lifecycle tests to current standards, but discovered tests are not validating signatures * Signatures validate on this test now although the test still does not check it. * Lint fix * Fixed plotnft show and linting errors * fixed failing farmer/harvester rpc test * lint fix * Commenting out some outdated tests * Updated test coverage * lint fix * Some minor P2singleton improvements (#6325) * Improve some debugging tools. * Tidy pool clvm. * Use `SINGLETON_STRUCT`. Remove unused `and` macro. * Use better name `SINGLETON_MOD_HASH`. * Finish lifecycle test suite. * Fixing for merge with chia-blockchain/pools_delayed_puzzle (#72) Co-authored-by: Matt Hauff <quexington@gmail.com> * Default delay time was being set incorrectly * Extracted get_delayed_puz_info_from_launcher_spend to driver code * Ms.taproot plot2 (#6692) * Start work on adding taproot to new plots * Fix issue in block_tools * new test-cache * Lint * DID fixexs * Fix other tests * Python black * Fix full node store test * Ensure block index <= 128 bits. * fix test_pool_config test * fix comments in pool_config and in chialisp files * self_pool -> pool -> self_pool * Implement leaving pools * Fix conflicts with main via mini-rebase * Fixup rebase mistakes * Bring in Mariano's node discovery chagnes from pools.dev * Fix adapters - Thanks Richard * build tests * Add pools tests * Disable DID tests * farmer|protocol: Some renaming related to the pool protocol * farmer: Use `None` instead of `{}` and add local `pool_state` * protocol|farmer: Introduce and use `PoolErrorCode` * rename: `pool_payout_instructions` -> `payout_instructions` * refactor: `AuthenticationKeyInfo` -> `authentication_key` * refactor: Move `launcher_id` up * rename: Some variable name changes * rename: `points_balance` -> `points` * format: Squash aggregation into one line * farmer: Make `update_pool_state` public * farmer: Print traceback if `update_pool_state` fails * farmer: Periodically call `GET /pool_info`, add `_pool_get_pool_info` * farmer: Add `authentication_token_timeout` to `pool_state` Fetch it from `GET /pool_info` * protocol|farmer: Implement support for `GET|POST|PUT /farmer` * farmer: Make use of `GET|POST /farmer` - To make the farmer known by the pool - To update local balance/difficulty from the pool periodically * farmer|protocol: Adjust `POST /partial` to match the latest spec * farmer: Hash messages before signing * pools: Drop unused code * farmer: Fix aggregation of partial signatures * farmer: support self pooling, don't pool if url=="" * wallet: return uint64 for delay time, instead of bytes * pool: add error code for delay time too short * farmer: cleaner logging when no connection to pool * farmer: add harvester node id to pool protocol * Rename method (test fix) and lint fix * Change errors to warnings (pool communication) * Remove pool callbacks on a reorg * farmer: Continue earlier when no pool URL is provided * farmer: Print method in log * farmer: Handle exceptions for all pool endpoint calls * farmer|protocol: Keep track of failed requests to the pool * farmer: Fix typo which caused issue with pooling * wallet: simplify solution_to_extra_data * tests: Comment out DID tests which are not working yet * Remove DID Wallet test workflows * Return launcher_id when creating Pool Wallet * Name p2_singleton_puzzle_hash correctly * Improve 'test_singleton_lifecycle_fast.py'. * Make test more robust in the face of asynchronous adversity * Add commandline cmds for joining and leaving pools * Fix poolnft leave params * Remove redundant assignment brought in from main * Remove unneeded code * Style and parsimony * pool_puzzles: Check was wrong, and bad naming * format: Fix linting * format: Remove log and rename variable * pool-wallet: Fix self pooling with multiple pool wallets. Don't remove interested puzzle_hash * gui: Use pools branch * format: fix lint * Remove ununsed code, improve initial_pool_state_from_dict * farmer: Instantly update the config, when config file changes * format: Speed up loading of the authentication key * logging: less annoying logging * Test pool NFT creation directly to pool * Test switching pools without self-farming in between * lint * pooling: Use integer for protocol version (#6797) * pooling: Use integer for protocol version * pooling: Fix import * Update GUI commit * Ms.login2 (#6804) * pooling: Login WIP * pooling: add RPC for get_link * dont use timeout * pooling: rename to get_login_link * format: remove logging * Fix SES test * Required cli argument Co-authored-by: almog <almogdepaz@gmail.com> * farmer|protocols: Rename `current_difficulty` for `POST /partial` (#6807) * Fix to farm summary * Use target_puzzlehash param name in RPC call * Pool test coverage (#6782) * Improvement in test coverage and typing * Added an extra absorb to the pool lifecycle test (only works when merged with https://github.com/Chia-Network/chia-blockchain/pull/6733) * Added new drivers for the p2_singleton puzzles * Added new tests and test coverage for singletons * organize pools testing directory * black formatting * black formatting in venv * lint fix * Update CI tests * Fixing tests post rebase * lint fix * Minor readability fix Co-authored-by: matt <matt@chia.net> * farmer: Drop `target_puzzle_hash` from `GET /farmer` and `GET /login` (#6816) * Allow creation of PlotNFTs in self-farming state * gui: Fix install with more RAM (#6821) * Allow implicit payout_address in self-pool state, improve error messages and param ergonomics * print units in non-standard wallets correctly * Fix farmer import * Make syncing message in CLI more intuitive like the GUI * Fix linting and show header hash instead of height * gui: Update to 725071236eff8c81d5b267dc8eb69d7e03f3df8c * Revert "Merge" This reverts commit 23a1e688c5fb4f72983fd896d4933336a365fe38, reversing changes made to a850246c6f4de4d2eb65c4ac1d6023431f3ba7e9. * Revert "Revert "Merge"" This reverts commit 680331859f5dc404cca9c2ff8f4a61df374db125. * Treat tx_record as Dict. Refactor tx submission * Also add passed-in coin spends when processing new blocks in reconsider_peak * Test utilities had moved * Fix import of moved block_tools * Potentially fix yaml * Previously didn't take the right part of this change * Add -y flag, improve commandline plotnft handling * Fix typo * Add -y flag to plotnft create * pool_wallet: Restore from DB properly * wallet: ignore bad pool configs * Reduce memory * pool_wallet: Add claim command * pool_wallet: Set transaction records to confirmed * wallet: Fix bug in transaction cache * Formatting and remove log * pool_wallet: CLI balance and improvements to plotnft_funcs.py * pool_wallet: Simplify, and fix issue with double submission * pool_wallet: Fix tests * pool_wallet: Don't allow switching before relative lock height * update gui * change to 3000 mem * Correct sense of -y flag for self-pooling * cli: Display payout instructions for pool * pool_wallet: Don't create massive transactions * cli: Improvements to plotnft * pool_wallet: Get correct pool state * pool_wallet: Use last transaction block to prevent condition failure * Add block height for current state * Add outstanding unconfirmed transactions to pw_status * Refine command line plotnft show pending transactions * Fix tests by using the correct output from pw_status * Try to fix windows build * Print expected leave height * label pool urls * pool_wallet: Don't include pool 1.75 rewards in total * wallet: Add RPC and CLI for deleting unconfirmed transactions for a wallet * pool_wallet: If farming to a pool, show 0 balance in wallet * pool_wallet: Show error message if invalid state, in CLI * pool_wallet: Don't allow switching if there are pending unconfirmed transactions * tests: Clean up pool test logging * tests: Fix lint * Changed the pool innerpuzzes (#6802) * overload solutions for pool_innerpuz parameters * Fix tests for reduced size puzzles * deleted messy deprecated test * Fix lint. * fix bug where spend types were the wrong way around * merge with richard's lint fix * fix wallet bug remove unnecessary signature add defun-inline for clarity * Swap to defun for absorb case Use cons box for member innerpuz solution * fix if statement for cons box p1 * remove unnecessary solution arg * quick innerpuz fix to make tests pass * Switch to key-value pairs Undo cons box solution in pool_member inner puzzle * fix singleton lifecycle test * added some comments to calrify the meaning on "ps" * lint fix * reduce label size, search for label when reconstructing from solution * no need to keep looping if `p` found * lint fix * Removed unecessary defun-inline and changed hyphens to underscores * Changed created_coin_value_or_0 to an inline function * Changed morph_condition to an inline function * Added a comment for odd_cons_m113 * Rename output_odd and odd_output_found * Add inline functions to document the lineage proof values * Stager two rewrite * Added an ASSER_MY_AMOUNT to p2_singleton_or_delayed * Extract truth functionality to singleton_truths.clib * Fix tree hashes * Changed truths to a struct rather than a list. * fix test_singletons update did_innerpuz * recompile did_innerpuz * fix a log error * Renamed variable and factored out code per @richardkiss * lint fix * switch launcher extra_data to key_value pairs * fix parsing of new format of extra_data in launcher solution * fix broken test for new launcher solution format * remove bare raise Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: Matt Hauff <quexington@gmail.com> * Also add passed-in coin spends when processing new blocks in reconsider_peak (#6898) Co-authored-by: Adam Kelly <aqk> * Moved debug_spend_bundle and added it to the SpendBundle object (#6840) * Moved debug_spend_bundle and added it to the SpendBundle object * Remove problematic typing * Add testnet config * wallet: Memory would get corrupted if there was an error (#6902) * wallet: Memory would get corrupted if there was an error * wallet: Use block_record * wallet: Add records in a full fork too * wallet: remove unnecessary arguments in CC and DID * add to cache, revert if transaction fails Co-authored-by: Yostra <straya@chia.net> * Improve comment * pool_wallet: Fix driver bug * wallet: Fix memory corruption * gui: Update to latest * Increase memory size * tests: Add test for absorbing from pool * small fix in solution_to_extra_data * Fixed incorrect function name * pooling: Fix EOS handling in full node * [pools.testnet9]add post /partial and /farmer header (#6957) * Update farmer.py add post header * Update farmer_api.py add post header * Update chia/farmer/farmer.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Update chia/farmer/farmer_api.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Fix lint and cleanup farmer.py * farmer: Fix linting issues (#7010) * Handle the case of incorrectly formatted PoolState data returned from inner singleton * wallet: Resubmit transaction if not successful, rename to new_transaction_block_callback (#7008) * Fix lint in pool_puzzles * pooling: Fix owner private key lookup, and remove unnecessary argument * pooling: Clear target state on `delete_unconfirmed_transactions` * Lint * Fix non-deterministic test * Slight cleanup clvm driver code (#7028) * Return None when a deserialized CLVM structure does not fit the expected format of var-value pair for singleton data * lint Co-authored-by: Adam Kelly <aqk> * Revert "Add testnet config" This reverts commit 98124427241b8a268fbab43ac116887c89e9974f. Co-authored-by: matt <matt@chia.net> Co-authored-by: Adam Kelly <aqk@aqk.im> Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Matt Hauff <quexington@gmail.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: Adam <aqk@Adams-MacBook-Pro.local> Co-authored-by: Adam Kelly <aqk> Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: xdustinface <xdustinfacex@gmail.com> Co-authored-by: almog <almogdepaz@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Earle Lowe <e.lowe@chia.net> Co-authored-by: arvidn <arvid@libtorrent.org> Co-authored-by: willi123yao <willi123yao@gmail.com> Co-authored-by: arty <art.yerkes@gmail.com> Co-authored-by: William Blanke <wjb98672@gmail.com> Co-authored-by: matt-o-how <48453825+matt-o-how@users.noreply.github.com> Co-authored-by: Chris Marslender <chrismarslender@gmail.com> Co-authored-by: Yostra <straya@chia.net> Co-authored-by: DouCrazy <43004977+lpf763827726@users.noreply.github.com>
2021-06-30 00:21:25 +03:00
async def get_puzzle_hash(self, new: bool) -> bytes32:
if new:
return await self.get_new_puzzlehash()
else:
record: Optional[
DerivationRecord
] = await self.wallet_state_manager.get_current_derivation_record_for_wallet(self.id())
if record is None:
return await self.get_new_puzzlehash()
return record.puzzle_hash
Pools mainnet (#7047) * added clarifying comments * WIP test * added WIP test * Refine genesis challenge. Remove unnecessary pool_puzzle function * Sign spend. Remove create_member_spend. Rename state transition function to create_travel_spend * Rename create_member_spend to create_travel_spend * Add singleton id logging * Enhance logging for debugging * renaming * rephrase inside the puzzle * fixed signing and added some support functions * Fix issue with announcement * Progress spending the singleton * Fix arguments to pool_state_to_inner_puzzle call * Fix arguments to pool_state_to_inner_puzzle * Improve error message when wallet is not running * Remove misleading message about missing wallet process, when problem is the farmer by making poolnft command error out earlier * Fix parent coin info bug * Multiple state transitions in one block * Lint * Remove assert * Fix incorrect p2_singleton_ph calculation (thanks nil00) * Update waiting room puzzle to accept genesis_challenge * Update calls to create_waiting * Go to waiting state from committed state * Augment debug_spend_bundle * fix 2 bugs in wallet * Fix lint * fix bad_agg_sig bug * Tests and lint * remove breakpoint * fix clvm tests for new hexs and hashs * Fixed a bug in the coin store that was probably from merging. (#6577) * Fixed a bug in the coin store that was probably from merging. * The exception doesn't need to be there * CI Lint fix * Added lifecycle tests for pooling drivers (#6610) * Ms.poolabsorb (#6615) * Support for absorbing rewards in pools (untested) * Style improvements * More work on absorb * Revert default root and remove log * Revert small plots * Use real sub slot iters * Update types * debug1 * Fix bugs * fix output of agg sig log messages * Make fewer calls to pw_status in test * remove old comment * logging and state management * logging * small bug fix & rename for accuracy * format * Fix types for uncurry function * lint * Update test to use exceptions * Change assumptions about self-pooling in lifecycle test * Install types for mypy * Revert "Install types for mypy" This reverts commit a82dcb712a6a97b8789b17c98cac8eafaffe90f5. * install types for mypy * install types for mypy * More keys * Remove flags requiring interactive prompts * Change initial spend to waiting room if self-pooling * lint * lint * linting * Refactor test * Use correct value in log message * update p2_singleton_or_delated_puzhash * initial version of pool wallet with p2_singleton_or_delay * run black formatting * fix rebase wonkiness * fix announcement code in p2_singleton_or_delayed * removed redundant defaulting standardised hexstr handling * lint fixes * Fixed pool lifecycle tests to current standards, but discovered tests are not validating signatures * Signatures validate on this test now although the test still does not check it. * Lint fix * Fixed plotnft show and linting errors * fixed failing farmer/harvester rpc test * lint fix * Commenting out some outdated tests * Updated test coverage * lint fix * Some minor P2singleton improvements (#6325) * Improve some debugging tools. * Tidy pool clvm. * Use `SINGLETON_STRUCT`. Remove unused `and` macro. * Use better name `SINGLETON_MOD_HASH`. * Finish lifecycle test suite. * Fixing for merge with chia-blockchain/pools_delayed_puzzle (#72) Co-authored-by: Matt Hauff <quexington@gmail.com> * Default delay time was being set incorrectly * Extracted get_delayed_puz_info_from_launcher_spend to driver code * Ms.taproot plot2 (#6692) * Start work on adding taproot to new plots * Fix issue in block_tools * new test-cache * Lint * DID fixexs * Fix other tests * Python black * Fix full node store test * Ensure block index <= 128 bits. * fix test_pool_config test * fix comments in pool_config and in chialisp files * self_pool -> pool -> self_pool * Implement leaving pools * Fix conflicts with main via mini-rebase * Fixup rebase mistakes * Bring in Mariano's node discovery chagnes from pools.dev * Fix adapters - Thanks Richard * build tests * Add pools tests * Disable DID tests * farmer|protocol: Some renaming related to the pool protocol * farmer: Use `None` instead of `{}` and add local `pool_state` * protocol|farmer: Introduce and use `PoolErrorCode` * rename: `pool_payout_instructions` -> `payout_instructions` * refactor: `AuthenticationKeyInfo` -> `authentication_key` * refactor: Move `launcher_id` up * rename: Some variable name changes * rename: `points_balance` -> `points` * format: Squash aggregation into one line * farmer: Make `update_pool_state` public * farmer: Print traceback if `update_pool_state` fails * farmer: Periodically call `GET /pool_info`, add `_pool_get_pool_info` * farmer: Add `authentication_token_timeout` to `pool_state` Fetch it from `GET /pool_info` * protocol|farmer: Implement support for `GET|POST|PUT /farmer` * farmer: Make use of `GET|POST /farmer` - To make the farmer known by the pool - To update local balance/difficulty from the pool periodically * farmer|protocol: Adjust `POST /partial` to match the latest spec * farmer: Hash messages before signing * pools: Drop unused code * farmer: Fix aggregation of partial signatures * farmer: support self pooling, don't pool if url=="" * wallet: return uint64 for delay time, instead of bytes * pool: add error code for delay time too short * farmer: cleaner logging when no connection to pool * farmer: add harvester node id to pool protocol * Rename method (test fix) and lint fix * Change errors to warnings (pool communication) * Remove pool callbacks on a reorg * farmer: Continue earlier when no pool URL is provided * farmer: Print method in log * farmer: Handle exceptions for all pool endpoint calls * farmer|protocol: Keep track of failed requests to the pool * farmer: Fix typo which caused issue with pooling * wallet: simplify solution_to_extra_data * tests: Comment out DID tests which are not working yet * Remove DID Wallet test workflows * Return launcher_id when creating Pool Wallet * Name p2_singleton_puzzle_hash correctly * Improve 'test_singleton_lifecycle_fast.py'. * Make test more robust in the face of asynchronous adversity * Add commandline cmds for joining and leaving pools * Fix poolnft leave params * Remove redundant assignment brought in from main * Remove unneeded code * Style and parsimony * pool_puzzles: Check was wrong, and bad naming * format: Fix linting * format: Remove log and rename variable * pool-wallet: Fix self pooling with multiple pool wallets. Don't remove interested puzzle_hash * gui: Use pools branch * format: fix lint * Remove ununsed code, improve initial_pool_state_from_dict * farmer: Instantly update the config, when config file changes * format: Speed up loading of the authentication key * logging: less annoying logging * Test pool NFT creation directly to pool * Test switching pools without self-farming in between * lint * pooling: Use integer for protocol version (#6797) * pooling: Use integer for protocol version * pooling: Fix import * Update GUI commit * Ms.login2 (#6804) * pooling: Login WIP * pooling: add RPC for get_link * dont use timeout * pooling: rename to get_login_link * format: remove logging * Fix SES test * Required cli argument Co-authored-by: almog <almogdepaz@gmail.com> * farmer|protocols: Rename `current_difficulty` for `POST /partial` (#6807) * Fix to farm summary * Use target_puzzlehash param name in RPC call * Pool test coverage (#6782) * Improvement in test coverage and typing * Added an extra absorb to the pool lifecycle test (only works when merged with https://github.com/Chia-Network/chia-blockchain/pull/6733) * Added new drivers for the p2_singleton puzzles * Added new tests and test coverage for singletons * organize pools testing directory * black formatting * black formatting in venv * lint fix * Update CI tests * Fixing tests post rebase * lint fix * Minor readability fix Co-authored-by: matt <matt@chia.net> * farmer: Drop `target_puzzle_hash` from `GET /farmer` and `GET /login` (#6816) * Allow creation of PlotNFTs in self-farming state * gui: Fix install with more RAM (#6821) * Allow implicit payout_address in self-pool state, improve error messages and param ergonomics * print units in non-standard wallets correctly * Fix farmer import * Make syncing message in CLI more intuitive like the GUI * Fix linting and show header hash instead of height * gui: Update to 725071236eff8c81d5b267dc8eb69d7e03f3df8c * Revert "Merge" This reverts commit 23a1e688c5fb4f72983fd896d4933336a365fe38, reversing changes made to a850246c6f4de4d2eb65c4ac1d6023431f3ba7e9. * Revert "Revert "Merge"" This reverts commit 680331859f5dc404cca9c2ff8f4a61df374db125. * Treat tx_record as Dict. Refactor tx submission * Also add passed-in coin spends when processing new blocks in reconsider_peak * Test utilities had moved * Fix import of moved block_tools * Potentially fix yaml * Previously didn't take the right part of this change * Add -y flag, improve commandline plotnft handling * Fix typo * Add -y flag to plotnft create * pool_wallet: Restore from DB properly * wallet: ignore bad pool configs * Reduce memory * pool_wallet: Add claim command * pool_wallet: Set transaction records to confirmed * wallet: Fix bug in transaction cache * Formatting and remove log * pool_wallet: CLI balance and improvements to plotnft_funcs.py * pool_wallet: Simplify, and fix issue with double submission * pool_wallet: Fix tests * pool_wallet: Don't allow switching before relative lock height * update gui * change to 3000 mem * Correct sense of -y flag for self-pooling * cli: Display payout instructions for pool * pool_wallet: Don't create massive transactions * cli: Improvements to plotnft * pool_wallet: Get correct pool state * pool_wallet: Use last transaction block to prevent condition failure * Add block height for current state * Add outstanding unconfirmed transactions to pw_status * Refine command line plotnft show pending transactions * Fix tests by using the correct output from pw_status * Try to fix windows build * Print expected leave height * label pool urls * pool_wallet: Don't include pool 1.75 rewards in total * wallet: Add RPC and CLI for deleting unconfirmed transactions for a wallet * pool_wallet: If farming to a pool, show 0 balance in wallet * pool_wallet: Show error message if invalid state, in CLI * pool_wallet: Don't allow switching if there are pending unconfirmed transactions * tests: Clean up pool test logging * tests: Fix lint * Changed the pool innerpuzzes (#6802) * overload solutions for pool_innerpuz parameters * Fix tests for reduced size puzzles * deleted messy deprecated test * Fix lint. * fix bug where spend types were the wrong way around * merge with richard's lint fix * fix wallet bug remove unnecessary signature add defun-inline for clarity * Swap to defun for absorb case Use cons box for member innerpuz solution * fix if statement for cons box p1 * remove unnecessary solution arg * quick innerpuz fix to make tests pass * Switch to key-value pairs Undo cons box solution in pool_member inner puzzle * fix singleton lifecycle test * added some comments to calrify the meaning on "ps" * lint fix * reduce label size, search for label when reconstructing from solution * no need to keep looping if `p` found * lint fix * Removed unecessary defun-inline and changed hyphens to underscores * Changed created_coin_value_or_0 to an inline function * Changed morph_condition to an inline function * Added a comment for odd_cons_m113 * Rename output_odd and odd_output_found * Add inline functions to document the lineage proof values * Stager two rewrite * Added an ASSER_MY_AMOUNT to p2_singleton_or_delayed * Extract truth functionality to singleton_truths.clib * Fix tree hashes * Changed truths to a struct rather than a list. * fix test_singletons update did_innerpuz * recompile did_innerpuz * fix a log error * Renamed variable and factored out code per @richardkiss * lint fix * switch launcher extra_data to key_value pairs * fix parsing of new format of extra_data in launcher solution * fix broken test for new launcher solution format * remove bare raise Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: Matt Hauff <quexington@gmail.com> * Also add passed-in coin spends when processing new blocks in reconsider_peak (#6898) Co-authored-by: Adam Kelly <aqk> * Moved debug_spend_bundle and added it to the SpendBundle object (#6840) * Moved debug_spend_bundle and added it to the SpendBundle object * Remove problematic typing * Add testnet config * wallet: Memory would get corrupted if there was an error (#6902) * wallet: Memory would get corrupted if there was an error * wallet: Use block_record * wallet: Add records in a full fork too * wallet: remove unnecessary arguments in CC and DID * add to cache, revert if transaction fails Co-authored-by: Yostra <straya@chia.net> * Improve comment * pool_wallet: Fix driver bug * wallet: Fix memory corruption * gui: Update to latest * Increase memory size * tests: Add test for absorbing from pool * small fix in solution_to_extra_data * Fixed incorrect function name * pooling: Fix EOS handling in full node * [pools.testnet9]add post /partial and /farmer header (#6957) * Update farmer.py add post header * Update farmer_api.py add post header * Update chia/farmer/farmer.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Update chia/farmer/farmer_api.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Fix lint and cleanup farmer.py * farmer: Fix linting issues (#7010) * Handle the case of incorrectly formatted PoolState data returned from inner singleton * wallet: Resubmit transaction if not successful, rename to new_transaction_block_callback (#7008) * Fix lint in pool_puzzles * pooling: Fix owner private key lookup, and remove unnecessary argument * pooling: Clear target state on `delete_unconfirmed_transactions` * Lint * Fix non-deterministic test * Slight cleanup clvm driver code (#7028) * Return None when a deserialized CLVM structure does not fit the expected format of var-value pair for singleton data * lint Co-authored-by: Adam Kelly <aqk> * Revert "Add testnet config" This reverts commit 98124427241b8a268fbab43ac116887c89e9974f. Co-authored-by: matt <matt@chia.net> Co-authored-by: Adam Kelly <aqk@aqk.im> Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Matt Hauff <quexington@gmail.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: Adam <aqk@Adams-MacBook-Pro.local> Co-authored-by: Adam Kelly <aqk> Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: xdustinface <xdustinfacex@gmail.com> Co-authored-by: almog <almogdepaz@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Earle Lowe <e.lowe@chia.net> Co-authored-by: arvidn <arvid@libtorrent.org> Co-authored-by: willi123yao <willi123yao@gmail.com> Co-authored-by: arty <art.yerkes@gmail.com> Co-authored-by: William Blanke <wjb98672@gmail.com> Co-authored-by: matt-o-how <48453825+matt-o-how@users.noreply.github.com> Co-authored-by: Chris Marslender <chrismarslender@gmail.com> Co-authored-by: Yostra <straya@chia.net> Co-authored-by: DouCrazy <43004977+lpf763827726@users.noreply.github.com>
2021-06-30 00:21:25 +03:00
async def get_new_puzzlehash(self, in_transaction: bool = False) -> bytes32:
return (await self.wallet_state_manager.get_unused_derivation_record(self.id(), in_transaction)).puzzle_hash
2020-02-12 04:01:39 +03:00
def make_solution(
self,
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
primaries: List[AmountWithPuzzlehash],
min_time=0,
me=None,
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
coin_announcements: Optional[Set[bytes]] = None,
Pools mainnet (#7047) * added clarifying comments * WIP test * added WIP test * Refine genesis challenge. Remove unnecessary pool_puzzle function * Sign spend. Remove create_member_spend. Rename state transition function to create_travel_spend * Rename create_member_spend to create_travel_spend * Add singleton id logging * Enhance logging for debugging * renaming * rephrase inside the puzzle * fixed signing and added some support functions * Fix issue with announcement * Progress spending the singleton * Fix arguments to pool_state_to_inner_puzzle call * Fix arguments to pool_state_to_inner_puzzle * Improve error message when wallet is not running * Remove misleading message about missing wallet process, when problem is the farmer by making poolnft command error out earlier * Fix parent coin info bug * Multiple state transitions in one block * Lint * Remove assert * Fix incorrect p2_singleton_ph calculation (thanks nil00) * Update waiting room puzzle to accept genesis_challenge * Update calls to create_waiting * Go to waiting state from committed state * Augment debug_spend_bundle * fix 2 bugs in wallet * Fix lint * fix bad_agg_sig bug * Tests and lint * remove breakpoint * fix clvm tests for new hexs and hashs * Fixed a bug in the coin store that was probably from merging. (#6577) * Fixed a bug in the coin store that was probably from merging. * The exception doesn't need to be there * CI Lint fix * Added lifecycle tests for pooling drivers (#6610) * Ms.poolabsorb (#6615) * Support for absorbing rewards in pools (untested) * Style improvements * More work on absorb * Revert default root and remove log * Revert small plots * Use real sub slot iters * Update types * debug1 * Fix bugs * fix output of agg sig log messages * Make fewer calls to pw_status in test * remove old comment * logging and state management * logging * small bug fix & rename for accuracy * format * Fix types for uncurry function * lint * Update test to use exceptions * Change assumptions about self-pooling in lifecycle test * Install types for mypy * Revert "Install types for mypy" This reverts commit a82dcb712a6a97b8789b17c98cac8eafaffe90f5. * install types for mypy * install types for mypy * More keys * Remove flags requiring interactive prompts * Change initial spend to waiting room if self-pooling * lint * lint * linting * Refactor test * Use correct value in log message * update p2_singleton_or_delated_puzhash * initial version of pool wallet with p2_singleton_or_delay * run black formatting * fix rebase wonkiness * fix announcement code in p2_singleton_or_delayed * removed redundant defaulting standardised hexstr handling * lint fixes * Fixed pool lifecycle tests to current standards, but discovered tests are not validating signatures * Signatures validate on this test now although the test still does not check it. * Lint fix * Fixed plotnft show and linting errors * fixed failing farmer/harvester rpc test * lint fix * Commenting out some outdated tests * Updated test coverage * lint fix * Some minor P2singleton improvements (#6325) * Improve some debugging tools. * Tidy pool clvm. * Use `SINGLETON_STRUCT`. Remove unused `and` macro. * Use better name `SINGLETON_MOD_HASH`. * Finish lifecycle test suite. * Fixing for merge with chia-blockchain/pools_delayed_puzzle (#72) Co-authored-by: Matt Hauff <quexington@gmail.com> * Default delay time was being set incorrectly * Extracted get_delayed_puz_info_from_launcher_spend to driver code * Ms.taproot plot2 (#6692) * Start work on adding taproot to new plots * Fix issue in block_tools * new test-cache * Lint * DID fixexs * Fix other tests * Python black * Fix full node store test * Ensure block index <= 128 bits. * fix test_pool_config test * fix comments in pool_config and in chialisp files * self_pool -> pool -> self_pool * Implement leaving pools * Fix conflicts with main via mini-rebase * Fixup rebase mistakes * Bring in Mariano's node discovery chagnes from pools.dev * Fix adapters - Thanks Richard * build tests * Add pools tests * Disable DID tests * farmer|protocol: Some renaming related to the pool protocol * farmer: Use `None` instead of `{}` and add local `pool_state` * protocol|farmer: Introduce and use `PoolErrorCode` * rename: `pool_payout_instructions` -> `payout_instructions` * refactor: `AuthenticationKeyInfo` -> `authentication_key` * refactor: Move `launcher_id` up * rename: Some variable name changes * rename: `points_balance` -> `points` * format: Squash aggregation into one line * farmer: Make `update_pool_state` public * farmer: Print traceback if `update_pool_state` fails * farmer: Periodically call `GET /pool_info`, add `_pool_get_pool_info` * farmer: Add `authentication_token_timeout` to `pool_state` Fetch it from `GET /pool_info` * protocol|farmer: Implement support for `GET|POST|PUT /farmer` * farmer: Make use of `GET|POST /farmer` - To make the farmer known by the pool - To update local balance/difficulty from the pool periodically * farmer|protocol: Adjust `POST /partial` to match the latest spec * farmer: Hash messages before signing * pools: Drop unused code * farmer: Fix aggregation of partial signatures * farmer: support self pooling, don't pool if url=="" * wallet: return uint64 for delay time, instead of bytes * pool: add error code for delay time too short * farmer: cleaner logging when no connection to pool * farmer: add harvester node id to pool protocol * Rename method (test fix) and lint fix * Change errors to warnings (pool communication) * Remove pool callbacks on a reorg * farmer: Continue earlier when no pool URL is provided * farmer: Print method in log * farmer: Handle exceptions for all pool endpoint calls * farmer|protocol: Keep track of failed requests to the pool * farmer: Fix typo which caused issue with pooling * wallet: simplify solution_to_extra_data * tests: Comment out DID tests which are not working yet * Remove DID Wallet test workflows * Return launcher_id when creating Pool Wallet * Name p2_singleton_puzzle_hash correctly * Improve 'test_singleton_lifecycle_fast.py'. * Make test more robust in the face of asynchronous adversity * Add commandline cmds for joining and leaving pools * Fix poolnft leave params * Remove redundant assignment brought in from main * Remove unneeded code * Style and parsimony * pool_puzzles: Check was wrong, and bad naming * format: Fix linting * format: Remove log and rename variable * pool-wallet: Fix self pooling with multiple pool wallets. Don't remove interested puzzle_hash * gui: Use pools branch * format: fix lint * Remove ununsed code, improve initial_pool_state_from_dict * farmer: Instantly update the config, when config file changes * format: Speed up loading of the authentication key * logging: less annoying logging * Test pool NFT creation directly to pool * Test switching pools without self-farming in between * lint * pooling: Use integer for protocol version (#6797) * pooling: Use integer for protocol version * pooling: Fix import * Update GUI commit * Ms.login2 (#6804) * pooling: Login WIP * pooling: add RPC for get_link * dont use timeout * pooling: rename to get_login_link * format: remove logging * Fix SES test * Required cli argument Co-authored-by: almog <almogdepaz@gmail.com> * farmer|protocols: Rename `current_difficulty` for `POST /partial` (#6807) * Fix to farm summary * Use target_puzzlehash param name in RPC call * Pool test coverage (#6782) * Improvement in test coverage and typing * Added an extra absorb to the pool lifecycle test (only works when merged with https://github.com/Chia-Network/chia-blockchain/pull/6733) * Added new drivers for the p2_singleton puzzles * Added new tests and test coverage for singletons * organize pools testing directory * black formatting * black formatting in venv * lint fix * Update CI tests * Fixing tests post rebase * lint fix * Minor readability fix Co-authored-by: matt <matt@chia.net> * farmer: Drop `target_puzzle_hash` from `GET /farmer` and `GET /login` (#6816) * Allow creation of PlotNFTs in self-farming state * gui: Fix install with more RAM (#6821) * Allow implicit payout_address in self-pool state, improve error messages and param ergonomics * print units in non-standard wallets correctly * Fix farmer import * Make syncing message in CLI more intuitive like the GUI * Fix linting and show header hash instead of height * gui: Update to 725071236eff8c81d5b267dc8eb69d7e03f3df8c * Revert "Merge" This reverts commit 23a1e688c5fb4f72983fd896d4933336a365fe38, reversing changes made to a850246c6f4de4d2eb65c4ac1d6023431f3ba7e9. * Revert "Revert "Merge"" This reverts commit 680331859f5dc404cca9c2ff8f4a61df374db125. * Treat tx_record as Dict. Refactor tx submission * Also add passed-in coin spends when processing new blocks in reconsider_peak * Test utilities had moved * Fix import of moved block_tools * Potentially fix yaml * Previously didn't take the right part of this change * Add -y flag, improve commandline plotnft handling * Fix typo * Add -y flag to plotnft create * pool_wallet: Restore from DB properly * wallet: ignore bad pool configs * Reduce memory * pool_wallet: Add claim command * pool_wallet: Set transaction records to confirmed * wallet: Fix bug in transaction cache * Formatting and remove log * pool_wallet: CLI balance and improvements to plotnft_funcs.py * pool_wallet: Simplify, and fix issue with double submission * pool_wallet: Fix tests * pool_wallet: Don't allow switching before relative lock height * update gui * change to 3000 mem * Correct sense of -y flag for self-pooling * cli: Display payout instructions for pool * pool_wallet: Don't create massive transactions * cli: Improvements to plotnft * pool_wallet: Get correct pool state * pool_wallet: Use last transaction block to prevent condition failure * Add block height for current state * Add outstanding unconfirmed transactions to pw_status * Refine command line plotnft show pending transactions * Fix tests by using the correct output from pw_status * Try to fix windows build * Print expected leave height * label pool urls * pool_wallet: Don't include pool 1.75 rewards in total * wallet: Add RPC and CLI for deleting unconfirmed transactions for a wallet * pool_wallet: If farming to a pool, show 0 balance in wallet * pool_wallet: Show error message if invalid state, in CLI * pool_wallet: Don't allow switching if there are pending unconfirmed transactions * tests: Clean up pool test logging * tests: Fix lint * Changed the pool innerpuzzes (#6802) * overload solutions for pool_innerpuz parameters * Fix tests for reduced size puzzles * deleted messy deprecated test * Fix lint. * fix bug where spend types were the wrong way around * merge with richard's lint fix * fix wallet bug remove unnecessary signature add defun-inline for clarity * Swap to defun for absorb case Use cons box for member innerpuz solution * fix if statement for cons box p1 * remove unnecessary solution arg * quick innerpuz fix to make tests pass * Switch to key-value pairs Undo cons box solution in pool_member inner puzzle * fix singleton lifecycle test * added some comments to calrify the meaning on "ps" * lint fix * reduce label size, search for label when reconstructing from solution * no need to keep looping if `p` found * lint fix * Removed unecessary defun-inline and changed hyphens to underscores * Changed created_coin_value_or_0 to an inline function * Changed morph_condition to an inline function * Added a comment for odd_cons_m113 * Rename output_odd and odd_output_found * Add inline functions to document the lineage proof values * Stager two rewrite * Added an ASSER_MY_AMOUNT to p2_singleton_or_delayed * Extract truth functionality to singleton_truths.clib * Fix tree hashes * Changed truths to a struct rather than a list. * fix test_singletons update did_innerpuz * recompile did_innerpuz * fix a log error * Renamed variable and factored out code per @richardkiss * lint fix * switch launcher extra_data to key_value pairs * fix parsing of new format of extra_data in launcher solution * fix broken test for new launcher solution format * remove bare raise Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: Matt Hauff <quexington@gmail.com> * Also add passed-in coin spends when processing new blocks in reconsider_peak (#6898) Co-authored-by: Adam Kelly <aqk> * Moved debug_spend_bundle and added it to the SpendBundle object (#6840) * Moved debug_spend_bundle and added it to the SpendBundle object * Remove problematic typing * Add testnet config * wallet: Memory would get corrupted if there was an error (#6902) * wallet: Memory would get corrupted if there was an error * wallet: Use block_record * wallet: Add records in a full fork too * wallet: remove unnecessary arguments in CC and DID * add to cache, revert if transaction fails Co-authored-by: Yostra <straya@chia.net> * Improve comment * pool_wallet: Fix driver bug * wallet: Fix memory corruption * gui: Update to latest * Increase memory size * tests: Add test for absorbing from pool * small fix in solution_to_extra_data * Fixed incorrect function name * pooling: Fix EOS handling in full node * [pools.testnet9]add post /partial and /farmer header (#6957) * Update farmer.py add post header * Update farmer_api.py add post header * Update chia/farmer/farmer.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Update chia/farmer/farmer_api.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Fix lint and cleanup farmer.py * farmer: Fix linting issues (#7010) * Handle the case of incorrectly formatted PoolState data returned from inner singleton * wallet: Resubmit transaction if not successful, rename to new_transaction_block_callback (#7008) * Fix lint in pool_puzzles * pooling: Fix owner private key lookup, and remove unnecessary argument * pooling: Clear target state on `delete_unconfirmed_transactions` * Lint * Fix non-deterministic test * Slight cleanup clvm driver code (#7028) * Return None when a deserialized CLVM structure does not fit the expected format of var-value pair for singleton data * lint Co-authored-by: Adam Kelly <aqk> * Revert "Add testnet config" This reverts commit 98124427241b8a268fbab43ac116887c89e9974f. Co-authored-by: matt <matt@chia.net> Co-authored-by: Adam Kelly <aqk@aqk.im> Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Matt Hauff <quexington@gmail.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: Adam <aqk@Adams-MacBook-Pro.local> Co-authored-by: Adam Kelly <aqk> Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: xdustinface <xdustinfacex@gmail.com> Co-authored-by: almog <almogdepaz@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Earle Lowe <e.lowe@chia.net> Co-authored-by: arvidn <arvid@libtorrent.org> Co-authored-by: willi123yao <willi123yao@gmail.com> Co-authored-by: arty <art.yerkes@gmail.com> Co-authored-by: William Blanke <wjb98672@gmail.com> Co-authored-by: matt-o-how <48453825+matt-o-how@users.noreply.github.com> Co-authored-by: Chris Marslender <chrismarslender@gmail.com> Co-authored-by: Yostra <straya@chia.net> Co-authored-by: DouCrazy <43004977+lpf763827726@users.noreply.github.com>
2021-06-30 00:21:25 +03:00
coin_announcements_to_assert: Optional[Set[bytes32]] = None,
puzzle_announcements: Optional[Set[bytes32]] = None,
puzzle_announcements_to_assert: Optional[Set[bytes32]] = None,
fee=0,
2021-02-21 22:24:57 +03:00
) -> Program:
2020-09-16 03:09:17 +03:00
assert fee >= 0
2020-03-06 02:53:36 +03:00
condition_list = []
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
if len(primaries) > 0:
2020-02-13 22:57:40 +03:00
for primary in primaries:
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
if "memos" in primary:
memos: Optional[List[bytes]] = primary["memos"]
if memos is not None and len(memos) == 0:
memos = None
else:
memos = None
condition_list.append(make_create_coin_condition(primary["puzzlehash"], primary["amount"], memos))
2020-02-12 04:01:39 +03:00
if min_time > 0:
condition_list.append(make_assert_absolute_seconds_exceeds_condition(min_time))
2020-02-12 04:01:39 +03:00
if me:
2020-03-06 02:53:36 +03:00
condition_list.append(make_assert_my_coin_id_condition(me["id"]))
2020-04-20 08:08:16 +03:00
if fee:
condition_list.append(make_reserve_fee_condition(fee))
if coin_announcements:
for announcement in coin_announcements:
condition_list.append(make_create_coin_announcement(announcement))
if coin_announcements_to_assert:
for announcement_hash in coin_announcements_to_assert:
condition_list.append(make_assert_coin_announcement(announcement_hash))
if puzzle_announcements:
for announcement in puzzle_announcements:
condition_list.append(make_create_puzzle_announcement(announcement))
if puzzle_announcements_to_assert:
for announcement_hash in puzzle_announcements_to_assert:
condition_list.append(make_assert_puzzle_announcement(announcement_hash))
2020-09-17 02:31:30 +03:00
return solution_for_conditions(condition_list)
2020-02-12 04:01:39 +03:00
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
def add_condition_to_solution(self, condition: Program, solution: Program) -> Program:
python_program = solution.as_python()
python_program[1].append(condition)
return Program.to(python_program)
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
async def select_coins(
self, amount: uint64, exclude: List[Coin] = None, min_coin_amount: Optional[uint128] = None
) -> Set[Coin]:
"""
Returns a set of coins that can be used for generating a new transaction.
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
Note: Must be called under wallet state manager lock
"""
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
spendable_amount: uint128 = await self.get_spendable_balance()
spendable_coins: List[WalletCoinRecord] = list(
await self.wallet_state_manager.get_spendable_coins_for_wallet(self.id())
)
2020-03-28 00:03:48 +03:00
# Try to use coins from the store, if there isn't enough of "unused"
# coins use change coins that are not confirmed yet
unconfirmed_removals: Dict[bytes32, Coin] = await self.wallet_state_manager.unconfirmed_removals_for_wallet(
self.id()
)
2020-12-11 21:44:15 +03:00
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
coins = await select_coins(
spendable_amount,
self.wallet_state_manager.constants.MAX_COIN_AMOUNT,
spendable_coins,
unconfirmed_removals,
self.log,
uint128(amount),
exclude,
min_coin_amount,
)
assert coins is not None and len(coins) > 0
assert sum(c.amount for c in coins) >= amount
return coins
2020-03-19 11:26:51 +03:00
async def _generate_unsigned_transaction(
2020-03-23 22:59:53 +03:00
self,
amount: uint64,
2020-03-23 22:59:53 +03:00
newpuzzlehash: bytes32,
fee: uint64 = uint64(0),
2020-03-23 22:59:53 +03:00
origin_id: bytes32 = None,
coins: Set[Coin] = None,
primaries_input: Optional[List[AmountWithPuzzlehash]] = None,
ignore_max_send_amount: bool = False,
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
coin_announcements_to_consume: Set[Announcement] = None,
puzzle_announcements_to_consume: Set[Announcement] = None,
memos: Optional[List[bytes]] = None,
negative_change_allowed: bool = False,
) -> List[CoinSpend]:
2020-03-06 02:53:36 +03:00
"""
Generates a unsigned transaction in form of List(Puzzle, Solutions)
Note: this must be called under a wallet state manager lock
2020-03-06 02:53:36 +03:00
"""
if primaries_input is None:
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
primaries: Optional[List[AmountWithPuzzlehash]] = None
total_amount = amount + fee
else:
primaries = primaries_input.copy()
primaries_amount = 0
for prim in primaries:
primaries_amount += prim["amount"]
total_amount = amount + fee + primaries_amount
if not ignore_max_send_amount:
max_send = await self.get_max_send_amount()
if total_amount > max_send:
raise ValueError(f"Can't send more than {max_send} in a single transaction")
if coins is None:
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
coins = await self.select_coins(uint64(total_amount))
2020-09-14 12:29:03 +03:00
assert len(coins) > 0
2020-04-01 04:59:14 +03:00
self.log.info(f"coins is not None {coins}")
spend_value = sum([coin.amount for coin in coins])
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
change = spend_value - total_amount
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
if negative_change_allowed:
change = max(0, change)
2021-04-29 20:30:24 +03:00
assert change >= 0
2020-03-06 02:53:36 +03:00
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
if coin_announcements_to_consume is not None:
coin_announcements_bytes: Optional[Set[bytes32]] = {a.name() for a in coin_announcements_to_consume}
else:
coin_announcements_bytes = None
if puzzle_announcements_to_consume is not None:
puzzle_announcements_bytes: Optional[Set[bytes32]] = {a.name() for a in puzzle_announcements_to_consume}
else:
puzzle_announcements_bytes = None
spends: List[CoinSpend] = []
primary_announcement_hash: Optional[bytes32] = None
2020-03-06 02:53:36 +03:00
# Check for duplicates
if primaries is not None:
all_primaries_list = [(p["puzzlehash"], p["amount"]) for p in primaries] + [(newpuzzlehash, amount)]
if len(set(all_primaries_list)) != len(all_primaries_list):
raise ValueError("Cannot create two identical coins")
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
if memos is None:
memos = []
assert memos is not None
for coin in coins:
2020-03-06 02:53:36 +03:00
# Only one coin creates outputs
if origin_id in (None, coin.name()):
origin_id = coin.name()
if primaries is None:
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
if amount > 0:
primaries = [{"puzzlehash": newpuzzlehash, "amount": uint64(amount), "memos": memos}]
else:
primaries = []
else:
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
primaries.append({"puzzlehash": newpuzzlehash, "amount": uint64(amount), "memos": memos})
2020-02-12 04:01:39 +03:00
if change > 0:
change_puzzle_hash: bytes32 = await self.get_new_puzzlehash()
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
primaries.append({"puzzlehash": change_puzzle_hash, "amount": uint64(change), "memos": []})
message_list: List[bytes32] = [c.name() for c in coins]
for primary in primaries:
message_list.append(Coin(coin.name(), primary["puzzlehash"], primary["amount"]).name())
message: bytes32 = std_hash(b"".join(message_list))
puzzle: Program = await self.puzzle_for_puzzle_hash(coin.puzzle_hash)
Pools mainnet (#7047) * added clarifying comments * WIP test * added WIP test * Refine genesis challenge. Remove unnecessary pool_puzzle function * Sign spend. Remove create_member_spend. Rename state transition function to create_travel_spend * Rename create_member_spend to create_travel_spend * Add singleton id logging * Enhance logging for debugging * renaming * rephrase inside the puzzle * fixed signing and added some support functions * Fix issue with announcement * Progress spending the singleton * Fix arguments to pool_state_to_inner_puzzle call * Fix arguments to pool_state_to_inner_puzzle * Improve error message when wallet is not running * Remove misleading message about missing wallet process, when problem is the farmer by making poolnft command error out earlier * Fix parent coin info bug * Multiple state transitions in one block * Lint * Remove assert * Fix incorrect p2_singleton_ph calculation (thanks nil00) * Update waiting room puzzle to accept genesis_challenge * Update calls to create_waiting * Go to waiting state from committed state * Augment debug_spend_bundle * fix 2 bugs in wallet * Fix lint * fix bad_agg_sig bug * Tests and lint * remove breakpoint * fix clvm tests for new hexs and hashs * Fixed a bug in the coin store that was probably from merging. (#6577) * Fixed a bug in the coin store that was probably from merging. * The exception doesn't need to be there * CI Lint fix * Added lifecycle tests for pooling drivers (#6610) * Ms.poolabsorb (#6615) * Support for absorbing rewards in pools (untested) * Style improvements * More work on absorb * Revert default root and remove log * Revert small plots * Use real sub slot iters * Update types * debug1 * Fix bugs * fix output of agg sig log messages * Make fewer calls to pw_status in test * remove old comment * logging and state management * logging * small bug fix & rename for accuracy * format * Fix types for uncurry function * lint * Update test to use exceptions * Change assumptions about self-pooling in lifecycle test * Install types for mypy * Revert "Install types for mypy" This reverts commit a82dcb712a6a97b8789b17c98cac8eafaffe90f5. * install types for mypy * install types for mypy * More keys * Remove flags requiring interactive prompts * Change initial spend to waiting room if self-pooling * lint * lint * linting * Refactor test * Use correct value in log message * update p2_singleton_or_delated_puzhash * initial version of pool wallet with p2_singleton_or_delay * run black formatting * fix rebase wonkiness * fix announcement code in p2_singleton_or_delayed * removed redundant defaulting standardised hexstr handling * lint fixes * Fixed pool lifecycle tests to current standards, but discovered tests are not validating signatures * Signatures validate on this test now although the test still does not check it. * Lint fix * Fixed plotnft show and linting errors * fixed failing farmer/harvester rpc test * lint fix * Commenting out some outdated tests * Updated test coverage * lint fix * Some minor P2singleton improvements (#6325) * Improve some debugging tools. * Tidy pool clvm. * Use `SINGLETON_STRUCT`. Remove unused `and` macro. * Use better name `SINGLETON_MOD_HASH`. * Finish lifecycle test suite. * Fixing for merge with chia-blockchain/pools_delayed_puzzle (#72) Co-authored-by: Matt Hauff <quexington@gmail.com> * Default delay time was being set incorrectly * Extracted get_delayed_puz_info_from_launcher_spend to driver code * Ms.taproot plot2 (#6692) * Start work on adding taproot to new plots * Fix issue in block_tools * new test-cache * Lint * DID fixexs * Fix other tests * Python black * Fix full node store test * Ensure block index <= 128 bits. * fix test_pool_config test * fix comments in pool_config and in chialisp files * self_pool -> pool -> self_pool * Implement leaving pools * Fix conflicts with main via mini-rebase * Fixup rebase mistakes * Bring in Mariano's node discovery chagnes from pools.dev * Fix adapters - Thanks Richard * build tests * Add pools tests * Disable DID tests * farmer|protocol: Some renaming related to the pool protocol * farmer: Use `None` instead of `{}` and add local `pool_state` * protocol|farmer: Introduce and use `PoolErrorCode` * rename: `pool_payout_instructions` -> `payout_instructions` * refactor: `AuthenticationKeyInfo` -> `authentication_key` * refactor: Move `launcher_id` up * rename: Some variable name changes * rename: `points_balance` -> `points` * format: Squash aggregation into one line * farmer: Make `update_pool_state` public * farmer: Print traceback if `update_pool_state` fails * farmer: Periodically call `GET /pool_info`, add `_pool_get_pool_info` * farmer: Add `authentication_token_timeout` to `pool_state` Fetch it from `GET /pool_info` * protocol|farmer: Implement support for `GET|POST|PUT /farmer` * farmer: Make use of `GET|POST /farmer` - To make the farmer known by the pool - To update local balance/difficulty from the pool periodically * farmer|protocol: Adjust `POST /partial` to match the latest spec * farmer: Hash messages before signing * pools: Drop unused code * farmer: Fix aggregation of partial signatures * farmer: support self pooling, don't pool if url=="" * wallet: return uint64 for delay time, instead of bytes * pool: add error code for delay time too short * farmer: cleaner logging when no connection to pool * farmer: add harvester node id to pool protocol * Rename method (test fix) and lint fix * Change errors to warnings (pool communication) * Remove pool callbacks on a reorg * farmer: Continue earlier when no pool URL is provided * farmer: Print method in log * farmer: Handle exceptions for all pool endpoint calls * farmer|protocol: Keep track of failed requests to the pool * farmer: Fix typo which caused issue with pooling * wallet: simplify solution_to_extra_data * tests: Comment out DID tests which are not working yet * Remove DID Wallet test workflows * Return launcher_id when creating Pool Wallet * Name p2_singleton_puzzle_hash correctly * Improve 'test_singleton_lifecycle_fast.py'. * Make test more robust in the face of asynchronous adversity * Add commandline cmds for joining and leaving pools * Fix poolnft leave params * Remove redundant assignment brought in from main * Remove unneeded code * Style and parsimony * pool_puzzles: Check was wrong, and bad naming * format: Fix linting * format: Remove log and rename variable * pool-wallet: Fix self pooling with multiple pool wallets. Don't remove interested puzzle_hash * gui: Use pools branch * format: fix lint * Remove ununsed code, improve initial_pool_state_from_dict * farmer: Instantly update the config, when config file changes * format: Speed up loading of the authentication key * logging: less annoying logging * Test pool NFT creation directly to pool * Test switching pools without self-farming in between * lint * pooling: Use integer for protocol version (#6797) * pooling: Use integer for protocol version * pooling: Fix import * Update GUI commit * Ms.login2 (#6804) * pooling: Login WIP * pooling: add RPC for get_link * dont use timeout * pooling: rename to get_login_link * format: remove logging * Fix SES test * Required cli argument Co-authored-by: almog <almogdepaz@gmail.com> * farmer|protocols: Rename `current_difficulty` for `POST /partial` (#6807) * Fix to farm summary * Use target_puzzlehash param name in RPC call * Pool test coverage (#6782) * Improvement in test coverage and typing * Added an extra absorb to the pool lifecycle test (only works when merged with https://github.com/Chia-Network/chia-blockchain/pull/6733) * Added new drivers for the p2_singleton puzzles * Added new tests and test coverage for singletons * organize pools testing directory * black formatting * black formatting in venv * lint fix * Update CI tests * Fixing tests post rebase * lint fix * Minor readability fix Co-authored-by: matt <matt@chia.net> * farmer: Drop `target_puzzle_hash` from `GET /farmer` and `GET /login` (#6816) * Allow creation of PlotNFTs in self-farming state * gui: Fix install with more RAM (#6821) * Allow implicit payout_address in self-pool state, improve error messages and param ergonomics * print units in non-standard wallets correctly * Fix farmer import * Make syncing message in CLI more intuitive like the GUI * Fix linting and show header hash instead of height * gui: Update to 725071236eff8c81d5b267dc8eb69d7e03f3df8c * Revert "Merge" This reverts commit 23a1e688c5fb4f72983fd896d4933336a365fe38, reversing changes made to a850246c6f4de4d2eb65c4ac1d6023431f3ba7e9. * Revert "Revert "Merge"" This reverts commit 680331859f5dc404cca9c2ff8f4a61df374db125. * Treat tx_record as Dict. Refactor tx submission * Also add passed-in coin spends when processing new blocks in reconsider_peak * Test utilities had moved * Fix import of moved block_tools * Potentially fix yaml * Previously didn't take the right part of this change * Add -y flag, improve commandline plotnft handling * Fix typo * Add -y flag to plotnft create * pool_wallet: Restore from DB properly * wallet: ignore bad pool configs * Reduce memory * pool_wallet: Add claim command * pool_wallet: Set transaction records to confirmed * wallet: Fix bug in transaction cache * Formatting and remove log * pool_wallet: CLI balance and improvements to plotnft_funcs.py * pool_wallet: Simplify, and fix issue with double submission * pool_wallet: Fix tests * pool_wallet: Don't allow switching before relative lock height * update gui * change to 3000 mem * Correct sense of -y flag for self-pooling * cli: Display payout instructions for pool * pool_wallet: Don't create massive transactions * cli: Improvements to plotnft * pool_wallet: Get correct pool state * pool_wallet: Use last transaction block to prevent condition failure * Add block height for current state * Add outstanding unconfirmed transactions to pw_status * Refine command line plotnft show pending transactions * Fix tests by using the correct output from pw_status * Try to fix windows build * Print expected leave height * label pool urls * pool_wallet: Don't include pool 1.75 rewards in total * wallet: Add RPC and CLI for deleting unconfirmed transactions for a wallet * pool_wallet: If farming to a pool, show 0 balance in wallet * pool_wallet: Show error message if invalid state, in CLI * pool_wallet: Don't allow switching if there are pending unconfirmed transactions * tests: Clean up pool test logging * tests: Fix lint * Changed the pool innerpuzzes (#6802) * overload solutions for pool_innerpuz parameters * Fix tests for reduced size puzzles * deleted messy deprecated test * Fix lint. * fix bug where spend types were the wrong way around * merge with richard's lint fix * fix wallet bug remove unnecessary signature add defun-inline for clarity * Swap to defun for absorb case Use cons box for member innerpuz solution * fix if statement for cons box p1 * remove unnecessary solution arg * quick innerpuz fix to make tests pass * Switch to key-value pairs Undo cons box solution in pool_member inner puzzle * fix singleton lifecycle test * added some comments to calrify the meaning on "ps" * lint fix * reduce label size, search for label when reconstructing from solution * no need to keep looping if `p` found * lint fix * Removed unecessary defun-inline and changed hyphens to underscores * Changed created_coin_value_or_0 to an inline function * Changed morph_condition to an inline function * Added a comment for odd_cons_m113 * Rename output_odd and odd_output_found * Add inline functions to document the lineage proof values * Stager two rewrite * Added an ASSER_MY_AMOUNT to p2_singleton_or_delayed * Extract truth functionality to singleton_truths.clib * Fix tree hashes * Changed truths to a struct rather than a list. * fix test_singletons update did_innerpuz * recompile did_innerpuz * fix a log error * Renamed variable and factored out code per @richardkiss * lint fix * switch launcher extra_data to key_value pairs * fix parsing of new format of extra_data in launcher solution * fix broken test for new launcher solution format * remove bare raise Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: Matt Hauff <quexington@gmail.com> * Also add passed-in coin spends when processing new blocks in reconsider_peak (#6898) Co-authored-by: Adam Kelly <aqk> * Moved debug_spend_bundle and added it to the SpendBundle object (#6840) * Moved debug_spend_bundle and added it to the SpendBundle object * Remove problematic typing * Add testnet config * wallet: Memory would get corrupted if there was an error (#6902) * wallet: Memory would get corrupted if there was an error * wallet: Use block_record * wallet: Add records in a full fork too * wallet: remove unnecessary arguments in CC and DID * add to cache, revert if transaction fails Co-authored-by: Yostra <straya@chia.net> * Improve comment * pool_wallet: Fix driver bug * wallet: Fix memory corruption * gui: Update to latest * Increase memory size * tests: Add test for absorbing from pool * small fix in solution_to_extra_data * Fixed incorrect function name * pooling: Fix EOS handling in full node * [pools.testnet9]add post /partial and /farmer header (#6957) * Update farmer.py add post header * Update farmer_api.py add post header * Update chia/farmer/farmer.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Update chia/farmer/farmer_api.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Fix lint and cleanup farmer.py * farmer: Fix linting issues (#7010) * Handle the case of incorrectly formatted PoolState data returned from inner singleton * wallet: Resubmit transaction if not successful, rename to new_transaction_block_callback (#7008) * Fix lint in pool_puzzles * pooling: Fix owner private key lookup, and remove unnecessary argument * pooling: Clear target state on `delete_unconfirmed_transactions` * Lint * Fix non-deterministic test * Slight cleanup clvm driver code (#7028) * Return None when a deserialized CLVM structure does not fit the expected format of var-value pair for singleton data * lint Co-authored-by: Adam Kelly <aqk> * Revert "Add testnet config" This reverts commit 98124427241b8a268fbab43ac116887c89e9974f. Co-authored-by: matt <matt@chia.net> Co-authored-by: Adam Kelly <aqk@aqk.im> Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Matt Hauff <quexington@gmail.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: Adam <aqk@Adams-MacBook-Pro.local> Co-authored-by: Adam Kelly <aqk> Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: xdustinface <xdustinfacex@gmail.com> Co-authored-by: almog <almogdepaz@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Earle Lowe <e.lowe@chia.net> Co-authored-by: arvidn <arvid@libtorrent.org> Co-authored-by: willi123yao <willi123yao@gmail.com> Co-authored-by: arty <art.yerkes@gmail.com> Co-authored-by: William Blanke <wjb98672@gmail.com> Co-authored-by: matt-o-how <48453825+matt-o-how@users.noreply.github.com> Co-authored-by: Chris Marslender <chrismarslender@gmail.com> Co-authored-by: Yostra <straya@chia.net> Co-authored-by: DouCrazy <43004977+lpf763827726@users.noreply.github.com>
2021-06-30 00:21:25 +03:00
solution: Program = self.make_solution(
primaries=primaries,
fee=fee,
coin_announcements={message},
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
coin_announcements_to_assert=coin_announcements_bytes,
puzzle_announcements_to_assert=puzzle_announcements_bytes,
Pools mainnet (#7047) * added clarifying comments * WIP test * added WIP test * Refine genesis challenge. Remove unnecessary pool_puzzle function * Sign spend. Remove create_member_spend. Rename state transition function to create_travel_spend * Rename create_member_spend to create_travel_spend * Add singleton id logging * Enhance logging for debugging * renaming * rephrase inside the puzzle * fixed signing and added some support functions * Fix issue with announcement * Progress spending the singleton * Fix arguments to pool_state_to_inner_puzzle call * Fix arguments to pool_state_to_inner_puzzle * Improve error message when wallet is not running * Remove misleading message about missing wallet process, when problem is the farmer by making poolnft command error out earlier * Fix parent coin info bug * Multiple state transitions in one block * Lint * Remove assert * Fix incorrect p2_singleton_ph calculation (thanks nil00) * Update waiting room puzzle to accept genesis_challenge * Update calls to create_waiting * Go to waiting state from committed state * Augment debug_spend_bundle * fix 2 bugs in wallet * Fix lint * fix bad_agg_sig bug * Tests and lint * remove breakpoint * fix clvm tests for new hexs and hashs * Fixed a bug in the coin store that was probably from merging. (#6577) * Fixed a bug in the coin store that was probably from merging. * The exception doesn't need to be there * CI Lint fix * Added lifecycle tests for pooling drivers (#6610) * Ms.poolabsorb (#6615) * Support for absorbing rewards in pools (untested) * Style improvements * More work on absorb * Revert default root and remove log * Revert small plots * Use real sub slot iters * Update types * debug1 * Fix bugs * fix output of agg sig log messages * Make fewer calls to pw_status in test * remove old comment * logging and state management * logging * small bug fix & rename for accuracy * format * Fix types for uncurry function * lint * Update test to use exceptions * Change assumptions about self-pooling in lifecycle test * Install types for mypy * Revert "Install types for mypy" This reverts commit a82dcb712a6a97b8789b17c98cac8eafaffe90f5. * install types for mypy * install types for mypy * More keys * Remove flags requiring interactive prompts * Change initial spend to waiting room if self-pooling * lint * lint * linting * Refactor test * Use correct value in log message * update p2_singleton_or_delated_puzhash * initial version of pool wallet with p2_singleton_or_delay * run black formatting * fix rebase wonkiness * fix announcement code in p2_singleton_or_delayed * removed redundant defaulting standardised hexstr handling * lint fixes * Fixed pool lifecycle tests to current standards, but discovered tests are not validating signatures * Signatures validate on this test now although the test still does not check it. * Lint fix * Fixed plotnft show and linting errors * fixed failing farmer/harvester rpc test * lint fix * Commenting out some outdated tests * Updated test coverage * lint fix * Some minor P2singleton improvements (#6325) * Improve some debugging tools. * Tidy pool clvm. * Use `SINGLETON_STRUCT`. Remove unused `and` macro. * Use better name `SINGLETON_MOD_HASH`. * Finish lifecycle test suite. * Fixing for merge with chia-blockchain/pools_delayed_puzzle (#72) Co-authored-by: Matt Hauff <quexington@gmail.com> * Default delay time was being set incorrectly * Extracted get_delayed_puz_info_from_launcher_spend to driver code * Ms.taproot plot2 (#6692) * Start work on adding taproot to new plots * Fix issue in block_tools * new test-cache * Lint * DID fixexs * Fix other tests * Python black * Fix full node store test * Ensure block index <= 128 bits. * fix test_pool_config test * fix comments in pool_config and in chialisp files * self_pool -> pool -> self_pool * Implement leaving pools * Fix conflicts with main via mini-rebase * Fixup rebase mistakes * Bring in Mariano's node discovery chagnes from pools.dev * Fix adapters - Thanks Richard * build tests * Add pools tests * Disable DID tests * farmer|protocol: Some renaming related to the pool protocol * farmer: Use `None` instead of `{}` and add local `pool_state` * protocol|farmer: Introduce and use `PoolErrorCode` * rename: `pool_payout_instructions` -> `payout_instructions` * refactor: `AuthenticationKeyInfo` -> `authentication_key` * refactor: Move `launcher_id` up * rename: Some variable name changes * rename: `points_balance` -> `points` * format: Squash aggregation into one line * farmer: Make `update_pool_state` public * farmer: Print traceback if `update_pool_state` fails * farmer: Periodically call `GET /pool_info`, add `_pool_get_pool_info` * farmer: Add `authentication_token_timeout` to `pool_state` Fetch it from `GET /pool_info` * protocol|farmer: Implement support for `GET|POST|PUT /farmer` * farmer: Make use of `GET|POST /farmer` - To make the farmer known by the pool - To update local balance/difficulty from the pool periodically * farmer|protocol: Adjust `POST /partial` to match the latest spec * farmer: Hash messages before signing * pools: Drop unused code * farmer: Fix aggregation of partial signatures * farmer: support self pooling, don't pool if url=="" * wallet: return uint64 for delay time, instead of bytes * pool: add error code for delay time too short * farmer: cleaner logging when no connection to pool * farmer: add harvester node id to pool protocol * Rename method (test fix) and lint fix * Change errors to warnings (pool communication) * Remove pool callbacks on a reorg * farmer: Continue earlier when no pool URL is provided * farmer: Print method in log * farmer: Handle exceptions for all pool endpoint calls * farmer|protocol: Keep track of failed requests to the pool * farmer: Fix typo which caused issue with pooling * wallet: simplify solution_to_extra_data * tests: Comment out DID tests which are not working yet * Remove DID Wallet test workflows * Return launcher_id when creating Pool Wallet * Name p2_singleton_puzzle_hash correctly * Improve 'test_singleton_lifecycle_fast.py'. * Make test more robust in the face of asynchronous adversity * Add commandline cmds for joining and leaving pools * Fix poolnft leave params * Remove redundant assignment brought in from main * Remove unneeded code * Style and parsimony * pool_puzzles: Check was wrong, and bad naming * format: Fix linting * format: Remove log and rename variable * pool-wallet: Fix self pooling with multiple pool wallets. Don't remove interested puzzle_hash * gui: Use pools branch * format: fix lint * Remove ununsed code, improve initial_pool_state_from_dict * farmer: Instantly update the config, when config file changes * format: Speed up loading of the authentication key * logging: less annoying logging * Test pool NFT creation directly to pool * Test switching pools without self-farming in between * lint * pooling: Use integer for protocol version (#6797) * pooling: Use integer for protocol version * pooling: Fix import * Update GUI commit * Ms.login2 (#6804) * pooling: Login WIP * pooling: add RPC for get_link * dont use timeout * pooling: rename to get_login_link * format: remove logging * Fix SES test * Required cli argument Co-authored-by: almog <almogdepaz@gmail.com> * farmer|protocols: Rename `current_difficulty` for `POST /partial` (#6807) * Fix to farm summary * Use target_puzzlehash param name in RPC call * Pool test coverage (#6782) * Improvement in test coverage and typing * Added an extra absorb to the pool lifecycle test (only works when merged with https://github.com/Chia-Network/chia-blockchain/pull/6733) * Added new drivers for the p2_singleton puzzles * Added new tests and test coverage for singletons * organize pools testing directory * black formatting * black formatting in venv * lint fix * Update CI tests * Fixing tests post rebase * lint fix * Minor readability fix Co-authored-by: matt <matt@chia.net> * farmer: Drop `target_puzzle_hash` from `GET /farmer` and `GET /login` (#6816) * Allow creation of PlotNFTs in self-farming state * gui: Fix install with more RAM (#6821) * Allow implicit payout_address in self-pool state, improve error messages and param ergonomics * print units in non-standard wallets correctly * Fix farmer import * Make syncing message in CLI more intuitive like the GUI * Fix linting and show header hash instead of height * gui: Update to 725071236eff8c81d5b267dc8eb69d7e03f3df8c * Revert "Merge" This reverts commit 23a1e688c5fb4f72983fd896d4933336a365fe38, reversing changes made to a850246c6f4de4d2eb65c4ac1d6023431f3ba7e9. * Revert "Revert "Merge"" This reverts commit 680331859f5dc404cca9c2ff8f4a61df374db125. * Treat tx_record as Dict. Refactor tx submission * Also add passed-in coin spends when processing new blocks in reconsider_peak * Test utilities had moved * Fix import of moved block_tools * Potentially fix yaml * Previously didn't take the right part of this change * Add -y flag, improve commandline plotnft handling * Fix typo * Add -y flag to plotnft create * pool_wallet: Restore from DB properly * wallet: ignore bad pool configs * Reduce memory * pool_wallet: Add claim command * pool_wallet: Set transaction records to confirmed * wallet: Fix bug in transaction cache * Formatting and remove log * pool_wallet: CLI balance and improvements to plotnft_funcs.py * pool_wallet: Simplify, and fix issue with double submission * pool_wallet: Fix tests * pool_wallet: Don't allow switching before relative lock height * update gui * change to 3000 mem * Correct sense of -y flag for self-pooling * cli: Display payout instructions for pool * pool_wallet: Don't create massive transactions * cli: Improvements to plotnft * pool_wallet: Get correct pool state * pool_wallet: Use last transaction block to prevent condition failure * Add block height for current state * Add outstanding unconfirmed transactions to pw_status * Refine command line plotnft show pending transactions * Fix tests by using the correct output from pw_status * Try to fix windows build * Print expected leave height * label pool urls * pool_wallet: Don't include pool 1.75 rewards in total * wallet: Add RPC and CLI for deleting unconfirmed transactions for a wallet * pool_wallet: If farming to a pool, show 0 balance in wallet * pool_wallet: Show error message if invalid state, in CLI * pool_wallet: Don't allow switching if there are pending unconfirmed transactions * tests: Clean up pool test logging * tests: Fix lint * Changed the pool innerpuzzes (#6802) * overload solutions for pool_innerpuz parameters * Fix tests for reduced size puzzles * deleted messy deprecated test * Fix lint. * fix bug where spend types were the wrong way around * merge with richard's lint fix * fix wallet bug remove unnecessary signature add defun-inline for clarity * Swap to defun for absorb case Use cons box for member innerpuz solution * fix if statement for cons box p1 * remove unnecessary solution arg * quick innerpuz fix to make tests pass * Switch to key-value pairs Undo cons box solution in pool_member inner puzzle * fix singleton lifecycle test * added some comments to calrify the meaning on "ps" * lint fix * reduce label size, search for label when reconstructing from solution * no need to keep looping if `p` found * lint fix * Removed unecessary defun-inline and changed hyphens to underscores * Changed created_coin_value_or_0 to an inline function * Changed morph_condition to an inline function * Added a comment for odd_cons_m113 * Rename output_odd and odd_output_found * Add inline functions to document the lineage proof values * Stager two rewrite * Added an ASSER_MY_AMOUNT to p2_singleton_or_delayed * Extract truth functionality to singleton_truths.clib * Fix tree hashes * Changed truths to a struct rather than a list. * fix test_singletons update did_innerpuz * recompile did_innerpuz * fix a log error * Renamed variable and factored out code per @richardkiss * lint fix * switch launcher extra_data to key_value pairs * fix parsing of new format of extra_data in launcher solution * fix broken test for new launcher solution format * remove bare raise Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: Matt Hauff <quexington@gmail.com> * Also add passed-in coin spends when processing new blocks in reconsider_peak (#6898) Co-authored-by: Adam Kelly <aqk> * Moved debug_spend_bundle and added it to the SpendBundle object (#6840) * Moved debug_spend_bundle and added it to the SpendBundle object * Remove problematic typing * Add testnet config * wallet: Memory would get corrupted if there was an error (#6902) * wallet: Memory would get corrupted if there was an error * wallet: Use block_record * wallet: Add records in a full fork too * wallet: remove unnecessary arguments in CC and DID * add to cache, revert if transaction fails Co-authored-by: Yostra <straya@chia.net> * Improve comment * pool_wallet: Fix driver bug * wallet: Fix memory corruption * gui: Update to latest * Increase memory size * tests: Add test for absorbing from pool * small fix in solution_to_extra_data * Fixed incorrect function name * pooling: Fix EOS handling in full node * [pools.testnet9]add post /partial and /farmer header (#6957) * Update farmer.py add post header * Update farmer_api.py add post header * Update chia/farmer/farmer.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Update chia/farmer/farmer_api.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Fix lint and cleanup farmer.py * farmer: Fix linting issues (#7010) * Handle the case of incorrectly formatted PoolState data returned from inner singleton * wallet: Resubmit transaction if not successful, rename to new_transaction_block_callback (#7008) * Fix lint in pool_puzzles * pooling: Fix owner private key lookup, and remove unnecessary argument * pooling: Clear target state on `delete_unconfirmed_transactions` * Lint * Fix non-deterministic test * Slight cleanup clvm driver code (#7028) * Return None when a deserialized CLVM structure does not fit the expected format of var-value pair for singleton data * lint Co-authored-by: Adam Kelly <aqk> * Revert "Add testnet config" This reverts commit 98124427241b8a268fbab43ac116887c89e9974f. Co-authored-by: matt <matt@chia.net> Co-authored-by: Adam Kelly <aqk@aqk.im> Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Matt Hauff <quexington@gmail.com> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: Adam <aqk@Adams-MacBook-Pro.local> Co-authored-by: Adam Kelly <aqk> Co-authored-by: Richard Kiss <him@richardkiss.com> Co-authored-by: xdustinface <xdustinfacex@gmail.com> Co-authored-by: almog <almogdepaz@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: Earle Lowe <e.lowe@chia.net> Co-authored-by: arvidn <arvid@libtorrent.org> Co-authored-by: willi123yao <willi123yao@gmail.com> Co-authored-by: arty <art.yerkes@gmail.com> Co-authored-by: William Blanke <wjb98672@gmail.com> Co-authored-by: matt-o-how <48453825+matt-o-how@users.noreply.github.com> Co-authored-by: Chris Marslender <chrismarslender@gmail.com> Co-authored-by: Yostra <straya@chia.net> Co-authored-by: DouCrazy <43004977+lpf763827726@users.noreply.github.com>
2021-06-30 00:21:25 +03:00
)
primary_announcement_hash = Announcement(coin.name(), message).name()
2020-03-06 02:53:36 +03:00
spends.append(
CoinSpend(
coin, SerializedProgram.from_bytes(bytes(puzzle)), SerializedProgram.from_bytes(bytes(solution))
)
)
break
else:
raise ValueError("origin_id is not in the set of selected coins")
# Process the non-origin coins now that we have the primary announcement hash
for coin in coins:
if coin.name() == origin_id:
continue
puzzle = await self.puzzle_for_puzzle_hash(coin.puzzle_hash)
solution = self.make_solution(coin_announcements_to_assert={primary_announcement_hash}, primaries=[])
spends.append(
CoinSpend(
coin, SerializedProgram.from_bytes(bytes(puzzle)), SerializedProgram.from_bytes(bytes(solution))
)
)
2020-04-01 04:59:14 +03:00
self.log.debug(f"Spends is {spends}")
2020-02-12 04:01:39 +03:00
return spends
async def sign_transaction(self, coin_spends: List[CoinSpend]) -> SpendBundle:
return await sign_coin_spends(
coin_spends,
self.secret_key_store.secret_key_for_public_key,
self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA,
self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM,
)
2020-02-13 22:57:40 +03:00
async def generate_signed_transaction(
2020-03-23 22:59:53 +03:00
self,
amount: uint64,
puzzle_hash: bytes32,
fee: uint64 = uint64(0),
2020-03-23 22:59:53 +03:00
origin_id: bytes32 = None,
coins: Set[Coin] = None,
primaries: Optional[List[AmountWithPuzzlehash]] = None,
ignore_max_send_amount: bool = False,
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
coin_announcements_to_consume: Set[Announcement] = None,
puzzle_announcements_to_consume: Set[Announcement] = None,
memos: Optional[List[bytes]] = None,
negative_change_allowed: bool = False,
2020-09-14 12:29:03 +03:00
) -> TransactionRecord:
"""
Use this to generate transaction.
Note: this must be called under a wallet state manager lock
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
The first output is (amount, puzzle_hash, memos), and the rest of the outputs are in primaries.
"""
if primaries is None:
non_change_amount = amount
else:
non_change_amount = uint64(amount + sum(p["amount"] for p in primaries))
2020-03-19 11:26:51 +03:00
transaction = await self._generate_unsigned_transaction(
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
amount,
puzzle_hash,
fee,
origin_id,
coins,
primaries,
ignore_max_send_amount,
coin_announcements_to_consume,
puzzle_announcements_to_consume,
memos,
negative_change_allowed,
)
2020-09-14 12:29:03 +03:00
assert len(transaction) > 0
2020-04-01 04:59:14 +03:00
2020-04-01 07:00:49 +03:00
self.log.info("About to sign a transaction")
await self.hack_populate_secret_keys_for_coin_spends(transaction)
spend_bundle: SpendBundle = await sign_coin_spends(
transaction,
self.secret_key_store.secret_key_for_public_key,
self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA,
self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM,
)
2020-02-13 22:57:40 +03:00
2020-04-28 04:42:08 +03:00
now = uint64(int(time.time()))
add_list: List[Coin] = list(spend_bundle.additions())
rem_list: List[Coin] = list(spend_bundle.removals())
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
output_amount = sum(a.amount for a in add_list) + fee
input_amount = sum(r.amount for r in rem_list)
if negative_change_allowed:
assert output_amount >= input_amount
else:
assert output_amount == input_amount
2020-04-28 04:42:08 +03:00
2020-09-14 12:29:03 +03:00
return TransactionRecord(
2021-01-08 07:49:15 +03:00
confirmed_at_height=uint32(0),
2020-04-28 04:42:08 +03:00
created_at_time=now,
to_puzzle_hash=puzzle_hash,
amount=uint64(non_change_amount),
2020-04-28 04:42:08 +03:00
fee_amount=uint64(fee),
confirmed=False,
sent=uint32(0),
spend_bundle=spend_bundle,
additions=add_list,
removals=rem_list,
wallet_id=self.id(),
2020-04-28 04:42:08 +03:00
sent_to=[],
2020-06-12 02:24:10 +03:00
trade_id=None,
Ui farm (#537) * added farm cards * updated farming page updated card, accordion and table components * updated formating * added @chia/core and @chia/icons packages small refactoring * replaced brand with chia icon removed modal dialog * removed old pages added WalletType into the constants * added craco for local alias fixed typos * fixed app provdier and typos * eslint format * updated deps * added minimum K=32 for mainnet added precision = 3 for plot size and total net size refactored plot page added hooks for open and select directory via electron api added react-form-hooks components for material-ui * updated format of the code * fix simulator * black * deps * added plot list * removed unused components moved plot list from farmer into the plot page removed unused console.logs updated format for fee, reward and total number * Bump colorlog to 4.5.0 * Bump colorlog to 4.6.2 * Farm crash fixes (#512) * Bump blspy to 0.2.5 Incorporate @wjblanke's potential bls fix for farming crashes * blspy to 0.2.6 * move to blspy 0.2.7 * added tooltip into the table cell fixed list of the plots added farming visualisation and hook for the farming state * renamed back index to selectKey * transaction type * Bump cbor2 from 5.1.2 to 5.2.0 Bumps [cbor2](https://github.com/agronholm/cbor2) from 5.1.2 to 5.2.0. - [Release notes](https://github.com/agronholm/cbor2/releases) - [Changelog](https://github.com/agronholm/cbor2/blob/master/docs/versionhistory.rst) - [Commits](https://github.com/agronholm/cbor2/compare/5.1.2...5.2.0) Signed-off-by: dependabot[bot] <support@github.com> * Add cbor 5.2.0 to install.sh * Don't forget azure pipelines * Bump sortedcontainers from 2.2.2 to 2.3.0 Bumps [sortedcontainers](https://github.com/grantjenks/python-sortedcontainers) from 2.2.2 to 2.3.0. - [Release notes](https://github.com/grantjenks/python-sortedcontainers/releases) - [Changelog](https://github.com/grantjenks/python-sortedcontainers/blob/master/HISTORY.rst) - [Commits](https://github.com/grantjenks/python-sortedcontainers/compare/v2.2.2...v2.3.0) Signed-off-by: dependabot[bot] <support@github.com> * Bump clvm-tools from 0.1.6 to 0.1.7 Bumps [clvm-tools](https://github.com/Chia-Network/clvm_tools) from 0.1.6 to 0.1.7. - [Release notes](https://github.com/Chia-Network/clvm_tools/releases) - [Commits](https://github.com/Chia-Network/clvm_tools/compare/0.1.6...0.1.7) Signed-off-by: dependabot[bot] <support@github.com> * Have Cbor2 version only rely on setup.py (#518) * cbor2 version should only be in setup.py * Build and install wheels in one step on Azure * swapped standard puzzle to use aggsig_me fixed bug in sign_coin_solutions where aggsig_me would not be signed correctly * cc_wallet and trade_manager use aggsig_me * fixed aggsig_me bug in wallet_tool * appeased superlinter black requests * added aggsig_me to cost_calculator, same as aggsig * black fix cost calculator * Bump chiapos to 0.12.35, catch up changelog * Appease the markdown lint * used new type enum from transaction simplified modals and added new type of modals * updated format of the UI files * added failed and not found plots fixed plot header added delete action for plot * typo * fixed scroll bar in the wallets list * removed unused code and fixed windows build * fixed all known scroll bar issues * added layout sidebar simplified layout flexbox * added radio button to chia/core added box shadow for layout sidebar showed plot in parallel (disabled until we add support) * npm run buil * removed additional fields from queue item * first version of refactored trade part * call get_plots after harvester updated format removed unused console.logs * added plot queue * upnp * Bump pos/vdf/bip158/bls for python 3.9 wheels * downgrade to last good chiavdf - no 3.9 ubuntu yet * Build python 3.8 and 3.9 on MacOS - temporarily compile chiavdf on Mac * Don't build vdf_client at first on Mac 3.9 * Modify typing for python 3.9 (#532) * Give MacOS 3.9 more time to test * try get_args * 3.7 * sys * tuple * is not none * pretty printer versus flake * black * Revert MacOS testing time to 60m max Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com> Co-authored-by: Gene Hoffman <30377676+hoffmang9@users.noreply.github.com> * Bump concurrent-log-handler from 0.9.17 to 0.9.19 (#530) Bumps [concurrent-log-handler](https://github.com/Preston-Landers/concurrent-log-handler) from 0.9.17 to 0.9.19. - [Release notes](https://github.com/Preston-Landers/concurrent-log-handler/releases) - [Changelog](https://github.com/Preston-Landers/concurrent-log-handler/blob/master/CHANGELOG.md) - [Commits](https://github.com/Preston-Landers/concurrent-log-handler/compare/0.9.17...0.9.19) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/upload-artifact from v2.2.0 to v2.2.1 (#528) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from v2.2.0 to v2.2.1. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v2.2.0...726a6dcd0199f578459862705eed35cda05af50b) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump keyring from 21.4.0 to 21.5.0 (#529) Bumps [keyring](https://github.com/jaraco/keyring) from 21.4.0 to 21.5.0. - [Release notes](https://github.com/jaraco/keyring/releases) - [Changelog](https://github.com/jaraco/keyring/blob/master/CHANGES.rst) - [Commits](https://github.com/jaraco/keyring/compare/v21.4.0...v21.5.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Try pyinstaller-4.1 (#533) * Try aiohttp 3.7.3 * fixed mac build * updated formating fixed eslint updated deps compiled locales * fixed locale file format * removed unused code * added "add plot directory" when plots are already there * slovak translation correction * use electron starter from dev branch * updated router and fixed electron build * used TXCH for testnet * removed eslintcache from the git * used correct translation (TXCH) for English locale * added missing plurals library * used same visualization for total size * removed unused code * update package-lock.json * start harvester and farmer * Bump blspy to 0.2.9 and brute force Python 3.9 timelord issue (#540) * Is a bad chiavdf cached? * Bump blspy * Check the env * rm unexpected vdf_client in python 3.9 * Remove debug echo * Bump pos/vdf/bip158/bls for python 3.9 wheels * downgrade to last good chiavdf - no 3.9 ubuntu yet * Bump pos/vdf/bip158/bls for python 3.9 wheels * downgrade to last good chiavdf - no 3.9 ubuntu yet Co-authored-by: Yostra <straya@chia.net> Co-authored-by: Gene Hoffman <30377676+hoffmang9@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthew Howard <matt@chia.net> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com> Co-authored-by: Bill Blanke <wjb2002@flex.com> Co-authored-by: wjblanke <wjb98672@gmail.com>
2020-11-25 22:48:20 +03:00
type=uint32(TransactionType.OUTGOING_TX.value),
name=spend_bundle.name(),
memos=list(compute_memos(spend_bundle).items()),
2020-03-19 22:11:58 +03:00
)
2020-04-21 16:55:59 +03:00
2020-04-28 04:42:08 +03:00
async def push_transaction(self, tx: TransactionRecord) -> None:
"""Use this API to send transactions."""
2020-04-28 04:42:08 +03:00
await self.wallet_state_manager.add_pending_transaction(tx)
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
await self.wallet_state_manager.wallet_node.update_ui()
2020-04-28 04:42:08 +03:00
# This is to be aggregated together with a CAT offer to ensure that the trade happens
2020-12-11 10:27:03 +03:00
async def create_spend_bundle_relative_chia(self, chia_amount: int, exclude: List[Coin]) -> SpendBundle:
2020-04-21 16:55:59 +03:00
list_of_solutions = []
utxos = None
# If we're losing value then get coins with at least that much value
# If we're gaining value then our amount doesn't matter
if chia_amount < 0:
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
utxos = await self.select_coins(uint64(abs(chia_amount)), exclude)
2020-04-21 16:55:59 +03:00
else:
Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit 34a2235de5f120e6e13d3e10a17a514fedeebb5e Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commit adbf7f4f94867aa5bfbded17ae1e568ab802759c Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit 5ebc1ac9fdaf61ee5d67f8d35b247ac776a8178e Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit 7e5a21b4c2b61455b49e0ec547b98e11a1f6b27d Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit 31c95b916d0826c197f862bb43b143dabf89eb72 Merge: d7b91295b d9b0ef5f3 Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit d7b91295b569a2e86c3042d8207c98ec2d12f681 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit 30dc7c0ab43c57885c55c6f84c3c5f9d0275fc73 Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit 6c8c2e4874a4a5f68046a6a1d7b6b8b0c6ce961c Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit 9f79b6f3044e3c188d2f62871e2f28d747e2e629 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit 67c1b3929f7858da29cc83a2c3e512fbb560f8a6 Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit 2d19a5324505de005e5b6a077c43fe368949543b Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit 6ab1cc79bb2355d42c34df3497e34be861d4ec85 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit 582c17aa8db6a337aca95cc4c7157b542f267ad7 Merge: ce2165942 618fbaeba Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit ce2165942972e07de9e1844aa5eb24c06ce0379c Merge: 16aabb3fd 6daba28db Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 16aabb3fd5f459c320dfbecf5af259b90f2a18cb Merge: 0b9fc2845 2286fe426 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit 0b9fc284553138f037d4aef470c7eb7e4a401249 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit 62e74c72f46ec0da33e5efebef3244980d32c967 Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commit e738f44320331cc16ce9456a48709fe8d700f40f Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-16 20:42:46 +03:00
utxos = await self.select_coins(uint64(0), exclude)
2020-04-21 16:55:59 +03:00
2020-09-14 12:29:03 +03:00
assert len(utxos) > 0
2020-04-21 16:55:59 +03:00
# Calculate output amount given sum of utxos
spend_value = sum([coin.amount for coin in utxos])
chia_amount = spend_value + chia_amount
# Create coin solutions for each utxo
output_created = None
for coin in utxos:
puzzle = await self.puzzle_for_puzzle_hash(coin.puzzle_hash)
2020-04-21 16:55:59 +03:00
if output_created is None:
newpuzhash = await self.get_new_puzzlehash()
Merge standalone wallet into main (#9793) * 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 at 71da0487b9cd5564453ec24b76f1ac773c272b75 * Remove unused ignores * more unused ignores * Fix bad merge at 3b143e705057d6c14e2fb3e00078aceff0552d7e * 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>
2022-01-13 23:08:32 +03:00
primaries: List[AmountWithPuzzlehash] = [
{"puzzlehash": newpuzhash, "amount": uint64(chia_amount), "memos": []}
]
2020-04-21 16:55:59 +03:00
solution = self.make_solution(primaries=primaries)
output_created = coin
list_of_solutions.append(CoinSpend(coin, puzzle, solution))
2020-04-21 16:55:59 +03:00
await self.hack_populate_secret_keys_for_coin_spends(list_of_solutions)
spend_bundle = await sign_coin_spends(
list_of_solutions,
self.secret_key_store.secret_key_for_public_key,
self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA,
self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM,
)
2020-09-17 01:53:22 +03:00
return spend_bundle
2022-04-23 00:54:11 +03:00
async def get_coins_to_offer(self, asset_id: Optional[bytes32], amount: uint64) -> Set[Coin]:
balance = await self.get_confirmed_balance()
if balance < amount:
raise Exception(f"insufficient funds in wallet {self.id()}")
return await self.select_coins(amount)