orchstr service transfer command works without wallet availability

This commit is contained in:
Lex Berezhny 2019-01-16 13:28:12 -05:00
parent a53b60fca4
commit 2cb9d5c636

View file

@ -80,10 +80,13 @@ class ConductorService:
async def transfer(self, request):
data = await request.post()
address = data.get('address')
if not address:
if not address and self.stack.wallet_started:
address = await self.stack.wallet_node.account.receiving.get_or_create_usable_address()
if not address:
raise ValueError("No address was provided.")
amount = data.get('amount', 1)
txid = await self.stack.blockchain_node.send_to_address(address, amount)
if self.stack.wallet_started:
await self.stack.wallet_node.ledger.on_transaction.where(
lambda e: e.tx.id == txid and e.address == address
)