|
76 | 76 | import eu.bittrade.libs.steemj.base.models.operations.CommentOperation; |
77 | 77 | import eu.bittrade.libs.steemj.base.models.operations.CommentOptionsOperation; |
78 | 78 | import eu.bittrade.libs.steemj.base.models.operations.CustomJsonOperation; |
| 79 | +import eu.bittrade.libs.steemj.base.models.operations.DelegateVestingSharesOperation; |
79 | 80 | import eu.bittrade.libs.steemj.base.models.operations.DeleteCommentOperation; |
80 | 81 | import eu.bittrade.libs.steemj.base.models.operations.Operation; |
81 | 82 | import eu.bittrade.libs.steemj.base.models.operations.TransferOperation; |
@@ -3835,4 +3836,87 @@ public ClaimRewardBalanceOperation claimRewards(AccountName accountName) |
3835 | 3836 |
|
3836 | 3837 | return claimOperation; |
3837 | 3838 | } |
| 3839 | + |
| 3840 | + /** |
| 3841 | + * Use this method to delegate Steem Power (Vesting Shares) from the default |
| 3842 | + * account to the <code>delegatee</code> account. The vesting shares are |
| 3843 | + * still owned by the original account, but content voting rights and |
| 3844 | + * bandwidth allocation are transferred to the receiving account. This sets |
| 3845 | + * the delegation to `vesting_shares`, increasing it or decreasing it as |
| 3846 | + * needed. (i.e. a delegation of 0 removes the delegation) When a delegation |
| 3847 | + * is removed the shares are placed in limbo for a week to prevent a satoshi |
| 3848 | + * of VESTS from voting on the same content twice. |
| 3849 | + * |
| 3850 | + * @param delegatee |
| 3851 | + * The account that the vesting shares are delegated to. |
| 3852 | + * @param vestingShares |
| 3853 | + * The amount of vesting shares. |
| 3854 | + * @throws SteemCommunicationException |
| 3855 | + * <ul> |
| 3856 | + * <li>If the server was not able to answer the request in the |
| 3857 | + * given time (see |
| 3858 | + * {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int) |
| 3859 | + * setResponseTimeout}).</li> |
| 3860 | + * <li>If there is a connection problem.</li> |
| 3861 | + * </ul> |
| 3862 | + * @throws SteemResponseException |
| 3863 | + * <ul> |
| 3864 | + * <li>If the SteemJ is unable to transform the JSON response |
| 3865 | + * into a Java object.</li> |
| 3866 | + * <li>If the Server returned an error object.</li> |
| 3867 | + * </ul> |
| 3868 | + * @throws SteemInvalidTransactionException |
| 3869 | + * If there is a problem while signing the transaction. |
| 3870 | + */ |
| 3871 | + public void delegateVestingShares(AccountName delegatee, Asset vestingShares) |
| 3872 | + throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException { |
| 3873 | + if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) { |
| 3874 | + throw new InvalidParameterException(NO_DEFAULT_ACCOUNT_ERROR_MESSAGE); |
| 3875 | + } |
| 3876 | + |
| 3877 | + delegateVestingShares(SteemJConfig.getInstance().getDefaultAccount(), delegatee, vestingShares); |
| 3878 | + } |
| 3879 | + |
| 3880 | + /** |
| 3881 | + * This method is like the |
| 3882 | + * {@link #delegateVestingShares(AccountName, AccountName, Asset)} method, |
| 3883 | + * but allows you to define the author account separately instead of using |
| 3884 | + * the {@link SteemJConfig#getDefaultAccount() DefaultAccount}. |
| 3885 | + * |
| 3886 | + * @param delegator |
| 3887 | + * The account that will delegate the vesting shares. |
| 3888 | + * @param delegatee |
| 3889 | + * The account that the vesting shares are delegated to. |
| 3890 | + * @param vestingShares |
| 3891 | + * The amount of vesting shares. |
| 3892 | + * @throws SteemCommunicationException |
| 3893 | + * <ul> |
| 3894 | + * <li>If the server was not able to answer the request in the |
| 3895 | + * given time (see |
| 3896 | + * {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int) |
| 3897 | + * setResponseTimeout}).</li> |
| 3898 | + * <li>If there is a connection problem.</li> |
| 3899 | + * </ul> |
| 3900 | + * @throws SteemResponseException |
| 3901 | + * <ul> |
| 3902 | + * <li>If the SteemJ is unable to transform the JSON response |
| 3903 | + * into a Java object.</li> |
| 3904 | + * <li>If the Server returned an error object.</li> |
| 3905 | + * </ul> |
| 3906 | + * @throws SteemInvalidTransactionException |
| 3907 | + * If there is a problem while signing the transaction. |
| 3908 | + */ |
| 3909 | + public void delegateVestingShares(AccountName delegator, AccountName delegatee, Asset vestingShares) |
| 3910 | + throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException { |
| 3911 | + DelegateVestingSharesOperation delegateVestingSharesOperation = new DelegateVestingSharesOperation(delegator, |
| 3912 | + delegatee, vestingShares); |
| 3913 | + |
| 3914 | + ArrayList<Operation> operations = new ArrayList<>(); |
| 3915 | + operations.add(delegateVestingSharesOperation); |
| 3916 | + DynamicGlobalProperty globalProperties = this.getDynamicGlobalProperties(); |
| 3917 | + SignedTransaction signedTransaction = new SignedTransaction(globalProperties.getHeadBlockId(), operations, |
| 3918 | + null); |
| 3919 | + signedTransaction.sign(); |
| 3920 | + this.broadcastTransaction(signedTransaction); |
| 3921 | + } |
3838 | 3922 | } |
0 commit comments