Skip to content

Commit

Permalink
supported selecting asset_id to fee for simple transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
brickgao committed Mar 12, 2018
1 parent c7f9899 commit 732d7d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bitshares/bitshares.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,15 @@ def clear(self):
# -------------------------------------------------------------------------
# Simple Transfer
# -------------------------------------------------------------------------
def transfer(self, to, amount, asset, memo="", account=None, **kwargs):
def transfer(self, to, amount, asset, memo="", fee_asset="1.3.0", account=None, **kwargs):
""" Transfer an asset to another account.
:param str to: Recipient
:param float amount: Amount to transfer
:param str asset: Asset to transfer
:param str memo: (optional) Memo, may begin with `#` for encrypted
messaging
:param str fee_asset: Asset to fee
:param str account: (optional) the source account for the transfer
if not ``default_account``
"""
Expand All @@ -438,7 +439,7 @@ def transfer(self, to, amount, asset, memo="", account=None, **kwargs):
)

op = operations.Transfer(**{
"fee": {"amount": 0, "asset_id": "1.3.0"},
"fee": {"amount": 0, "asset_id": fee_asset},
"from": account["id"],
"to": to["id"],
"amount": {
Expand Down
6 changes: 5 additions & 1 deletion bitshares/transactionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ def constructTx(self):
ops.extend([Operation(op)])

# We no wrap everything into an actual transaction
ops = transactions.addRequiredFees(self.bitshares.rpc, ops)
if len(ops) == 1 and isinstance(ops[0].op, operations.Transfer):
fee_assert_id = ops[0].op.data["fee"].data["asset_id"].Id
ops = transactions.addRequiredFees(self.bitshares.rpc, ops, asset_id=fee_assert_id)
else:
ops = transactions.addRequiredFees(self.bitshares.rpc, ops)
expiration = transactions.formatTimeFromNow(
self.expiration or self.bitshares.expiration
)
Expand Down

0 comments on commit 732d7d2

Please sign in to comment.