def tx_prepare(ctx, src, dst, amount, fee, pk, otsidx):
"""
Request a tx blob (unsigned) to transfer from src to dst (uses local wallet)
"""
try:
address_src, src_xmss = _select_wallet(ctx, src)
if src_xmss:
address_src_pk = src_xmss.pk()
address_src_otsidx = src_xmss.get_index()
else:
address_src_pk = pk.encode()
address_src_otsidx = int(otsidx)
address_dst = dst.encode()
amount_shor = int(amount * 1.e8)
fee_shor = int(fee * 1.e8)
except Exception as e:
click.echo("Error validating arguments")
quit(1)
channel = grpc.insecure_channel(ctx.obj.node_public_address)
stub = qrl_pb2_grpc.PublicAPIStub(channel)
# FIXME: This could be problematic. Check
transferCoinsReq = qrl_pb2.TransferCoinsReq(address_from=address_src,
address_to=address_dst,
amount=amount_shor,
fee=fee_shor,
xmss_pk=address_src_pk,
xmss_ots_index=address_src_otsidx)
try:
transferCoinsResp = stub.TransferCoins(transferCoinsReq, timeout=5)
except grpc.RpcError as e:
click.echo(e.details())
quit(1)
except Exception as e:
click.echo("Unhandled error: {}".format(str(e)))
quit(1)
txblob = bin2hstr(transferCoinsResp.transaction_unsigned.SerializeToString())
print(txblob)
评论列表
文章目录