@@ -3636,11 +3636,12 @@ public void deletePostOrComment(AccountName postOrCommentAuthor, Permlink postOr
36363636 }
36373637
36383638 /**
3639- * Transfer currency from default account to recipient. Amount is
3640- * automatically converted from normalized representation to base
3639+ * Transfer the currency of your choice from
3640+ * {@link SteemJConfig#getDefaultAccount() DefaultAccount} to recipient.
3641+ * Amount is automatically converted from normalized representation to base
36413642 * representation. For example, to transfer 1.00 SBD to another account,
36423643 * simply use:
3643- * <code>SteemJ.transfer(new AccountName("accountb"), AssetSymbolType.SBD, 1.0, "My memo");</code>
3644+ * <code>SteemJ.transfer(new AccountName("accountb"), new Asset( 1.0, AssetSymbolType.SBD) , "My memo");</code>
36443645 *
36453646 * <b>Attention</b>
36463647 * <ul>
@@ -3655,20 +3656,18 @@ public void deletePostOrComment(AccountName postOrCommentAuthor, Permlink postOr
36553656 * transfer from. If no default account has been provided, this method will
36563657 * throw an error. If you do not want to configure the following account as
36573658 * a default account, please use the
3658- * {@link #transfer(AccountName, AccountName, AssetSymbolType, double, String)}
3659- * method and provide the <code>from</code> account separately.</li>
3659+ * {@link #transfer(AccountName, AccountName, Asset, String)} method and
3660+ * provide the <code>from</code> account separately.</li>
36603661 * </ul>
36613662 *
36623663 * @param to
36633664 * The account name of the account the
36643665 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} should
36653666 * transfer currency to.
3666- * @param assetType
3667- * Asset type, see
3668- * {@link eu.bittrade.libs.steemj.enums.AssetSymbolType}.
36693667 * @param amount
3670- * Normalized amount of asset to transfer. For example, use 1.0
3671- * to transfer 1 SBD.
3668+ * An {@link Asset} object containing the Asset type (see
3669+ * {@link eu.bittrade.libs.steemj.enums.AssetSymbolType} and the
3670+ * amount to transfer.
36723671 * @param memo
36733672 * Message include with transfer (255 char max)
36743673 * @return The TransferOperation broadcast.
@@ -3692,13 +3691,13 @@ public void deletePostOrComment(AccountName postOrCommentAuthor, Permlink postOr
36923691 * If one of the provided parameters does not fulfill the
36933692 * requirements described above.
36943693 */
3695- public TransferOperation transfer (AccountName to , AssetSymbolType assetType , double amount , String memo )
3694+ public TransferOperation transfer (AccountName to , Asset amount , String memo )
36963695 throws SteemCommunicationException , SteemResponseException , SteemInvalidTransactionException {
36973696 if (SteemJConfig .getInstance ().getDefaultAccount ().isEmpty ()) {
36983697 throw new InvalidParameterException (NO_DEFAULT_ACCOUNT_ERROR_MESSAGE );
36993698 }
37003699
3701- return transfer (SteemJConfig .getInstance ().getDefaultAccount (), to , assetType , amount , memo );
3700+ return transfer (SteemJConfig .getInstance ().getDefaultAccount (), to , amount , memo );
37023701 }
37033702
37043703 /**
@@ -3719,11 +3718,10 @@ public TransferOperation transfer(AccountName to, AssetSymbolType assetType, dou
37193718 * The account from which to transfer currency.
37203719 * @param to
37213720 * The account to which to transfer currency.
3722- * @param assetType
3723- * Asset type, see
3724- * {@link eu.bittrade.libs.steemj.enums.AssetSymbolType}.
37253721 * @param amount
3726- * The amount to transfer.
3722+ * An {@link Asset} object containing the Asset type (see
3723+ * {@link eu.bittrade.libs.steemj.enums.AssetSymbolType} and the
3724+ * amount to transfer.
37273725 * @param memo
37283726 * Message include with transfer (255 char max)
37293727 * @return The TransferOperation broadcast.
@@ -3747,19 +3745,9 @@ public TransferOperation transfer(AccountName to, AssetSymbolType assetType, dou
37473745 * If one of the provided parameters does not fulfill the
37483746 * requirements described above.
37493747 */
3750- public TransferOperation transfer (AccountName from , AccountName to , AssetSymbolType assetType , double amount ,
3751- String memo ) throws SteemCommunicationException , SteemResponseException , SteemInvalidTransactionException {
3752- // Convert amount to long asset value. Conversion factor depends on
3753- // asset type
3754- Asset asset = new Asset ();
3755- asset .setSymbol (assetType );
3756- asset .setAmount (Double .valueOf (amount * Math .pow (10.0 , asset .getPrecision ())).longValue ());
3757- if (!asset .toReal ().equals (amount )) {
3758- throw new IllegalStateException ("Amount conversion mismatch: " + amount + " -> " + asset .toReal ());
3759- }
3760-
3761- // Create & broadcast transfer operation
3762- TransferOperation transferOperation = new TransferOperation (from , to , asset , memo );
3748+ public TransferOperation transfer (AccountName from , AccountName to , Asset amount , String memo )
3749+ throws SteemCommunicationException , SteemResponseException , SteemInvalidTransactionException {
3750+ TransferOperation transferOperation = new TransferOperation (from , to , amount , memo );
37633751 ArrayList <Operation > operations = new ArrayList <>();
37643752 operations .add (transferOperation );
37653753 DynamicGlobalProperty globalProperties = this .getDynamicGlobalProperties ();
0 commit comments