|
9 | 9 | from iota.adapter import BaseAdapter, resolve_adapter |
10 | 10 | from iota.commands import BaseCommand, CustomCommand, core, \ |
11 | 11 | discover_commands, extended |
| 12 | +from iota.commands.extended.helpers import Helpers |
12 | 13 | from iota.crypto.addresses import AddressGenerator |
13 | 14 | from iota.crypto.types import Seed |
14 | 15 | from six import with_metaclass |
@@ -440,6 +441,7 @@ def __init__(self, adapter, seed=None, testnet=False): |
440 | 441 | super(Iota, self).__init__(adapter, testnet) |
441 | 442 |
|
442 | 443 | self.seed = Seed(seed) if seed else Seed.random() |
| 444 | + self.helpers = Helpers(self) |
443 | 445 |
|
444 | 446 | def broadcast_and_store(self, trytes): |
445 | 447 | # type: (Iterable[TransactionTrytes]) -> dict |
@@ -773,6 +775,33 @@ def prepare_transfer(self, transfers, inputs=None, change_address=None): |
773 | 775 | changeAddress = change_address, |
774 | 776 | ) |
775 | 777 |
|
| 778 | + def promote_transaction( |
| 779 | + self, |
| 780 | + transaction, |
| 781 | + depth, |
| 782 | + min_weight_magnitude = None, |
| 783 | + ): |
| 784 | + # type: (TransactionHash, int, Optional[int]) -> dict |
| 785 | + """ |
| 786 | + Promotes a transaction by adding spam on top of it. |
| 787 | +
|
| 788 | + :return: |
| 789 | + Dict containing the following values:: |
| 790 | +
|
| 791 | + { |
| 792 | + 'bundle': Bundle, |
| 793 | + The newly-published bundle. |
| 794 | + } |
| 795 | + """ |
| 796 | + if min_weight_magnitude is None: |
| 797 | + min_weight_magnitude = self.default_min_weight_magnitude |
| 798 | + |
| 799 | + return extended.PromoteTransactionCommand(self.adapter)( |
| 800 | + transaction = transaction, |
| 801 | + depth = depth, |
| 802 | + minWeightMagnitude = min_weight_magnitude, |
| 803 | + ) |
| 804 | + |
776 | 805 | def replay_bundle( |
777 | 806 | self, |
778 | 807 | transaction, |
@@ -914,3 +943,27 @@ def send_trytes(self, trytes, depth, min_weight_magnitude=None): |
914 | 943 | depth = depth, |
915 | 944 | minWeightMagnitude = min_weight_magnitude, |
916 | 945 | ) |
| 946 | + |
| 947 | + def is_reattachable(self, addresses): |
| 948 | + # type: (Iterable[Address]) -> dict |
| 949 | + """ |
| 950 | + This API function helps you to determine whether you should replay a |
| 951 | + transaction or make a completely new transaction with a different seed. |
| 952 | + What this function does, is it takes one or more input addresses (i.e. from spent transactions) |
| 953 | + as input and then checks whether any transactions with a value transferred are confirmed. |
| 954 | + If yes, it means that this input address has already been successfully used in a different |
| 955 | + transaction and as such you should no longer replay the transaction. |
| 956 | +
|
| 957 | + :param addresses: |
| 958 | + List of addresses. |
| 959 | +
|
| 960 | + :return: |
| 961 | + Dict containing the following values:: |
| 962 | + { |
| 963 | + 'reattachable': List[bool], |
| 964 | + Always a list, even if only one address was queried. |
| 965 | + } |
| 966 | + """ |
| 967 | + return extended.IsReattachableCommand(self.adapter)( |
| 968 | + addresses=addresses |
| 969 | + ) |
0 commit comments